Finished Nuts/Honor/Quotes
This commit is contained in:
@@ -163,7 +163,7 @@ async function honorCheck(interaction) {
|
||||
}
|
||||
async function honorMenu(interaction) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('- Honor Menu WIP! -')
|
||||
.setTitle('- Honor Menu! -')
|
||||
.setDescription('- Choose someone from the Select Menu below\r\n- Choose Honor Dishonor, or History\r\n- Confirm your Selection')
|
||||
.setThumbnail(interaction.guild.iconURL())
|
||||
const row = new ActionRowBuilder()
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { configDotenv } = require("dotenv");
|
||||
configDotenv
|
||||
|
||||
async function musicJoin(interaction) {
|
||||
const voiceChannel = await interaction.guild.channels.fetch(process.env.D_RealTartarosID)
|
||||
await interaction.client.distube.voices.join(voiceChannel)
|
||||
await voiceChannel.guild.members.me.edit({ mute: false })
|
||||
await interaction.reply({
|
||||
content: `Joined ${voiceChannel}`,
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
async function musicLeave(interaction) {
|
||||
const voiceChannel = await interaction.guild.channels.fetch(process.env.D_RealTartarosID)
|
||||
await interaction.client.distube.voices.leave(voiceChannel)
|
||||
await interaction.reply({
|
||||
content: `Left ${voiceChannel}`,
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
async function musicPlay(interaction) {
|
||||
const url = await interaction.options.getString('url')
|
||||
const regex = /^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/gm
|
||||
const voiceChannel = await interaction.member.voice.channel
|
||||
|
||||
if (!url.match(regex)) {
|
||||
return await interaction.editReply({
|
||||
content: `Invalid URL`,
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
await interaction.client.distube.play(voiceChannel, url)
|
||||
const queue = interaction.client.distube.getQueue(interaction.guild)
|
||||
const { name, thumbnail } = queue.songs[0]
|
||||
const embed = new EmbedBuilder()
|
||||
.setThumbnail(thumbnail)
|
||||
.setTitle(`Added ${name} to Queue`)
|
||||
.setURL(url)
|
||||
await interaction.editReply({
|
||||
embeds: [embed]
|
||||
})
|
||||
}
|
||||
async function musicVolume(interaction) {
|
||||
const queue = interaction.client.distube.getQueue(interaction.guild)
|
||||
if (!queue) {
|
||||
return await interaction.reply({
|
||||
content: `There is nothing in the queue right now!`,
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
const volume = await interaction.options.getNumber('volume')
|
||||
queue.setVolume(volume)
|
||||
await interaction.reply({
|
||||
content: `Set Volume to ${volume}%`,
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
async function musicQueue(interaction) {
|
||||
const queue = interaction.client.distube.getQueue(interaction.guild)
|
||||
if (!queue) {
|
||||
return await interaction.reply({
|
||||
content: `There is nothing in the queue right now!`,
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
const songs = queue.songs.map((song, i) => `${i === 0 ? 'Playing:' : `${i}.`} ${song.name} - \`${song.formattedDuration}\``)
|
||||
.join('\n')
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`Server Queue`)
|
||||
.setDescription(songs.toString())
|
||||
await interaction.reply({
|
||||
embeds: [ embed ]
|
||||
})
|
||||
}
|
||||
async function musicSkip(interaction) {
|
||||
const queue = interaction.client.distube.getQueue(interaction.guild)
|
||||
if (!queue) {
|
||||
return await interaction.reply({
|
||||
content: `There is nothing in the queue right now!`,
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
try {
|
||||
const song = await queue.skip()
|
||||
await interaction.reply({
|
||||
content: `Skipped! Now playing:\n${song.name}`
|
||||
})
|
||||
} catch (e) {
|
||||
await interaction.reply({
|
||||
content: e
|
||||
})
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('music')
|
||||
.setDescription('handles all music related commands')
|
||||
.addSubcommand(s =>
|
||||
s
|
||||
.setName('play')
|
||||
.setDescription('plays music')
|
||||
.addStringOption(o => o.setName('url').setDescription('youtube url').setRequired(true))
|
||||
).addSubcommand(s =>
|
||||
s
|
||||
.setName('join')
|
||||
.setDescription('join default music channel')
|
||||
).addSubcommand(s =>
|
||||
s
|
||||
.setName('leave')
|
||||
.setDescription('leave default music channel')
|
||||
).addSubcommand(s =>
|
||||
s
|
||||
.setName('volume')
|
||||
.setDescription('adjust music volume (default: 50%)')
|
||||
.addNumberOption(o => o.setName('volume').setDescription('choose volume').addChoices(
|
||||
{ name: '100%', value: 100 },
|
||||
{ name: '90%', value: 90 },
|
||||
{ name: '80%', value: 80 },
|
||||
{ name: '70%', value: 70 },
|
||||
{ name: '60%', value: 60 },
|
||||
{ name: '50%', value: 50 },
|
||||
{ name: '40%', value: 40 },
|
||||
{ name: '30%', value: 30 },
|
||||
{ name: '20%', value: 20 },
|
||||
{ name: '10%', value: 10 },
|
||||
{ name: '0%', value: 0 },
|
||||
).setRequired(true))
|
||||
).addSubcommand(s =>
|
||||
s
|
||||
.setName('queue')
|
||||
.setDescription('show current queue')
|
||||
).addSubcommand(s =>
|
||||
s
|
||||
.setName('skip')
|
||||
.setDescription('skip current song')
|
||||
),
|
||||
async execute(interaction) {
|
||||
const subcommand = await interaction.options._subcommand
|
||||
switch (subcommand) {
|
||||
case 'play':
|
||||
interaction.deferReply()
|
||||
musicPlay(interaction)
|
||||
break;
|
||||
case 'join':
|
||||
musicJoin(interaction)
|
||||
break;
|
||||
case 'leave':
|
||||
musicLeave(interaction)
|
||||
break;
|
||||
case 'volume':
|
||||
musicVolume(interaction)
|
||||
break;
|
||||
case 'queue':
|
||||
musicQueue(interaction)
|
||||
break;
|
||||
case 'skip':
|
||||
musicSkip(interaction)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+214
-11
@@ -9,12 +9,22 @@ Random By Year?
|
||||
List?
|
||||
Counter (Leaderboard?)
|
||||
*/
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js')
|
||||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, UserSelectMenuBuilder } = require('discord.js')
|
||||
const { mClient } = require('../..')
|
||||
require('dotenv').config()
|
||||
|
||||
async function quotesAdd(interaction) {
|
||||
const messageLink = await interaction.options.getString('link')
|
||||
//regex for message link
|
||||
const regex = /^https:\/\/discord\.com\/channels\/\d+\/\d+\/\d+$/
|
||||
|
||||
if (!messageLink.match(regex)) {
|
||||
return await interaction.editReply({
|
||||
content: `Invalid URL`,
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
|
||||
let temp = messageLink.split('/')
|
||||
let messageID = temp[temp.length - 1]
|
||||
let channelID = temp[temp.length - 2]
|
||||
@@ -31,23 +41,29 @@ async function quotesAdd(interaction) {
|
||||
embed: await message.embeds ? 'embed' : null
|
||||
} // debug
|
||||
if (msgData.reference) {
|
||||
let refMessage = await channel.messages.fetch(msgData.reference.messageId)
|
||||
let refGuild = await interaction.client.guilds.fetch(msgData.reference.guildId)
|
||||
let refChannel = await refGuild.channels.fetch(msgData.reference.channelId)
|
||||
let refMessage = await refChannel.messages.fetch(msgData.reference.messageId)
|
||||
|
||||
|
||||
var refData = {
|
||||
content: refMessage.content,
|
||||
author: await refMessage.author,
|
||||
embed: await refMessage.embeds ? 'embed' : null
|
||||
embed: await refMessage.embeds.length > 0 ? 'embed' : null
|
||||
}
|
||||
}
|
||||
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const quotesColl = db.collection('quotes')
|
||||
const found = await quotesColl.findOne({ messageID: messageID })
|
||||
if (found) { return await interaction.reply({ content: 'Quote Already in Database', ephemeral: true }) }
|
||||
if (found) { return await interaction.editReply({ content: 'Quote Already in Database', ephemeral: true }) }
|
||||
await quotesColl.findOneAndUpdate({ messageID: messageID }, {
|
||||
$set: {
|
||||
messageID: messageID,
|
||||
channelID: channelID,
|
||||
guildID: guildID
|
||||
guildID: guildID,
|
||||
by: msgData.author.id,
|
||||
count: 0
|
||||
}
|
||||
}, { upsert: true })
|
||||
|
||||
@@ -56,6 +72,8 @@ async function quotesAdd(interaction) {
|
||||
description += `> ${refData.author}`
|
||||
if (refData.embed) {
|
||||
description += '*an embed / a command* '
|
||||
} else {
|
||||
description += refData.content
|
||||
}
|
||||
description += `\r\n↳`
|
||||
}
|
||||
@@ -66,22 +84,199 @@ async function quotesAdd(interaction) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setThumbnail(msgData.author.displayAvatarURL())
|
||||
.setURL(messageLink)
|
||||
.setTitle(`Quote #${messageID} Added!`)
|
||||
.setTitle(`- Quote Added! -`)
|
||||
.setDescription(description)
|
||||
.setFooter({ text: footer})
|
||||
await interaction.reply({ embeds: [embed] })
|
||||
.setFooter({ text: (footer + ' #' + messageID) })
|
||||
await interaction.editReply({ embeds: [embed] })
|
||||
}
|
||||
async function quotesRemove(interaction) {
|
||||
const id = await interaction.options.getString('id')
|
||||
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const quotesColl = db.collection('quotes')
|
||||
const found = await quotesColl.findOne({ messageID: id })
|
||||
if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) }
|
||||
|
||||
await quotesColl.deleteOne({ messageID: id })
|
||||
|
||||
return interaction.reply({ content: 'Quote successfully removed!', ephemeral: true })
|
||||
}
|
||||
async function quotesSearch(interaction) {
|
||||
const id = interaction.options.getString("id")
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const quotesColl = db.collection('quotes')
|
||||
const found = await quotesColl.findOne({ messageID: id })
|
||||
if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) }
|
||||
|
||||
|
||||
const guild = await interaction.client.guilds.fetch(found.guildID)
|
||||
const channel = await guild.channels.fetch(found.channelID)
|
||||
const message = await channel.messages.fetch(found.messageID)
|
||||
|
||||
var msgData = {
|
||||
content: message.content,
|
||||
author: await message.author,
|
||||
reference: await message.reference,
|
||||
embed: await message.embeds ? 'embed' : null
|
||||
} // debug
|
||||
|
||||
quotesColl.findOneAndUpdate({
|
||||
messageID: found.messageID
|
||||
},{
|
||||
$inc: { count: 1}
|
||||
},{
|
||||
upsert: true
|
||||
})
|
||||
|
||||
if (msgData.reference) {
|
||||
let refMessage = await channel.messages.fetch(msgData.reference.messageId)
|
||||
var refData = {
|
||||
content: refMessage.content,
|
||||
author: await refMessage.author,
|
||||
embed: await refMessage.embeds.length > 0 ? 'embed' : null
|
||||
}
|
||||
}
|
||||
|
||||
var description = ''
|
||||
if (refData) {
|
||||
description += `> ${refData.author}`
|
||||
if (refData.embed) {
|
||||
description += '*an embed / a command* '
|
||||
} else {
|
||||
description += refData.content
|
||||
}
|
||||
description += `\r\n↳`
|
||||
}
|
||||
let messageLink = `https://discord.com/channels/${found.guildID}/${found.channelID}/${found.messageID}`
|
||||
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 Found! -`)
|
||||
.setDescription(description)
|
||||
.setFooter({ text: (footer + ' #' + found.messageID) })
|
||||
await interaction.reply({ embeds: [embed] })
|
||||
|
||||
}
|
||||
async function quotesRandom(interaction) {
|
||||
var user = interaction.options.getUser("by")
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const quotesColl = db.collection('quotes')
|
||||
var rdm
|
||||
if(user){
|
||||
rdm = await quotesColl.aggregate([
|
||||
{
|
||||
$match: { by: user.id},
|
||||
},{
|
||||
$sample: { size: 1 }
|
||||
}
|
||||
]).toArray()
|
||||
} else {
|
||||
rdm = await quotesColl.aggregate([
|
||||
{
|
||||
$sample: { size: 1 }
|
||||
}
|
||||
]).toArray()
|
||||
}
|
||||
const found = rdm[0]
|
||||
if (!found) { return await interaction.reply({ content: 'Database Empty', ephemeral: true }) }
|
||||
const guild = await interaction.client.guilds.fetch(found.guildID)
|
||||
const channel = await guild.channels.fetch(found.channelID)
|
||||
const message = await channel.messages.fetch(found.messageID)
|
||||
|
||||
var msgData = {
|
||||
content: message.content,
|
||||
author: await message.author,
|
||||
reference: await message.reference,
|
||||
embed: await message.embeds ? 'embed' : null
|
||||
} // debug
|
||||
|
||||
quotesColl.findOneAndUpdate({
|
||||
messageID: found.messageID
|
||||
},{
|
||||
$inc: { count: 1}
|
||||
},{
|
||||
upsert: true
|
||||
})
|
||||
|
||||
if (msgData.reference) {
|
||||
let refMessage = await channel.messages.fetch(msgData.reference.messageId)
|
||||
var refData = {
|
||||
content: refMessage.content,
|
||||
author: await refMessage.author,
|
||||
embed: await refMessage.embeds.length > 0 ? 'embed' : null
|
||||
}
|
||||
}
|
||||
|
||||
var description = ''
|
||||
if (refData) {
|
||||
description += `> ${refData.author}`
|
||||
if (refData.embed) {
|
||||
description += '*an embed / a command* '
|
||||
} else {
|
||||
description += refData.content
|
||||
}
|
||||
description += `\r\n↳`
|
||||
}
|
||||
let messageLink = `https://discord.com/channels/${found.guildID}/${found.channelID}/${found.messageID}`
|
||||
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 Found! -`)
|
||||
.setDescription(description)
|
||||
.setFooter({ text: (footer + ' #' + found.messageID) })
|
||||
await interaction.reply({ embeds: [embed] })
|
||||
}
|
||||
async function quotesList(interaction) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('- Quotes List! -')
|
||||
.setDescription('- Choose someone below to filter by User')
|
||||
.setThumbnail(interaction.guild.iconURL())
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setEmoji(`◀`)
|
||||
.setCustomId('quotes_list_left')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setEmoji(`❌`)
|
||||
.setCustomId('abort')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setEmoji(`▶`)
|
||||
.setCustomId('quotes_list_right')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
)
|
||||
|
||||
const select = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new UserSelectMenuBuilder()
|
||||
.setCustomId('quotes_list_mentionable')
|
||||
.setPlaceholder('Filter by User')
|
||||
)
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [embed],
|
||||
components: [select, row],
|
||||
ephemeral: true
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
async function quotesLeaderboard(interaction) {
|
||||
|
||||
// need to add count to quotes
|
||||
}
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -106,14 +301,19 @@ module.exports = {
|
||||
s
|
||||
.setName('random')
|
||||
.setDescription('get a random quote')
|
||||
.addUserOption(o => o.setName('target').setDescription('by user')))
|
||||
.addUserOption(o => o.setName('by').setDescription('by user')))
|
||||
.addSubcommand(s =>
|
||||
s
|
||||
.setName('leaderboard')
|
||||
.setDescription('see the most used quotes')),
|
||||
.setDescription('see the most used quotes'))
|
||||
.addSubcommand(s =>
|
||||
s
|
||||
.setName('list')
|
||||
.setDescription('[ADMIN] list all quotes')),
|
||||
async execute(interaction) {
|
||||
switch (interaction.options._subcommand) {
|
||||
case 'add':
|
||||
await interaction.deferReply()
|
||||
quotesAdd(interaction)
|
||||
break;
|
||||
case 'remove':
|
||||
@@ -128,6 +328,9 @@ module.exports = {
|
||||
case 'leaderboard':
|
||||
quotesLeaderboard(interaction)
|
||||
break;
|
||||
case 'list':
|
||||
quotesList(interaction)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
const { SlashCommandBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('ping')
|
||||
.setDescription('returns pong'),
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply()
|
||||
await interaction.editReply('pong!')
|
||||
await interaction.followUp('another pong!')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user