From cfd5a2f59a3f2e39a1490687014e78e9e5b0d7fd Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 9 May 2022 13:05:35 +0300 Subject: [PATCH] cleanup --- src/structure/components/commands/utility/Poll.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/structure/components/commands/utility/Poll.js b/src/structure/components/commands/utility/Poll.js index b683bb7..7a792ef 100644 --- a/src/structure/components/commands/utility/Poll.js +++ b/src/structure/components/commands/utility/Poll.js @@ -52,6 +52,7 @@ class PollCommand extends SlashCommand { const { guild, subcommand, member, author } = invoker; if (subcommand.name === 'create') { + await invoker.deferReply(); const questions = []; @@ -111,21 +112,25 @@ class PollCommand extends SlashCommand { }; await guild.createPoll(poll); - await invoker.editReply({ index: 'COMMAND_POLL_START', params: { channel: _channel.id } }); + await invoker.editReply({ emoji: 'success', index: 'COMMAND_POLL_START', params: { channel: _channel.id } }); } else if (subcommand.name === 'delete') { + const poll = guild.callbacks.find((cb) => cb.data.type === 'poll' && cb.data.message === message.value); - if (!poll) return { index: 'COMMAND_POLL_404' }; + if (!poll) return { index: 'COMMAND_POLL_404', emoji: 'failure' }; await guild.removeCallback(poll.id); const pollChannel = await guild.resolveChannel(poll.channel); const msg = await pollChannel.messages.fetch(poll.message).catch(() => null); if(msg) await msg.delete(); return { index: 'COMMAND_POLL_DELETED', emoji: 'success' }; + } else if (subcommand.name === 'end') { + const poll = guild.callbacks.find((cb) => cb.data.type === 'poll' && cb.data.message === message.value); - if (!poll) return { index: 'COMMAND_POLL_404' }; + if (!poll) return { index: 'COMMAND_POLL_404', emoji: 'failure' }; await guild._poll(poll.data); return { index: 'COMMAND_POLL_ENDED', emoji: 'success' }; + } }