added !list command

This commit is contained in:
DeSqBlocki
2023-03-10 01:10:29 +01:00
parent f6456df41b
commit f62636cfde
+18 -1
View File
@@ -1,4 +1,4 @@
const { Client, Events, GatewayIntentBits, Partials } = require('discord.js');
const { Client, Events, GatewayIntentBits, Partials, EmbedBuilder } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
@@ -91,6 +91,8 @@ client.on(Events.MessageCreate, async (msg) => {
case "remove":
delChannel(args[1], msg)
break;
case "list":
listChannels(msg)
default:
break;
}
@@ -118,4 +120,19 @@ function delChannel(channel, msg) {
content: `Unsubscribed from [${channel}] Notifications!`
})
}
function listChannels(msg){
let subscribed = []
let embed = new EmbedBuilder()
.setTitle('Lists of Subscribed Channels:')
for (const [key, value] of Object.entries(channels)) {
if(value.includes(msg.author.id)){
subscribed.push(key)
}
}
embed.setDescription(subscribed.join("\n"))
msg.reply({
embeds: [embed]
})
}
client.login(process.env.DISCORD_Token);