reset channel feature

This commit is contained in:
SowinskiBraeden committed 2023-02-27 10:45:33 -08:00
1 parent 8997b5de01
commit df3ec26f13
5 files changed
+482 -338

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@ module.exports = {
if (!channel) return interaction.send({ content: `Uh Oh! The channel <#${args[0].value}> connot be found.` }); if (!channel) return interaction.send({ content: `Uh Oh! The channel <#${args[0].value}> connot be found.` });
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild); let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (guild.server.hasCustomChannels==false) return interaction.send({ content: `There are no channels to be removed.` }); if (guild.server.hasCustomChannels==false) return interaction.send({ content: `There are no channels to be removed.` });
if (!guild.server.allowedChannels.includes(channelid)) return interaction.send({ content: `The channel <#${args[0].value}> is not added to your roles.` }); if (!guild.server.allowedChannels.includes(channelid)) return interaction.send({ content: `The channel <#${args[0].value}> is not added to your channels.` });
for (let i = 0; i < guild.server.allowedChannels.length; i++) { for (let i = 0; i < guild.server.allowedChannels.length; i++) {
if (guild.server.allowedChannels[i]==channelid) { if (guild.server.allowedChannels[i]==channelid) {
if ((guild.server.allowedChannels.length-1)==0) { if ((guild.server.allowedChannels.length-1)==0) {
+32
View File
@@ -0,0 +1,32 @@
const { EmbedBuilder } = require('discord.js');
const bitfieldCalculator = require('discord-bitfield-calculator');
module.exports = {
name: "reset_channels",
description: "Reset the configured channels for the bot",
usage: "[channel]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
SlashCommand: {
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
const permissions = bitfieldCalculator.permissions(interaction.member.permissions);
if (!permissions.includes("MANAGE_GUILD")) return interaction.send({ content: 'You don\'t have the permissions to use this command.' });
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (client.exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return interaction.send({ content: `The channel <#${args[0].value}> has already been added.` });
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.allowedChannels":[]},$set:{"server.hasCustomChannels":false}},function(err, res) {
if (err) throw err;
return interaction.send({ content: `Successfully reset all configured channels` });
});
},
},
}
-39
View File
@@ -1,39 +0,0 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "setprefix",
description: "Update prefix for the bot",
usage: "[new Prefix]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
options: [
{
name: "new-prefix",
description: "Update prefix for the bot",
value: "setprefix",
type: 3,
required: true,
},
],
SlashCommand: {
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} 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({ content: `You are not allowed to use the bot in this channel.` });
}
if (args[0].length<1) return interaction.send({ content: 'Your new prefix must be \`1\` character!' })
client.dbo.collection("prefixes").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.prefix":args[0].value}},function(err, res) {
if (err) throw err;
interaction.send({ content: `The new prefix is now **\`${args[0].value}\`**` });
});
},
},
}
+448 -298
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -12,6 +12,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"colors": "^1.4.0", "colors": "^1.4.0",
"discord-bitfield-calculator": "^1.2.0",
"discord.js": "^14.3.0", "discord.js": "^14.3.0",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"express": "^4.17.1", "express": "^4.17.1",