From 21b17797d73919dceac4e0241d4691f8eacba067 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Wed, 16 Mar 2022 21:17:36 -0700 Subject: [PATCH] update/channels --- commands/channels.js | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 commands/channels.js diff --git a/commands/channels.js b/commands/channels.js new file mode 100644 index 0000000..e1c6a8f --- /dev/null +++ b/commands/channels.js @@ -0,0 +1,75 @@ +const { MessageEmbed } = require('discord.js'); + +module.exports = { + name: "channels", + description: "View a list of allowed channels", + usage: "", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: [], + }, + aliases: [], + /** + * + * @param {require("../structures/LinesPoliceCadBot")} client + * @param {import("discord.js").MessageCreate} message + * @param {string[]} args + * @param {*} param3 + */ + run: async (client, message) => { + let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild); + if (guild.server.hasCustomChannels==false) { + return message.channel.send('There are no channels set for the bot.'); + } + + let channels = ``; + for (let i = 0; i < guild.server.allowedChannels.length; i++) { + if (guild.server.allowedChannels[i] == undefined) break; + if (channels.length==0) channels += `<#${guild.server.allowedChannels[i]}>`; + else channels += `\n<#${guild.server.allowedChannels[i]}>`; + } + let channelsEmbed = new MessageEmbed() + .setColor('#0099ff') + .setDescription('**Allowed Channels to use the Bot**') + .addFields( + { name: `There are currently ${guild.server.allowedChannels.length} allowed channels.`, value: `${channels}`, inline: true }, + ) + .setFooter('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t') + return message.channel.send({ embeds: [channelsEmbed] }); + }, + SlashCommand: { + options: [], + /** + * + * @param {require("../structures/LinesPoliceCadBot")} 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 guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild); + if (guild.server.hasCustomChannels==false) { + return interaction.send('There are no channels set for the bot.'); + } + + let channels = ``; + for (let i = 0; i < guild.server.allowedChannels.length; i++) { + if (guild.server.allowedChannels[i] == undefined) break; + if (channels.length==0) channels += `<#${guild.server.allowedChannels[i]}>`; + else channels += `\n<#${guild.server.allowedChannels[i]}>`; + } + let channelsEmbed = new MessageEmbed() + .setColor('#0099ff') + .setDescription('**Allowed Channels to use the Bot**') + .addFields( + { name: `There are currently ${guild.server.allowedChannels.length} allowed channels.`, value: `${channels}`, inline: true }, + ) + .setFooter('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t') + return interaction.send({ embeds: [channelsEmbed] }); + }, + }, +} \ No newline at end of file