From bb4a1d5cf5ced0aeaf8d6469bc335465484a0156 Mon Sep 17 00:00:00 2001 From: ui_creeperlv Date: Wed, 6 Mar 2024 14:00:53 +0530 Subject: [PATCH] Basic /setup Saving into Database --- src/commands/servers/setup.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/commands/servers/setup.js b/src/commands/servers/setup.js index d95ab67..b384e80 100644 --- a/src/commands/servers/setup.js +++ b/src/commands/servers/setup.js @@ -15,8 +15,19 @@ module.exports = { async execute(interaction) { var channel = interaction.options.getChannel("channel"); - console.log(channel); - - await interaction.reply('Pong!'); + interaction.client.database.search("xan.guilds" , { + serverId : interaction.guild.id + } , async (data) => { + if(data == null){ + interaction.client.database.insert("xan.guilds" , { + serverId : interaction.guild.id, + channelId : channel.id + }, async (c) => { + await interaction.reply(`Saved Channel as #${channel.name} in Database`); + }) + }else{ + await interaction.reply(`Guild is already saved into Database`); + } + }); }, }; \ No newline at end of file