From 918b383a48b8780c6fb3e7f30e909cb77b1cdb51 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Sun, 3 Jul 2022 15:16:23 -0700 Subject: [PATCH] fix bugs/add tweet command --- commands/help.js | 1 - commands/me.js | 6 ++--- commands/tweet.js | 60 +++++++++++++++++++++++++++++++++++++++++ structures/QuarksBot.js | 3 --- 4 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 commands/tweet.js diff --git a/commands/help.js b/commands/help.js index b340637..3a5bfff 100644 --- a/commands/help.js +++ b/commands/help.js @@ -8,7 +8,6 @@ module.exports = { channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], member: [], }, - aliases: ["command", "commands", "cmd"], /** * * @param {require("../structures/LinesPoliceCadBot")} client diff --git a/commands/me.js b/commands/me.js index 0e08407..f5434d2 100644 --- a/commands/me.js +++ b/commands/me.js @@ -8,7 +8,6 @@ module.exports = { channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], member: [], }, - aliases: ["action", "do"], /** * * @param {require("../structures/LinesPoliceCadBot")} client @@ -46,9 +45,10 @@ module.exports = { if (client.exists(GuildDB.actionChannel)) { const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.actionChannel); - return channel.send({ embeds: [actionEmbed] }); + channel.send({ embeds: [actionEmbed] }); + return interaction.send('Action performed'); } else { - return interaction.send({ embeds: [actionEmbed] }); + return interaction.send({ content: 'Action performed', embeds: [actionEmbed] }); } }, }, diff --git a/commands/tweet.js b/commands/tweet.js new file mode 100644 index 0000000..df67317 --- /dev/null +++ b/commands/tweet.js @@ -0,0 +1,60 @@ +const { MessageEmbed } = require('discord.js'); + +module.exports = { + name: "tweet", + description: "Tweet your thoughts to the local twitter page", + usage: "[message]", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: [], + }, + /** + * + * @param {require("../structures/LinesPoliceCadBot")} client + * @param {import("discord.js").MessageCreate} message + * @param {string[]} args + * @param {*} param3 + */ + SlashCommand: { + options: [ + { + name: "message", + description: "Your message to tweet", + value: "message", + type: 3, + required: true, + }, + ], + /** + * + * @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 userID = interaction.member.user.id; + let avatar = interaction.member.user.avatar; + + const tweetEmbed = new MessageEmbed() + .setColor('#0099ff') + .setTitle('New Twitter Notifciation') + .setThumbnail('https://static.vecteezy.com/system/resources/previews/002/534/045/original/social-media-twitter-logo-blue-isolated-free-vector.jpg') + .setAuthor({ name: `${interaction.member.user.username}`, iconURL: `https://cdn.discordapp.com/avatars/${userID}/${avatar}.png` }) + .setDescription(args[0].value) + .setTimestamp() + + if (client.exists(GuildDB.tweetChannel)) { + const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.tweetChannel); + channel.send({ embeds: [tweetEmbed] }); + return interaction.send('Tweeted!'); + } else { + return interaction.send({ content: 'Tweeted!', embeds: [tweetEmbed] }); + } + }, + }, +} \ No newline at end of file diff --git a/structures/QuarksBot.js b/structures/QuarksBot.js index 7370604..51c680b 100644 --- a/structures/QuarksBot.js +++ b/structures/QuarksBot.js @@ -29,10 +29,7 @@ class QuarksBot extends Client { this.ws.on("INTERACTION_CREATE", async (interaction) => { client.log("Interaction") let GuildDB = await this.GetGuild(interaction.guild_id); - - if (interaction.type==3) return; - const command = interaction.data.name.toLowerCase(); const args = interaction.data.options;