Add give command #137

Merged
Vylpes merged 3 commits from feature/113-give-command into develop 2024-01-12 17:51:30 +00:00
3 changed files with 13 additions and 13 deletions
Showing only changes of commit daaa55cd72 - Show all commits

View file

@ -23,7 +23,7 @@ const requiredConfigs: string[] = [
"DB_SYNC", "DB_SYNC",
"DB_LOGGING", "DB_LOGGING",
"EXPRESS_PORT", "EXPRESS_PORT",
] ];
requiredConfigs.forEach(config => { requiredConfigs.forEach(config => {
if (!process.env[config]) { if (!process.env[config]) {

View file

@ -10,41 +10,41 @@ export default class Give extends Command {
super(); super();
this.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('give') .setName("give")
.setDescription('Give a user a card manually, in case bot breaks') .setDescription("Give a user a card manually, in case bot breaks")
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator) .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator)
.addStringOption(x => .addStringOption(x =>
x x
.setName('cardnumber') .setName("cardnumber")
.setDescription('G') .setDescription("G")
.setRequired(true)) .setRequired(true))
.addUserOption(x => .addUserOption(x =>
x x
.setName('user') .setName("user")
.setDescription("The user to give the card to") .setDescription("The user to give the card to")
.setRequired(true)); .setRequired(true));
} }
public override async execute(interaction: CommandInteraction<CacheType>) { public override async execute(interaction: CommandInteraction<CacheType>) {
if (!CoreClient.AllowDrops) { if (!CoreClient.AllowDrops) {
await interaction.reply('Bot is currently syncing, please wait until its done.'); await interaction.reply("Bot is currently syncing, please wait until its done.");
return; return;
} }
if (await Config.GetValue('safemode') == "true") { if (await Config.GetValue("safemode") == "true") {
await interaction.reply('Safe Mode has been activated, please resync to continue.'); await interaction.reply("Safe Mode has been activated, please resync to continue.");
return; return;
} }
const whitelistedUsers = process.env.BOT_ADMINS!.split(','); const whitelistedUsers = process.env.BOT_ADMINS!.split(",");
if (!whitelistedUsers.find(x => x == interaction.user.id)) { if (!whitelistedUsers.find(x => x == interaction.user.id)) {
await interaction.reply("Only whitelisted users can use this command."); await interaction.reply("Only whitelisted users can use this command.");
return; return;
} }
const cardNumber = interaction.options.get('cardnumber', true); const cardNumber = interaction.options.get("cardnumber", true);
const user = interaction.options.getUser('user', true); const user = interaction.options.getUser("user", true);
const card = CardDropHelperMetadata.GetCardByCardNumber(cardNumber.value!.toString()); const card = CardDropHelperMetadata.GetCardByCardNumber(cardNumber.value!.toString());

View file

@ -55,7 +55,7 @@ export default class CardDropHelperMetadata {
return card; return card;
} }
public static GenerateDropEmbed(drop: DropResult, quantityClaimed: Number, imageFileName: string): EmbedBuilder { public static GenerateDropEmbed(drop: DropResult, quantityClaimed: number, imageFileName: string): EmbedBuilder {
let description = ""; let description = "";
description += `Series: ${drop.series.name}\n`; description += `Series: ${drop.series.name}\n`;
description += `Claimed: ${quantityClaimed}\n`; description += `Claimed: ${quantityClaimed}\n`;