minor enhancements / action channel manager
This commit is contained in:
4 files changed
+109
-6
No files matched your search
@@ -0,0 +1,59 @@
|
|||||||
|
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "removeactionchannel",
|
||||||
|
description: "Remove action channel",
|
||||||
|
usage: "",
|
||||||
|
permissions: {
|
||||||
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||||
|
member: ["MANAGE_GUILD"],
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/QuarksBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} message
|
||||||
|
* @param {string[]} args
|
||||||
|
* @param {*} param3
|
||||||
|
*/
|
||||||
|
run: async (client, interaction, args, { GuildDB }) => {
|
||||||
|
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
|
||||||
|
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let message = new MessageEmbed()
|
||||||
|
.setTitle('Are you sure you want to stop using this channel for actions?')
|
||||||
|
.setColor(client.config.EmbedColor)
|
||||||
|
|
||||||
|
let row = new MessageActionRow()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`yes`)
|
||||||
|
.setLabel("Yes")
|
||||||
|
.setStyle("DANGER"),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`no`)
|
||||||
|
.setLabel("No")
|
||||||
|
.setStyle("SUCCESS")
|
||||||
|
)
|
||||||
|
|
||||||
|
interaction.send({ embeds: [message], components: [row] });
|
||||||
|
|
||||||
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
|
let queryString = ButtonInteraction.customId;
|
||||||
|
let action = ''
|
||||||
|
if (queryString=='yes') {
|
||||||
|
action = 'removed';
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.actionChannel":null}},function(err, res) {
|
||||||
|
if (err) throw err;
|
||||||
|
});
|
||||||
|
} else if (queryString=='no') {
|
||||||
|
action = 'kept';
|
||||||
|
}
|
||||||
|
return ButtonInteraction.update({ content: `Successfully ${action} channel.`, embeds: [], components: [] });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -41,8 +41,6 @@ module.exports = {
|
|||||||
interaction.send({ embeds: [message], components: [row] });
|
interaction.send({ embeds: [message], components: [row] });
|
||||||
|
|
||||||
client.once("interactionCreate", ButtonInteraction => {
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
if (ButtonInteraction.message.interaction &&
|
|
||||||
ButtonInteraction.message.interaction.commandName!='removetweetchannel') return;
|
|
||||||
let queryString = ButtonInteraction.customId;
|
let queryString = ButtonInteraction.customId;
|
||||||
let action = ''
|
let action = ''
|
||||||
if (queryString=='yes') {
|
if (queryString=='yes') {
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "actionchannel",
|
||||||
|
description: "Select a channel to send actions",
|
||||||
|
usage: "[channel]",
|
||||||
|
permissions: {
|
||||||
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||||
|
member: ["MANAGE_GUILD"],
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "channel",
|
||||||
|
description: "Channel to send action messages",
|
||||||
|
value: "channel",
|
||||||
|
type: 7,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/QuarksBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} message
|
||||||
|
* @param {string[]} args
|
||||||
|
* @param {*} param3
|
||||||
|
*/
|
||||||
|
run: async (client, interaction, args, { GuildDB }) => {
|
||||||
|
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
|
||||||
|
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let channelid = args[0].value;
|
||||||
|
let channel = client.channels.cache.get(channelid);
|
||||||
|
if (!channel) return interaction.send(`Cannot find that channel.`);
|
||||||
|
if (channel.type=="voice") return interaction.send(`Connot set voice channel to actions channel.`);
|
||||||
|
if (channel.deleted) return interaction.send(`Connot set deleted channel to actions channel.`);
|
||||||
|
let guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
||||||
|
if (client.exists(guild.server.actionChannel)&&guild.server.actionChannel==channelid) return interaction.send(`The channel <#${args[0].value}> has already been set for actions.`);
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.actionChannel":channelid}},function(err, res) {
|
||||||
|
if (err) throw err;
|
||||||
|
return interaction.send(`Successfully set <#${args[0].value}> for tweets.`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "settweetchannel",
|
name: "tweetchannel",
|
||||||
description: "Select a channel to send tweets",
|
description: "Select a channel to send tweets",
|
||||||
usage: "[channel]",
|
usage: "[channel]",
|
||||||
permissions: {
|
permissions: {
|
||||||
@@ -12,7 +12,7 @@ module.exports = {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: "channel",
|
name: "channel",
|
||||||
description: "Channel to add to allowed channles",
|
description: "Channel to send tweets",
|
||||||
value: "channel",
|
value: "channel",
|
||||||
type: 7,
|
type: 7,
|
||||||
required: true,
|
required: true,
|
||||||
@@ -33,8 +33,8 @@ module.exports = {
|
|||||||
let channelid = args[0].value;
|
let channelid = args[0].value;
|
||||||
let channel = client.channels.cache.get(channelid);
|
let channel = client.channels.cache.get(channelid);
|
||||||
if (!channel) return interaction.send(`Cannot find that channel.`);
|
if (!channel) return interaction.send(`Cannot find that channel.`);
|
||||||
if (channel.type=="voice") return interaction.send(`Connot set voice channel to preferred channel.`);
|
if (channel.type=="voice") return interaction.send(`Connot set voice channel to tweets channel.`);
|
||||||
if (channel.deleted) return interaction.send(`Connot set deleted channel to preferred channel.`);
|
if (channel.deleted) return interaction.send(`Connot set deleted channel to tweets channel.`);
|
||||||
let guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
let guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
||||||
if (client.exists(guild.server.tweetChannel)&&guild.server.tweetChannel==channelid) return interaction.send(`The channel <#${args[0].value}> has already been set for tweets.`);
|
if (client.exists(guild.server.tweetChannel)&&guild.server.tweetChannel==channelid) return interaction.send(`The channel <#${args[0].value}> has already been set for tweets.`);
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.tweetChannel":channelid}},function(err, res) {
|
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.tweetChannel":channelid}},function(err, res) {
|
||||||
|
|||||||
Reference in new issue
Block a user