trying to handle music
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js")
|
||||
const { mClient } = require("../..")
|
||||
require('dotenv').config()
|
||||
|
||||
module.exports = {
|
||||
name: 'honor_menu_dishonor',
|
||||
description: 'honor menu dishonor button',
|
||||
async execute(interaction) {
|
||||
let description = interaction.message.embeds[0].data.description
|
||||
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const honorsColl = db.collection('honors')
|
||||
const reason = `[-] Quick Menu Dishonor`
|
||||
const theirHonorLevel = await honorsColl.findOne({ userID: target.id })
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('- Honor Menu WIP -')
|
||||
.setDescription(`Willst du wirklich <@${target.id}> einen **Dishonor** geben?\r\n[Grund: ${reason}]`)
|
||||
.addFields({
|
||||
name: 'Current Honor Level', value: `${theirHonorLevel?.honors ?? 0} (**-1**)`
|
||||
})
|
||||
.setThumbnail(target.displayAvatarURL())
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel('✔')
|
||||
.setCustomId('honor_multi_confirm')
|
||||
.setStyle(ButtonStyle.Success)
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel('✖')
|
||||
.setCustomId('abort')
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
)
|
||||
await interaction.reply({
|
||||
embeds: [embed],
|
||||
components: [row],
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js")
|
||||
const { mClient } = require("../..")
|
||||
require('dotenv').config()
|
||||
|
||||
module.exports = {
|
||||
name: 'honor_menu_history',
|
||||
description: 'show selected user honor history',
|
||||
async execute(interaction) {
|
||||
let description = interaction.message.embeds[0].data.description
|
||||
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const reasonsColl = db.collection('honor-reasons')
|
||||
const history = await reasonsColl.findOne({ userID: target.user.id })
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('- Honor History -')
|
||||
.setDescription(`${target} - ${target.user.globalName ?? target.user.username}`)
|
||||
.setThumbnail(target.displayAvatarURL())
|
||||
.setFooter({text: 'Um zurückzukehren, wähle einen Nutzer!'})
|
||||
if(history){
|
||||
let temp = ''
|
||||
history.reasons.forEach(reason => {
|
||||
temp += reason + '\r\n'
|
||||
})
|
||||
embed.setDescription(temp)
|
||||
}
|
||||
const select = await interaction.message.components[0]
|
||||
const row = await interaction.message.components[1]
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [embed],
|
||||
components: [select, row],
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
const { EmbedBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle } = require("discord.js")
|
||||
const { mClient } = require("../..")
|
||||
require('dotenv').config()
|
||||
|
||||
module.exports = {
|
||||
name: 'honor_menu_honor',
|
||||
description: 'honor menu honor button',
|
||||
async execute(interaction) {
|
||||
let description = interaction.message.embeds[0].data.description
|
||||
const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1))
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const honorsColl = db.collection('honors')
|
||||
const reason = `[+] Quick Menu Honor`
|
||||
const theirHonorLevel = await honorsColl.findOne({ userID: target.id })
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('- Honor Up! -')
|
||||
.setDescription(`Willst du wirklich <@${target.id}> einen **Honor** geben?\r\n[Grund: ${reason}]`)
|
||||
.addFields({
|
||||
name: 'Current Honor Level', value: `${theirHonorLevel?.honors ?? 0} (**+1**)`
|
||||
})
|
||||
.setThumbnail(target.displayAvatarURL())
|
||||
//.setFooter('Honor Level updaten sich nicht automatisch!')
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel('✔')
|
||||
.setCustomId('honor_multi_confirm')
|
||||
.setStyle(ButtonStyle.Success)
|
||||
)
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel('✖')
|
||||
.setCustomId('abort')
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
)
|
||||
await interaction.reply({
|
||||
embeds: [embed],
|
||||
components: [row],
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
const { EmbedBuilder } = require("discord.js")
|
||||
const { mClient } = require("../..")
|
||||
require('dotenv').config()
|
||||
|
||||
module.exports = {
|
||||
name: 'honor_multi_confirm',
|
||||
description: 'confirm it',
|
||||
async execute(interaction) {
|
||||
let temp = await interaction.message.embeds[0].description.split(' ')
|
||||
var honor
|
||||
if (temp[5].slice(2, -2) == 'Honor') {
|
||||
honor = 1
|
||||
} else {
|
||||
honor = -1
|
||||
}
|
||||
const target = await interaction.message.guild.members.fetch(temp[3].slice(2, -1))
|
||||
temp = interaction.message.embeds[0].description.split('\r\n')
|
||||
const reason = `${temp[1].slice(7, -1)}`
|
||||
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const honorsColl = db.collection('honors')
|
||||
const reasonsColl = db.collection('honor-reasons')
|
||||
const theirHonorLevel = await honorsColl.findOne({ userID: target.id })
|
||||
|
||||
await honorsColl.findOneAndUpdate({ userID: target.id }, { $inc: { honors: honor } }, { upsert: true })
|
||||
await reasonsColl.findOneAndUpdate({ userID: target.id }, { $push: { reasons: reason } }, { upsert: true })
|
||||
|
||||
var description
|
||||
var newTitle
|
||||
var newDescription
|
||||
var newThumbnail
|
||||
|
||||
if (honor == 1) {
|
||||
description = `Willst du wirklich <@${target.id}> einen Honor geben?\r\n[Grund: ${reason}]`
|
||||
newTitle = 'Honor Up!'
|
||||
newDescription = `<@${target.id}> erhält einen Honor!\r\n[Grund: ${reason}]`
|
||||
newThumbnail = "https://cdn.discordapp.com/emojis/748176295535443968.webp"
|
||||
} else {
|
||||
description = `Willst du wirklich <@${target.id}> einen Dishonor geben?\r\n[Grund: ${reason}]`
|
||||
newTitle = 'Honor Down!'
|
||||
newDescription = `<@${target.id}> erhält einen Dishonor!\r\n[Grund: ${reason}]`
|
||||
newThumbnail = "https://cdn.discordapp.com/emojis/748176295132790786.webp"
|
||||
}
|
||||
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('- Honor Menu -')
|
||||
.setDescription(description)
|
||||
.addFields({
|
||||
name: 'Current Honor Level', value: `${theirHonorLevel?.honors ?? 0} ${honor == 1 ? '(**+1**)' : '(**-1**)'}`
|
||||
})
|
||||
.setThumbnail(target.displayAvatarURL())
|
||||
await interaction.update({
|
||||
embeds: [embed]
|
||||
})
|
||||
|
||||
const newEmbed = new EmbedBuilder()
|
||||
.setTitle(newTitle)
|
||||
.setDescription(newDescription)
|
||||
.setThumbnail(newThumbnail)
|
||||
await interaction.followUp({
|
||||
embeds: [newEmbed],
|
||||
components: [],
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
const { EmbedBuilder } = require("discord.js")
|
||||
const { mClient } = require("../..")
|
||||
require('dotenv').config()
|
||||
|
||||
module.exports = {
|
||||
name: 'honors_leaderboard_left',
|
||||
description: 'navigate a page up',
|
||||
async execute(interaction) {
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const honorsColl = db.collection('honors')
|
||||
const min = 0
|
||||
let skip = interaction.message.embeds[0].data.description.split('.')
|
||||
skip = Number(skip[0]) - 6
|
||||
skip = skip - ( skip % 5)
|
||||
if ( skip < 4){
|
||||
skip = 0
|
||||
}
|
||||
const honorsData = await honorsColl.find().sort({ honors: -1 }).skip(skip).limit(5).toArray()
|
||||
let fields
|
||||
honorsData.forEach((data) => {
|
||||
skip++
|
||||
fields = (fields ? fields : '') + (`${skip}. <@${data.userID}> : ${data.honors} Honors\r\n`)
|
||||
})
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Honors Leaderboard')
|
||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||
.setDescription(fields.toString());
|
||||
await interaction.update({
|
||||
embeds: [embed],
|
||||
components: [interaction.message.components[0]]
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
const { EmbedBuilder } = require("discord.js")
|
||||
const { mClient } = require("../..")
|
||||
require('dotenv').config()
|
||||
module.exports = {
|
||||
name: 'honors_leaderboard_right',
|
||||
description: 'navigate a page down',
|
||||
async execute(interaction) {
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const honorsColl = db.collection('honors')
|
||||
const max = await honorsColl.countDocuments()
|
||||
let skip = interaction.message.embeds[0].data.description.split('.')
|
||||
skip = Number(skip[0]) +4
|
||||
if (skip >= (max - (max % 5))) {
|
||||
skip = max - (max % 5)
|
||||
}
|
||||
const honorsData = await honorsColl.find().sort({ honors: -1 }).skip(skip).limit(5).toArray()
|
||||
let fields
|
||||
honorsData.forEach((data) => {
|
||||
skip++
|
||||
fields = (fields ? fields : '') + (`${skip}. <@${data.userID}> : ${data.honors} Honors\r\n`)
|
||||
})
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Honors Leaderboard')
|
||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||
.setDescription(fields.toString());
|
||||
await interaction.update({
|
||||
embeds: [embed],
|
||||
components: [interaction.message.components[0]]
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
const { EmbedBuilder } = require("discord.js")
|
||||
const { mClient } = require("../..")
|
||||
require('dotenv').config()
|
||||
module.exports = {
|
||||
name: 'honors_leaderboard_self',
|
||||
description: 'navigate to your own placement',
|
||||
async execute(interaction) {
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const honorsColl = db.collection('honors')
|
||||
|
||||
const self = await honorsColl.find({ userID: interaction.user.id }).toArray()
|
||||
const all = await honorsColl.find().sort({ honors: -1 }).toArray()
|
||||
|
||||
function findIndex(){
|
||||
let index = 0
|
||||
for (let i = 0; i < all.length; i++) {
|
||||
index++
|
||||
if (all[i].honors === self[0].honors) {
|
||||
return index
|
||||
}
|
||||
}
|
||||
}
|
||||
let selfIndex = findIndex()
|
||||
let skip = selfIndex - ( selfIndex % 5)
|
||||
|
||||
const honorsData = await honorsColl.find().sort({ honors: -1 }).skip(skip).limit(5).toArray()
|
||||
let fields
|
||||
honorsData.forEach((data) => {
|
||||
skip++
|
||||
fields = (fields ? fields : '') + (`${skip}. <@${data.userID}> : ${data.honors} Honors\r\n`)
|
||||
})
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Honors Leaderboard')
|
||||
.setThumbnail('https://cdn.discordapp.com/attachments/1152723542836772914/1152940755539722240/pngwing.com.png')
|
||||
.setDescription(fields.toString());
|
||||
await interaction.update({
|
||||
embeds: [embed],
|
||||
components: [interaction.message.components[0]]
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user