-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2.3.5: Privacy updates and bug fixes
- Loading branch information
reishimanfr
committed
May 6, 2024
1 parent
ef11793
commit ca2ceb6
Showing
9 changed files
with
191 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, SlashCommandBuilder } from 'discord.js' | ||
import type { Command } from '../../Types/Command' | ||
import { playlists } from '../../Models' | ||
import { logger } from '../../Helpers/Logger' | ||
|
||
const deleteMyData: Command<false> = { | ||
data: new SlashCommandBuilder() | ||
.setName('delete-my-data') | ||
.setDescription('Deletes everything from the database related to you.'), | ||
|
||
permissions: {}, | ||
|
||
callback: async ({ interaction }) => { | ||
const confirmationMessage = await interaction.reply({ | ||
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.', | ||
ephemeral: true, | ||
components: [ | ||
new ActionRowBuilder<ButtonBuilder>() | ||
.addComponents( | ||
new ButtonBuilder() | ||
.setCustomId('yes') | ||
.setEmoji('✅') | ||
.setLabel('Yes, I\'m 100% sure.') | ||
.setStyle(ButtonStyle.Secondary), | ||
|
||
new ButtonBuilder() | ||
.setCustomId('no') | ||
.setEmoji('❌') | ||
.setLabel('No, I\'ve changed my mind.') | ||
.setStyle(ButtonStyle.Secondary), | ||
) | ||
] | ||
}) | ||
|
||
const optionCollector = await confirmationMessage.awaitMessageComponent({ | ||
componentType: ComponentType.Button, | ||
idle: 120000 | ||
}) | ||
|
||
if (!optionCollector) { | ||
return interaction.editReply({ | ||
components: [], | ||
content: 'Command timed out. Your data will not be deleted.' | ||
}) | ||
} | ||
|
||
if (optionCollector.customId === 'no') { | ||
return interaction.editReply({ | ||
components: [], | ||
content: 'Cancelling data deletion.' | ||
}) | ||
} | ||
|
||
const toDelete = [playlists] // Array in case we want to add something here | ||
|
||
for (const part of toDelete) { | ||
try { | ||
await part.destroy({ where: { userId: interaction.user.id } }) | ||
} catch (error) { | ||
logger.error(`Failed to delete user data for ${interaction.user.id}: ${error.stack}`) | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default deleteMyData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Button } from '../../../Types/Button' | ||
|
||
const queue: Button = { | ||
name: 'queue', | ||
musicOptions: {}, | ||
run: async ({ interaction, player}) => { | ||
if (!player.queue.length) { | ||
return interaction.reply({ | ||
content: 'The queue is empty.', | ||
ephemeral: true | ||
}) | ||
} | ||
|
||
const embed = player.queueManager.createQueueEmbed()[0] | ||
const description = `${embed.data.description}\n:warning: For full list of songs use the \`/queue\` command.` | ||
|
||
await interaction.reply({ | ||
embeds: [embed.setDescription(description)], | ||
ephemeral: true | ||
}) | ||
} | ||
} | ||
|
||
export default queue |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Delete everything related to the guild from which we got kicked out of | ||
import { Events, type Guild } from 'discord.js' | ||
import type { Event } from '../../Types/Event'; | ||
import { PlayerSettings, SponsorBlockDb, serverStats, starboardConfig, starboardEntries } from '../../Models' | ||
import { logger } from '../../Helpers/Logger' | ||
|
||
const GuildDelete: Event = { | ||
name: Events.GuildDelete, | ||
once: false, | ||
|
||
execute: async (guild: Guild) => { | ||
logger.warn(`Deleting database entries for guild "${guild.name}" (${guild.id})`) | ||
|
||
const classes = [PlayerSettings, serverStats, SponsorBlockDb, starboardConfig, starboardEntries] | ||
|
||
for (const part of classes) { | ||
try { | ||
await part.destroy({ where: { guildId: guild.id } }) | ||
} catch (error) { | ||
logger.error(`Failed to delete database entry after leaving server ${guild.name} (${guild.id}): ${error.stack}`) | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default GuildDelete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Events } from 'discord.js' | ||
import type { Event } from '../../Types/Event'; | ||
import { logger } from '../../Helpers/Logger' | ||
|
||
const Warn: Event = { | ||
name: Events.Warn, | ||
once: false, | ||
|
||
execute: (info: string) => { | ||
logger.warn(`Discord.js warning: ${info}`) | ||
} | ||
} | ||
|
||
export default Warn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters