add/remove channels with allowed channels
This commit is contained in:
3 files changed
+117
-13
No files matched your search
+1
-1
@@ -62,7 +62,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
newBalance = banking.account.balance + args[0].value;
|
||||
newCash = Math.abs(banking.account.cash - args[0].value);
|
||||
newCash = Math.abs(banking.account.cash.toFixed(2) - args[0].value);
|
||||
|
||||
client.dbo.collection("banking").updateOne({"account.userID":interaction.member.user.id},{$set:{"account.balance":newBalance,"account.cash":newCash}}, function(err, res) {
|
||||
if (err) {
|
||||
|
||||
+94
-10
@@ -11,14 +11,34 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
options: [
|
||||
{
|
||||
name: "channel-type",
|
||||
description: "What the channel is used for",
|
||||
value: "channel-type",
|
||||
type: 3,
|
||||
required: true,
|
||||
choices: [
|
||||
{ name: "action", value: "action" }, { name: "tweet", value: "tweet" },
|
||||
],
|
||||
name: "action",
|
||||
description: "remove action channel",
|
||||
value: "action",
|
||||
type: 1,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "tweet",
|
||||
description: "remove tweet channel",
|
||||
value: "tweet",
|
||||
type: 1,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
name: "allowed",
|
||||
description: "remove an allowed channel",
|
||||
value: "allowed",
|
||||
type: 1,
|
||||
required: false,
|
||||
options: [
|
||||
{
|
||||
name: "channel",
|
||||
description: "Channel to send add to allowed channels",
|
||||
value: "channel",
|
||||
type: 7,
|
||||
required: true,
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
/**
|
||||
@@ -33,7 +53,66 @@ module.exports = {
|
||||
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||
}
|
||||
|
||||
let channelType = args[0].value;
|
||||
if (args[0].name == 'allowed') {
|
||||
let channelid = args[0].options[0].value;
|
||||
|
||||
let embed = new MessageEmbed()
|
||||
.setTitle('Channel is not in allowed Channels')
|
||||
.setColor("RED")
|
||||
|
||||
if (!GuildDB.allowedChannels.includes(channelid)) return interaction.send({ embeds: [embed] });
|
||||
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
|
||||
|
||||
});
|
||||
|
||||
let message = new MessageEmbed()
|
||||
.setTitle(`Are you sure you want to remove this channel from allowed channels?`)
|
||||
.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":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
let embed = new MessageEmbed()
|
||||
.setTitle(err)
|
||||
.setColor("RED")
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
} else if (queryString=='no') {
|
||||
action = 'kept';
|
||||
}
|
||||
|
||||
let successEmbed = new MessageEmbed()
|
||||
.setColor("GREEN")
|
||||
.setTitle(`Successfully ${action} channel.`)
|
||||
|
||||
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let channelType = args[0].name;
|
||||
let query;
|
||||
if (channelType == "action") {
|
||||
query = {
|
||||
@@ -83,7 +162,12 @@ module.exports = {
|
||||
} else if (queryString=='no') {
|
||||
action = 'kept';
|
||||
}
|
||||
return ButtonInteraction.update({ content: `Successfully ${action} channel.`, embeds: [], components: [] });
|
||||
|
||||
let successEmbed = new MessageEmbed()
|
||||
.setColor("GREEN")
|
||||
.setTitle(`Successfully ${action} channel.`)
|
||||
|
||||
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||
});
|
||||
return;
|
||||
},
|
||||
|
||||
+22
-2
@@ -17,12 +17,12 @@ module.exports = {
|
||||
type: 3,
|
||||
required: true,
|
||||
choices: [
|
||||
{ name: "action", value: "action" }, { name: "tweet", value: "tweet" },
|
||||
{ name: "action", value: "action" }, { name: "tweet", value: "tweet" }, { name: "allowed", value: "allowed" },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
description: "Channel to send tweets",
|
||||
description: "Channel to send actions/tweets",
|
||||
value: "channel",
|
||||
type: 7,
|
||||
required: true,
|
||||
@@ -49,6 +49,26 @@ module.exports = {
|
||||
if (channel.deleted) return interaction.send(`Connot set deleted channel to ${channelType} channel.`);
|
||||
let guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
||||
|
||||
if (channelType == "allowed") {
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push:{"server.allowedChannels": channelid}}, function (err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
let embed = new MessageEmbed()
|
||||
.setTitle(err)
|
||||
.setColor("RED")
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
|
||||
let successEmbed = new MessageEmbed()
|
||||
.setColor("GREEN")
|
||||
.setTitle("Success")
|
||||
.setDescription(`Successfully set <#${channelid}> as an allowed channel.`);
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
}
|
||||
|
||||
let channelSetting, query;
|
||||
if (channelType == "action") {
|
||||
channelSetting = guild.server.actionChannel;
|
||||
|
||||
Reference in new issue
Block a user