52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
const { SlashCommandBuilder } = require('@discordjs/builders');
|
|
const { Permissions } = require('discord.js');
|
|
|
|
const db = require('quick.db');
|
|
|
|
const credits = new db.table('credits');
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('give')
|
|
.setDescription('Give a user credits (ADMIN).')
|
|
.addUserOption((option) =>
|
|
option.setName('user').setDescription('The user you want to pay.').setRequired(true)
|
|
)
|
|
.addIntegerOption((option) =>
|
|
option.setName('amount').setDescription('The amount you will pay.').setRequired(true)
|
|
),
|
|
async execute(interaction) {
|
|
await interaction.deferReply({ ephemeral: true });
|
|
if (!interaction.member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
|
|
const embed = {
|
|
title: 'Give failed',
|
|
description: 'You need to have permission to manage this guild (MANAGE_GUILD)',
|
|
};
|
|
return await interaction.editReply({ embeds: [embed], ephemeral: true });
|
|
}
|
|
const user = await interaction.options.getUser('user');
|
|
const amount = await interaction.options.getInteger('amount');
|
|
|
|
if (amount <= 0) {
|
|
const embed = {
|
|
title: 'Give',
|
|
description: "You can't give zero or below.",
|
|
color: 0xbb2124,
|
|
timestamp: new Date(),
|
|
footer: { text: 'Zyner Bot' },
|
|
};
|
|
return await interaction.editReply({ embeds: [embed], ephemeral: true });
|
|
} else {
|
|
await credits.add(user.id, amount);
|
|
|
|
const embed = {
|
|
title: 'Give',
|
|
description: `Gave ${amount <= 1 ? `${amount} credit` : `${amount} credits`} to ${user}.`,
|
|
color: 0x22bb33,
|
|
timestamp: new Date(),
|
|
footer: { text: 'Zyner Bot' },
|
|
};
|
|
return await interaction.editReply({ embeds: [embed], ephemeral: true });
|
|
}
|
|
},
|
|
};
|