initial music stuff

This commit is contained in:
ReaperOfVeriod
2026-01-31 02:50:20 +01:00
parent e262300def
commit f00cbb2091
9 changed files with 535 additions and 35 deletions
+32 -32
View File
@@ -1,34 +1,38 @@
const { Events, MessageFlags, Collection, GuildMember, PermissionsBitField } = require('discord.js');
const { Events, MessageFlags, Collection } = require('discord.js');
async function safeReply(interaction, content) {
if (interaction.replied || interaction.deferred) {
await interaction.editReply(content).catch(() => {
interaction.followUp({ content, flags: MessageFlags.Ephemeral }).catch(console.error);
});
} else {
await interaction.reply({ content, flags: MessageFlags.Ephemeral }).catch(console.error);
}
}
module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
if (interaction.isChatInputCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
if (!command) return console.error(`No command matching ${interaction.commandName} found.`);
const { cooldowns } = interaction.client;
if (!cooldowns.has(command.data.name)) {
cooldowns.set(command.data.name, new Collection());
}
if (!cooldowns.has(command.data.name)) cooldowns.set(command.data.name, new Collection());
const now = Date.now();
const timestamps = cooldowns.get(command.data.name);
const defaultCooldownDuration = 3;
const cooldownAmount = (command.cooldown ?? defaultCooldownDuration) * 1000;
const defaultCooldown = 3;
const cooldownAmount = (command.cooldown ?? defaultCooldown) * 1000;
if (timestamps.has(interaction.user.id)) {
const expirationTime = timestamps.get(interaction.user.id) + cooldownAmount;
if (now < expirationTime) {
const expiredTimestamp = Math.round(expirationTime / 1000);
return interaction.reply({ content: `Please wait, you are on a cooldown for \`${command.data.name}\`. You can use it again <t:${expiredTimestamp}:R>.`, flags: MessageFlags.Ephemeral });
const expired = Math.round(expirationTime / 1000);
return interaction.reply({
content: `Please wait, you are on cooldown for \`${command.data.name}\`. Try again <t:${expired}:R>.`,
flags: MessageFlags.Ephemeral,
});
}
}
@@ -39,43 +43,39 @@ module.exports = {
await command.execute(interaction);
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
} else {
await interaction.reply({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
}
await safeReply(interaction, '❌ There was an error while executing this command!');
}
} else if (interaction.isButton()) {
if (interaction.customId === 'acceptnotifications') {
const notifiRoleId = "1401849479149391882";
const notifiRoleId = '1401849479149391882';
try {
if (interaction.member.roles.cache.has(notifiRoleId)) {
await interaction.reply({ content: 'you already have the notification role!', flags: MessageFlags.Ephemeral });
await interaction.reply({ content: 'You already have the notification role!', flags: MessageFlags.Ephemeral });
} else {
await interaction.member.roles.add(notifiRoleId);
await interaction.reply({ content: 'Thank you hope to see you soon in my streams!', flags: MessageFlags.Ephemeral });
await interaction.reply({ content: 'Thank you! Hope to see you soon in my streams!', flags: MessageFlags.Ephemeral });
}
} catch (error) {
await interaction.reply({ content: 'something went wrong', flags: MessageFlags.Ephemeral });
console.log(error);
console.error(error);
await interaction.reply({ content: 'Something went wrong', flags: MessageFlags.Ephemeral });
}
}
if (interaction.customId === 'acceptrules') {
const viewerRoleId = "1401153107601395774";
const viewerRoleId = '1401153107601395774';
try {
if (interaction.member.roles.cache.has(viewerRoleId)) {
await interaction.reply({ content: 'you already have accepted the rules!', flags: MessageFlags.Ephemeral });
await interaction.reply({ content: 'You already accepted the rules!', flags: MessageFlags.Ephemeral });
} else {
await interaction.member.roles.add(viewerRoleId);
await interaction.reply({ content: 'Thank you for accepting the rules!', flags: MessageFlags.Ephemeral });
}
} catch (error) {
await interaction.reply({ content: 'something went wrong', flags: MessageFlags.Ephemeral });
console.log(error);
console.error(error);
await interaction.reply({ content: 'Something went wrong', flags: MessageFlags.Ephemeral });
}
}
} else if (interaction.isStringSelectMenu()) {
// respond to the select menu
// handle select menu
}
},
};
};