revamp settings into one command
This commit is contained in:
6 files changed
+480
-481
No files matched your search
@@ -1,176 +0,0 @@
|
|||||||
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: "remove-channel",
|
|
||||||
debug: false,
|
|
||||||
description: "Remove channel",
|
|
||||||
usage: "[channel type]",
|
|
||||||
permissions: {
|
|
||||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
|
||||||
member: ["MANAGE_GUILD"],
|
|
||||||
},
|
|
||||||
SlashCommand: {
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @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.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = {
|
|
||||||
$set: {
|
|
||||||
"server.actionChannel": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else query = {
|
|
||||||
$set: {
|
|
||||||
"server.tweetChannel": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let message = new MessageEmbed()
|
|
||||||
.setTitle(`Are you sure you want to stop using this channel for ${channelType}s?`)
|
|
||||||
.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},query,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;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
const { MessageEmbed, Guild } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: "remove-income",
|
|
||||||
debug: false,
|
|
||||||
description: "remove an income role",
|
|
||||||
usage: "[role] [amount daily]",
|
|
||||||
permissions: {
|
|
||||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
|
||||||
member: ["MANAGE_GUILD"],
|
|
||||||
},
|
|
||||||
SlashCommand: {
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "role",
|
|
||||||
description: "role for this income",
|
|
||||||
value: "role",
|
|
||||||
type: 8,
|
|
||||||
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.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].value);
|
|
||||||
if (searchIndex == -1) {
|
|
||||||
let embed = new MessageEmbed()
|
|
||||||
.setTitle('Role not found')
|
|
||||||
.setColor("RED");
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
|
||||||
} else {
|
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$pull: {"server.incomeRoles": args[0].value}}, 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()
|
|
||||||
.setTitle('Success')
|
|
||||||
.setDescription(`Successfully remoed <@&${args[0].value}> from income roles.`)
|
|
||||||
.setColor('GREEN');
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
const { MessageEmbed } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: "set-channel",
|
|
||||||
debug: false,
|
|
||||||
description: "set a channel",
|
|
||||||
usage: "[channel type] [channel]",
|
|
||||||
permissions: {
|
|
||||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
|
||||||
member: ["MANAGE_GUILD"],
|
|
||||||
},
|
|
||||||
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: "allowed", value: "allowed" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "channel",
|
|
||||||
description: "Channel to send actions/tweets",
|
|
||||||
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 channelType = args[0].value;
|
|
||||||
let channelid = args[1].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 ${channelType} channel.`);
|
|
||||||
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;
|
|
||||||
query = { $set: { "server.actionChannel": channelid } }
|
|
||||||
} else if (channelType == "tweet") {
|
|
||||||
channelSetting = guild.server.tweetChannel;
|
|
||||||
query = { $set: { "server.tweetChannel": channelid } }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channelSetting == channelid) return interaction.send(`The channel <#${args[1].value}> has already been set for ${channelType}s.`);
|
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},query,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}> for ${channelType}s.`);
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
const { MessageEmbed, Guild } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: "set-income",
|
|
||||||
debug: false,
|
|
||||||
description: "set a role to recieve income when working",
|
|
||||||
usage: "[role] [amount daily]",
|
|
||||||
permissions: {
|
|
||||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
|
||||||
member: ["MANAGE_GUILD"],
|
|
||||||
},
|
|
||||||
SlashCommand: {
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "role",
|
|
||||||
description: "role for this income",
|
|
||||||
value: "role",
|
|
||||||
type: 8,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "amount",
|
|
||||||
description: "the amount to earn in 1 day of work",
|
|
||||||
value: 120.00,
|
|
||||||
type: 10,
|
|
||||||
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.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[1].value <= 0) {
|
|
||||||
let embed = new MessageEmbed()
|
|
||||||
.setTitle('Amount cannot be $0 or less than $0')
|
|
||||||
.setColor("RED");
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
|
||||||
}
|
|
||||||
|
|
||||||
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].value);
|
|
||||||
if (searchIndex == -1) {
|
|
||||||
let newIncome = {
|
|
||||||
role: args[0].value,
|
|
||||||
income: args[1].value,
|
|
||||||
}
|
|
||||||
|
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, function(err, res) {
|
|
||||||
if (err) {
|
|
||||||
client.log(err);
|
|
||||||
let embed = new MessageEmbed()
|
|
||||||
.setTitle(err)
|
|
||||||
.setColor("RED");
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": args[0].value},
|
|
||||||
{$set: {"server.incomeRoles.$.income": args[1].value}}, 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()
|
|
||||||
.setTitle('Success')
|
|
||||||
.setDescription(`Updated <@&${args[0].value}>'s income to $${args[1].value}`)
|
|
||||||
.setColor('GREEN');
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
const { MessageEmbed } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: "set-starting-balance",
|
|
||||||
debug: false,
|
|
||||||
description: "change the starting balance for the server",
|
|
||||||
usage: "[amount]",
|
|
||||||
permissions: {
|
|
||||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
|
||||||
member: ["MANAGE_GUILD"],
|
|
||||||
},
|
|
||||||
SlashCommand: {
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "amount",
|
|
||||||
description: "the amount to set the starting balance",
|
|
||||||
value: 1000.00,
|
|
||||||
type: 10,
|
|
||||||
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.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {"server.startingBalance":args[0].value}, 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()
|
|
||||||
.setTitle('Success')
|
|
||||||
.setDescription(`Successfully set $${args[0].value.toFixed(2)} as starting balance`)
|
|
||||||
.setColor('GREEN');
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,480 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "settings",
|
||||||
|
debug: false,
|
||||||
|
description: "configure your server settings",
|
||||||
|
usage: "[opt] [action] [value]",
|
||||||
|
permissions: {
|
||||||
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||||
|
member: ["MANAGE_GUILD"],
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "allowed_channels",
|
||||||
|
description: "set channels you're allowed to use the bot in",
|
||||||
|
value: "allowed_channels",
|
||||||
|
type: 1,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "add/remove",
|
||||||
|
description: "add/remove channel",
|
||||||
|
value: "add/remove",
|
||||||
|
type: 3,
|
||||||
|
required: true,
|
||||||
|
choices: [
|
||||||
|
{ name: "add", value: "add" }, { name: "remove", value: "remove" },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "channel",
|
||||||
|
description: "the channel to configure",
|
||||||
|
value: "channel",
|
||||||
|
type: 7,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "action_channel",
|
||||||
|
description: "set the channel to be used for /me commands",
|
||||||
|
value: "action_channel",
|
||||||
|
type: 1,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "add/remove",
|
||||||
|
description: "add/remove channel",
|
||||||
|
value: "add/remove",
|
||||||
|
type: 3,
|
||||||
|
required: true,
|
||||||
|
choices: [
|
||||||
|
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "channel",
|
||||||
|
description: "the channel to configure",
|
||||||
|
value: "channel",
|
||||||
|
type: 7,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "tweet_channel",
|
||||||
|
description: "set the channel to be used for /tweet commands",
|
||||||
|
value: "tweet_channel",
|
||||||
|
type: 1,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "add/remove",
|
||||||
|
description: "add/remove channel",
|
||||||
|
value: "add/remove",
|
||||||
|
type: 3,
|
||||||
|
required: true,
|
||||||
|
choices: [
|
||||||
|
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "channel",
|
||||||
|
description: "the channel to configure",
|
||||||
|
value: "channel",
|
||||||
|
type: 7,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "starting_balance",
|
||||||
|
description: "set the starting balance",
|
||||||
|
value: "starting_balance",
|
||||||
|
type: 1,
|
||||||
|
options: [{
|
||||||
|
name: "amount",
|
||||||
|
description: "the amount to set the starting balance",
|
||||||
|
value: 1000.00,
|
||||||
|
type: 10,
|
||||||
|
required: true,
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "set_income_role",
|
||||||
|
description: "add/update a role to earn income on /work command",
|
||||||
|
value: "set_income_role",
|
||||||
|
type: 1,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "role",
|
||||||
|
description: "role for this income",
|
||||||
|
value: "role",
|
||||||
|
type: 8,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "amount",
|
||||||
|
description: "the amount to earn in 1 day of work",
|
||||||
|
value: 120.00,
|
||||||
|
type: 10,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "remove_income_role",
|
||||||
|
description: "remove a role from earning income",
|
||||||
|
value: "remove_income_role",
|
||||||
|
type: 1,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "role",
|
||||||
|
description: "role to remove",
|
||||||
|
value: "role",
|
||||||
|
type: 8,
|
||||||
|
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.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].name == 'allowed_channels') {
|
||||||
|
const channelid = args[0].options[1].value;
|
||||||
|
|
||||||
|
if (args[0].options[0].value == 'add') {
|
||||||
|
const channel = client.channels.cache.get(channelid);
|
||||||
|
|
||||||
|
const errorEmbed = new MessageEmbed().setColor("RED")
|
||||||
|
let error = false;
|
||||||
|
|
||||||
|
if (!channel) errorEmbed.setDescription(`**Error Notice:** Cannot find that channel.`);
|
||||||
|
if (channel.type=="voice") errorEmbed.setDescriptions(`**Error Notice:** Cannot add voice channel to allowed channels.`);
|
||||||
|
if (channel.deleted) errorEmbed.setDescription(`**Error Notice":** Cannot add deleted channel to allowed channels.`);
|
||||||
|
if (error) return interaction.send({ embeds: [errorEmbed] });
|
||||||
|
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push:{"server.allowedChannels": channelid}}, function (err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const successEmbed = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setDescription(`**Success:** Set <#${channelid}> as an allowed channel.`);
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
} else if (args[0].options[0].value == 'remove') {
|
||||||
|
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescription(`**Error Notice:** <#${channelid}> 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) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const prompt = new MessageEmbed()
|
||||||
|
.setTitle(`Are you sure you want to remove this channel from allowed channels?`)
|
||||||
|
.setColor(client.config.EmbedColor)
|
||||||
|
|
||||||
|
const opt = new MessageActionRow()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`yes`)
|
||||||
|
.setLabel("Yes")
|
||||||
|
.setStyle("DANGER"),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`no`)
|
||||||
|
.setLabel("No")
|
||||||
|
.setStyle("SUCCESS")
|
||||||
|
)
|
||||||
|
|
||||||
|
interaction.send({ embeds: [prompt], components: [opt] });
|
||||||
|
|
||||||
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
|
const 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);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (queryString=='no') action = 'kept';
|
||||||
|
|
||||||
|
const successEmbed = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTitle(`Successfully ${action} channel.`)
|
||||||
|
|
||||||
|
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (args[0].name == 'action_channel') {
|
||||||
|
const channelid = args[0].options[1].value;
|
||||||
|
|
||||||
|
if (args[0].options[0].value == 'set') {
|
||||||
|
const guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
||||||
|
const channelSetting = guild.server.actionChannel;
|
||||||
|
|
||||||
|
const presetEmbed = new MessageEmbed()
|
||||||
|
.setColor(client.config.EmbedColor)
|
||||||
|
.setDescription(`The channel <#${channelid}> has already been set for actions.`)
|
||||||
|
|
||||||
|
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.actionChannel":channelid}},function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const successEmbed = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTitle(`Successfully set <#${channelid}> for actions.`)
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
} else if (args[0].options[0].value == 'remove') {
|
||||||
|
const prompt = new MessageEmbed()
|
||||||
|
.setTitle(`Are you sure you want to stop using this channel for actions?`)
|
||||||
|
.setColor(client.config.EmbedColor)
|
||||||
|
|
||||||
|
const opt = new MessageActionRow()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`yes`)
|
||||||
|
.setLabel("Yes")
|
||||||
|
.setStyle("DANGER"),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`no`)
|
||||||
|
.setLabel("No")
|
||||||
|
.setStyle("SUCCESS")
|
||||||
|
)
|
||||||
|
|
||||||
|
interaction.send({ embeds: [prompt], components: [opt] });
|
||||||
|
|
||||||
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
|
const 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) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (queryString=='no') action = 'kept';
|
||||||
|
|
||||||
|
const successEmbed = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTitle(`Successfully ${action} channel.`)
|
||||||
|
|
||||||
|
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (args[0].name == 'tweet_channel') {
|
||||||
|
const channelid = args[0].options[1].value;
|
||||||
|
|
||||||
|
if (args[0].options[0].value == 'set') {
|
||||||
|
const guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
||||||
|
const channelSetting = guild.server.tweetChannel;
|
||||||
|
|
||||||
|
const presetEmbed = new MessageEmbed()
|
||||||
|
.setColor(client.config.EmbedColor)
|
||||||
|
.setDescription(`The channel <#${channelid}> has already been set for tweets.`)
|
||||||
|
|
||||||
|
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.actionChannel":channelid}},function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const successEmbed = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTitle(`Successfully set <#${channelid}> for actions.`)
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
} else if (args[0].options[0].value == 'remove') {
|
||||||
|
const prompt = new MessageEmbed()
|
||||||
|
.setTitle(`Are you sure you want to stop using this channel for tweets?`)
|
||||||
|
.setColor(client.config.EmbedColor)
|
||||||
|
|
||||||
|
const opt = new MessageActionRow()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`yes`)
|
||||||
|
.setLabel("Yes")
|
||||||
|
.setStyle("DANGER"),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`no`)
|
||||||
|
.setLabel("No")
|
||||||
|
.setStyle("SUCCESS")
|
||||||
|
)
|
||||||
|
|
||||||
|
interaction.send({ embeds: [prompt], components: [opt] });
|
||||||
|
|
||||||
|
client.once("interactionCreate", ButtonInteraction => {
|
||||||
|
const queryString = ButtonInteraction.customId;
|
||||||
|
let action = ''
|
||||||
|
if (queryString=='yes') {
|
||||||
|
action = 'removed';
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.tweetChannel": null}},function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (queryString=='no') action = 'kept';
|
||||||
|
|
||||||
|
const successEmbed = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTitle(`Successfully ${action} channel.`)
|
||||||
|
|
||||||
|
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (args[0].name == 'starting_balance') {
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {"server.startingBalance":args[0].options[0].value}, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let successEmbed = new MessageEmbed()
|
||||||
|
.setColor('GREEN')
|
||||||
|
.setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as starting balance`);
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
} else if (args[0].name == 'set_income_role') {
|
||||||
|
if (args[0].options[1].value <= 0) {
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setDescriptions('**Error Notice:** Amount cannot be $0 or less than $0.')
|
||||||
|
.setColor("RED");
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[0].value);
|
||||||
|
if (searchIndex == -1) {
|
||||||
|
const newIncome = {
|
||||||
|
role: args[0].options[0].value,
|
||||||
|
income: args[0].options[1].value,
|
||||||
|
}
|
||||||
|
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": args[0].options[0].value},
|
||||||
|
{$set: {"server.incomeRoles.$.income": args[1].value}}, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||||
|
.setColor("RED")
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const successEmbed = new MessageEmbed()
|
||||||
|
.setDescription(`Successfully updated <@&${args[0].options[0].value}>'s income to $${args[0].options[1].value}`)
|
||||||
|
.setColor('GREEN');
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
} else if (args[0].name == 'remove_income_role') {
|
||||||
|
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[0].value);
|
||||||
|
if (searchIndex == -1) {
|
||||||
|
const errorEmbed = new MessageEmbed()
|
||||||
|
.setDescription('**Error Notice:** Role not found')
|
||||||
|
.setColor("RED");
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [errorEmbed] });
|
||||||
|
} else {
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$pull: {"server.incomeRoles": args[0].options[0].value}}, 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()
|
||||||
|
.setTitle('Success')
|
||||||
|
.setDescription(`Successfully remoed <@&${args[0].options[0].value}> from income roles.`)
|
||||||
|
.setColor('GREEN');
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in new issue
Block a user