Skip to content

Commit ca2ceb6

Browse files
author
reishimanfr
committed
v2.3.5: Privacy updates and bug fixes
1 parent ef11793 commit ca2ceb6

9 files changed

Lines changed: 191 additions & 79 deletions

File tree

src/Commands/config/player-config.ts

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -62,66 +62,65 @@ const player_config: Command = {
6262
.setCustomId('options-select')
6363
.setOptions(
6464
{
65-
label: 'View config',
66-
description: 'Shows the current configuration of the player.',
67-
value: 'showConfig',
68-
emoji: '⚙️'
65+
label: "Config",
66+
description: "Display current player settings.",
67+
value: "showConfig",
68+
emoji: "⚙️"
6969
},
7070
{
71-
label: 'Sponsorblock auto skipping',
72-
description: 'Configures skipping sponsored segments automatically with sponsorblock.',
73-
value: 'sponsorBlockConfig',
74-
emoji: '⏭'
71+
label: "Sponsor Skip",
72+
description: "Automatically skip sponsored segments with Sponsorblock.",
73+
value: "sponsorBlockConfig",
74+
emoji: "⏭"
7575
},
7676
{
77-
label: 'Leave on queue end',
78-
description: 'Toggles if the bot should leave after a queue ends.',
79-
value: 'queueEndDisconnect',
80-
emoji: '👋'
77+
label: "Auto-Leave",
78+
description: "Automatically leave after queue ends.",
79+
value: "queueEndDisconnect",
80+
emoji: "👋"
8181
},
8282
{
83-
label: 'Vote skipping',
84-
description: 'Toggles if skipping a song requires users to vote to skip.',
85-
value: 'voteSkipToggle',
86-
emoji: '⏩'
83+
label: "Vote Skip",
84+
description: "Require votes to skip a song.",
85+
value: "voteSkipToggle",
86+
emoji: "⏩"
8787
},
8888
{
89-
label: 'Resend message after song end',
90-
description: 'Toggles if the bot should resend the now playing message on new track.',
91-
value: 'resendMessageOnEnd',
92-
emoji: '↪️'
89+
label: "Resend On End",
90+
description: "Resend the 'now playing' message for new tracks.",
91+
value: "resendMessageOnEnd",
92+
emoji: "↪️"
9393
},
9494
{
95-
label: 'Dynamic now playing message',
96-
description: 'Toggles if the bot should update the now playing message every 15s.',
97-
value: 'dynamicNowPlaying',
98-
emoji: '🔄'
95+
label: "Dynamic Now Playing",
96+
description: "Update 'now playing' message every 15s.",
97+
value: "dynamicNowPlaying",
98+
emoji: "🔄"
9999
},
100100
{
101-
label: 'Require DJ role',
102-
description: 'Toggles if members are required to have the DJ role to use commands.',
103-
value: 'requireDjRole',
104-
emoji: '❗'
101+
label: "DJ Role Required",
102+
description: "Members need DJ role to use commands.",
103+
value: "requireDjRole",
104+
emoji: "❗"
105105
},
106-
{
107-
label: 'DJ role',
108-
description: 'Sets the role to be considered the "DJ role".',
109-
value: 'djRoleId',
110-
emoji: '✨'
106+
{
107+
label: "Set DJ Role",
108+
description: "Define the DJ role.",
109+
value: "djRoleId",
110+
emoji: "✨"
111111
},
112-
{
113-
label: 'Vote skipping member amount',
114-
description: 'Sets how many members must be in voice channel for voting to be enabled.',
115-
value: 'voteSkipMembers',
116-
emoji: '🔢'
112+
{
113+
label: "Vote Skip Members",
114+
description: "Number of members needed to enable voting.",
115+
value: "voteSkipMembers",
116+
emoji: "🔢"
117117
},
118118
{
119-
label: 'Vote skipping threshold (%)',
120-
description: 'Sets the % of members required to vote "yes" to skip a song.',
121-
value: 'setVoteSkipThreshold',
122-
emoji: '🔢'
123-
}
124-
)
119+
label: "Vote Skip Threshold",
120+
description: "Percentage of 'yes' votes required to skip a song.",
121+
value: "setVoteSkipThreshold",
122+
emoji: "🔢"
123+
})
125124
)
126125

127126
const res = await interaction.reply({
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, SlashCommandBuilder } from 'discord.js'
2+
import type { Command } from '../../Types/Command'
3+
import { playlists } from '../../Models'
4+
import { logger } from '../../Helpers/Logger'
5+
6+
const deleteMyData: Command<false> = {
7+
data: new SlashCommandBuilder()
8+
.setName('delete-my-data')
9+
.setDescription('Deletes everything from the database related to you.'),
10+
11+
permissions: {},
12+
13+
callback: async ({ interaction }) => {
14+
const confirmationMessage = await interaction.reply({
15+
content: 'Are you absolutely sure you want to delete everything in the database related to you?\n:warning: **This will also delete any playlists you created/imported.**\nServer specific music player settings won\'t be changed in any way.',
16+
ephemeral: true,
17+
components: [
18+
new ActionRowBuilder<ButtonBuilder>()
19+
.addComponents(
20+
new ButtonBuilder()
21+
.setCustomId('yes')
22+
.setEmoji('✅')
23+
.setLabel('Yes, I\'m 100% sure.')
24+
.setStyle(ButtonStyle.Secondary),
25+
26+
new ButtonBuilder()
27+
.setCustomId('no')
28+
.setEmoji('❌')
29+
.setLabel('No, I\'ve changed my mind.')
30+
.setStyle(ButtonStyle.Secondary),
31+
)
32+
]
33+
})
34+
35+
const optionCollector = await confirmationMessage.awaitMessageComponent({
36+
componentType: ComponentType.Button,
37+
idle: 120000
38+
})
39+
40+
if (!optionCollector) {
41+
return interaction.editReply({
42+
components: [],
43+
content: 'Command timed out. Your data will not be deleted.'
44+
})
45+
}
46+
47+
if (optionCollector.customId === 'no') {
48+
return interaction.editReply({
49+
components: [],
50+
content: 'Cancelling data deletion.'
51+
})
52+
}
53+
54+
const toDelete = [playlists] // Array in case we want to add something here
55+
56+
for (const part of toDelete) {
57+
try {
58+
await part.destroy({ where: { userId: interaction.user.id } })
59+
} catch (error) {
60+
logger.error(`Failed to delete user data for ${interaction.user.id}: ${error.stack}`)
61+
}
62+
}
63+
}
64+
}
65+
66+
export default deleteMyData
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ const togglePlayback: Button = {
88
},
99

1010
run: async ({ interaction, player }) => {
11-
const member = await interaction.guild?.members.fetch(interaction.user.id)
12-
13-
if (!member?.voice.channel) {
14-
return interaction.reply({
15-
content: 'You must be in a voice channel to use this command.',
16-
ephemeral: true
17-
})
18-
}
19-
20-
await interaction.deferUpdate()
2111
player.pause(!player.isPaused)
2212
player.messageManger.updatePlayerMessage()
13+
14+
interaction.reply({
15+
content: player.isPaused ? 'Paused' : 'Resumed',
16+
ephemeral: true
17+
})
2318
}
2419
}
2520

src/Events/Bot/Buttons/queue.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { Button } from '../../../Types/Button'
2+
3+
const queue: Button = {
4+
name: 'queue',
5+
musicOptions: {},
6+
run: async ({ interaction, player}) => {
7+
if (!player.queue.length) {
8+
return interaction.reply({
9+
content: 'The queue is empty.',
10+
ephemeral: true
11+
})
12+
}
13+
14+
const embed = player.queueManager.createQueueEmbed()[0]
15+
const description = `${embed.data.description}\n:warning: For full list of songs use the \`/queue\` command.`
16+
17+
await interaction.reply({
18+
embeds: [embed.setDescription(description)],
19+
ephemeral: true
20+
})
21+
}
22+
}
23+
24+
export default queue

src/Events/Bot/Buttons/showQueue.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/Events/Bot/GuildDelete.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Delete everything related to the guild from which we got kicked out of
2+
import { Events, type Guild } from 'discord.js'
3+
import type { Event } from '../../Types/Event';
4+
import { PlayerSettings, SponsorBlockDb, serverStats, starboardConfig, starboardEntries } from '../../Models'
5+
import { logger } from '../../Helpers/Logger'
6+
7+
const GuildDelete: Event = {
8+
name: Events.GuildDelete,
9+
once: false,
10+
11+
execute: async (guild: Guild) => {
12+
logger.warn(`Deleting database entries for guild "${guild.name}" (${guild.id})`)
13+
14+
const classes = [PlayerSettings, serverStats, SponsorBlockDb, starboardConfig, starboardEntries]
15+
16+
for (const part of classes) {
17+
try {
18+
await part.destroy({ where: { guildId: guild.id } })
19+
} catch (error) {
20+
logger.error(`Failed to delete database entry after leaving server ${guild.name} (${guild.id}): ${error.stack}`)
21+
}
22+
}
23+
}
24+
}
25+
26+
export default GuildDelete

src/Events/Bot/Warn.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Events } from 'discord.js'
2+
import type { Event } from '../../Types/Event';
3+
import { logger } from '../../Helpers/Logger'
4+
5+
const Warn: Event = {
6+
name: Events.Warn,
7+
once: false,
8+
9+
execute: (info: string) => {
10+
logger.warn(`Discord.js warning: ${info}`)
11+
}
12+
}
13+
14+
export default Warn

src/Helpers/Logger.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
import chalk from "chalk"
22
import moment from 'moment'
3+
require('dotenv').config()
4+
5+
const logLevel = process.env.LOG_LEVEL
6+
7+
// 0 1 2 3 4 5
8+
const levelNames = ['trace', 'debug', 'info', 'warn', 'error', 'fatal']
9+
const level = levelNames.indexOf(logLevel)
310

411
class logger {
512
private shutUpAboutStaticClassesBiomeThanks() { }
613

714
// biome-ignore lint/suspicious/noExplicitAny: Leave me alone please
815
static trace(...items: any) {
16+
if (level > 0) return
917
const base = chalk.gray(`[${moment().format('hh:mm:ss.SSS')}]`)
1018
console.log(`${base} ${chalk.magenta('TRACE:')} ${items}`)
1119
}
1220

1321
// biome-ignore lint/suspicious/noExplicitAny: Leave me alone please
1422
static debug(...items: any) {
23+
if (level > 1) return
1524
const base = chalk.gray(`[${moment().format('hh:mm:ss.SSS')}]`)
1625
console.log(`${base} ${chalk.blue('DEBUG:')} ${items}`)
1726
}
1827

1928
// biome-ignore lint/suspicious/noExplicitAny: Leave me alone please
2029
static info(...items: any) {
30+
if (level > 2) return
2131
const base = chalk.gray(`[${moment().format('hh:mm:ss.SSS')}]`)
2232
console.log(`${base} ${chalk.greenBright('INFO:')} ${items}`)
2333
}
2434

2535
// biome-ignore lint/suspicious/noExplicitAny: Leave me alone please
2636
static warn(...items: any) {
37+
if (level > 3) return
2738
const base = chalk.gray(`[${moment().format('hh:mm:ss.SSS')}]`)
2839
console.log(`${base} ${chalk.yellowBright('WARN:')} ${items}`)
2940
}
3041

3142
// biome-ignore lint/suspicious/noExplicitAny: Leave me alone please
3243
static error(...items: any) {
44+
if (level > 4) return
3345
const base = chalk.gray(`[${moment().format('hh:mm:ss.SSS')}]`)
3446
console.log(`${base} ${chalk.redBright('ERROR:')} ${items}`)
3547
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,4 @@ cron.schedule('*/1 * * * *', () => {
113113
client.user.setPresence({
114114
activities: [{ name: activityName, type: activityType }]
115115
})
116-
})
116+
})

0 commit comments

Comments
 (0)