diff --git a/README.md b/README.md index 799850c..0073535 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ Arthonor-Neo is a custom Discord bot designed for community interaction and fun. ## Differences from Version 2.x +### Legacy Commands (Chat Messages) +These have been mostly removed with certain exceptions: + +- Quoteadd has been kept due to the technicaly incompabiltity of replying using slash commands. +- Nuts has been kept due to frequent usage + ### Removed - Timers - WGE diff --git a/commands/legacy/quotes/quoteadd.js b/commands/legacy/quotes/quoteadd.js new file mode 100644 index 0000000..4d6ab57 --- /dev/null +++ b/commands/legacy/quotes/quoteadd.js @@ -0,0 +1,76 @@ +const { EmbedBuilder, MessageFlags } = require("discord.js") +const { client, mClient } = require("../../../index") + +module.exports = { + name: 'quotesadd', + description: 'adds a quote to the database by replying to the message', + category: 'Quotes', + aliases: ['qadd', 'qa'], + async execute(message, args) { + const refMessage = message.reference // message to be quoted has been replied to + const refMessageId = refMessage.messageId + const refChannelId = refMessage.channelId + const refGuildId = refMessage.guildId + var msgData = {} + var refData = {} + const quoteGuild = await client.guilds.fetch(refGuildId) + const quoteChannel = await quoteGuild.channels.fetch(refChannelId) + const quoteMessage = await quoteChannel.messages.fetch(refMessageId) + + msgData = { + content: quoteMessage.content, + author: await quoteMessage.author, + reference: await quoteMessage.reference, + embed: await quoteMessage.embeds ? 'embed' : null + } // debug + if (msgData.reference) { + const quoteRefGuild = await client.guilds.fetch(msgData.reference.guildId) + const quoteRefChannel = await quoteRefGuild.channels.fetch(msgData.reference.channelId) + const quoteRefMessage = await quoteRefChannel.messages.fetch(msgData.reference.messageId) + + + refData = { + content: quoteRefMessage.content, + author: await quoteRefMessage.author, + embed: await quoteRefMessage.embeds.length > 0 ? 'embed' : null + } + } + + const db = mClient.db(process.env.M_DB) + const quotesColl = db.collection('items_quotes') + const found = await quotesColl.findOne({ messageID: quoteMessage.id }) + if (found) { return await message.reply({ content: 'Quote Already in Database', flags: MessageFlags.Ephemeral }) } + await quotesColl.findOneAndUpdate({ messageID: quoteMessage.id }, { + $set: { + messageID: quoteMessage.id, + channelID: quoteChannel.id, + guildID: quoteGuild.id, + by: msgData.author.id, + count: 0 + } + }, { upsert: true }) + + var description = '' + if (refData) { + description += `> ${refData.author}` + if (refData.embed) { + description += '*an embed / a command* ' + } else { + description += refData.content + } + description += `\r\n↳` + } + const messageLink = `https://discord.com/channels/${quoteGuild.id}/${quoteChannel.id}/${quoteMessage.id}/` + description += `${msgData.author} ${msgData.content}\r\n\r\n${messageLink}` + let timestamp = new Date(message.createdTimestamp) + let footer = timestamp.toDateString().toString() + + const embed = new EmbedBuilder() + .setThumbnail(msgData.author.displayAvatarURL()) + .setURL(messageLink) + .setTitle(`- Quote Added! -`) + .setDescription(description) + .setFooter({ text: (footer + ' #' + quoteMessage.id) }) + await message.reply({ embeds: [embed] }) + } +} diff --git a/commands/slash/applications/quotes.js b/commands/slash/applications/quotes.js index ecd1b64..43f4d06 100644 --- a/commands/slash/applications/quotes.js +++ b/commands/slash/applications/quotes.js @@ -8,6 +8,7 @@ require('dotenv').config() function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function quotesAdd(interaction) { + const messageLink = await interaction.options.getString('link') //regex for message link const regex = /^https:\/\/discord\.com\/channels\/\d+\/\d+\/\d+$/ @@ -357,7 +358,7 @@ module.exports = { .addSubcommand(s => s .setName('add') - .setDescription('add a new quote') + .setDescription('add a new quote either by replying to a message or inserting the message link') .addStringOption(o => o.setName('link').setDescription('insert message link').setRequired(true))) .addSubcommand(s => s