re-added quotes chat command for adding them by reply function

This commit is contained in:
2026-04-07 20:23:27 +02:00
parent f41f848ad5
commit 466b9708cf
3 changed files with 84 additions and 1 deletions
+6
View File
@@ -24,6 +24,12 @@ Arthonor-Neo is a custom Discord bot designed for community interaction and fun.
## Differences from Version 2.x ## 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 ### Removed
- Timers - Timers
- WGE - WGE
+76
View File
@@ -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] })
}
}
+2 -1
View File
@@ -8,6 +8,7 @@ require('dotenv').config()
function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
async function quotesAdd(interaction) { async function quotesAdd(interaction) {
const messageLink = await interaction.options.getString('link') const messageLink = await interaction.options.getString('link')
//regex for message link //regex for message link
const regex = /^https:\/\/discord\.com\/channels\/\d+\/\d+\/\d+$/ const regex = /^https:\/\/discord\.com\/channels\/\d+\/\d+\/\d+$/
@@ -357,7 +358,7 @@ module.exports = {
.addSubcommand(s => .addSubcommand(s =>
s s
.setName('add') .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))) .addStringOption(o => o.setName('link').setDescription('insert message link').setRequired(true)))
.addSubcommand(s => .addSubcommand(s =>
s s