mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
Немного переделал giveaway, должно быть удобнее в пользовании
This commit is contained in:
parent
38c4ac94c9
commit
26205d1416
2 changed files with 26 additions and 12 deletions
|
@ -17,7 +17,7 @@ class Giveaway extends BaseCommand {
|
||||||
.setDescription(client.translate("moderation/giveaway:GIVEAWAY_ID")))
|
.setDescription(client.translate("moderation/giveaway:GIVEAWAY_ID")))
|
||||||
.addStringOption(option => option.setName("duration")
|
.addStringOption(option => option.setName("duration")
|
||||||
.setDescription(client.translate("common:DURATION")))
|
.setDescription(client.translate("common:DURATION")))
|
||||||
.addStringOption(option => option.setName("winners_count")
|
.addIntegerOption(option => option.setName("winners_count")
|
||||||
.setDescription(client.translate("moderation/giveaway:WINNERS_COUNT")))
|
.setDescription(client.translate("moderation/giveaway:WINNERS_COUNT")))
|
||||||
.addStringOption(option => option.setName("prize")
|
.addStringOption(option => option.setName("prize")
|
||||||
.setDescription(client.translate("moderation/giveaway:PRIZE")))
|
.setDescription(client.translate("moderation/giveaway:PRIZE")))
|
||||||
|
@ -42,19 +42,29 @@ class Giveaway extends BaseCommand {
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
async execute(client, interaction) {
|
async execute(client, interaction) {
|
||||||
const options = ["create", "reroll", "delete", "end"].map(tag =>
|
|
||||||
JSON.parse(JSON.stringify({
|
|
||||||
label: tag,
|
|
||||||
value: tag
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
|
|
||||||
const row = new ActionRowBuilder()
|
const row = new ActionRowBuilder()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new SelectMenuBuilder()
|
new SelectMenuBuilder()
|
||||||
.setCustomId("giveaway_select")
|
.setCustomId("giveaway_select")
|
||||||
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
|
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
|
||||||
.addOptions(options)
|
.addOptions([
|
||||||
|
{
|
||||||
|
label: interaction.translate("moderation/giveaway:CREATE"),
|
||||||
|
value: "create"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: interaction.translate("moderation/giveaway:REROLL"),
|
||||||
|
value: "reroll"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: interaction.translate("moderation/giveaway:DELETE"),
|
||||||
|
value: "delete"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: interaction.translate("moderation/giveaway:END"),
|
||||||
|
value: "end"
|
||||||
|
}
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
const msg = await interaction.reply({
|
const msg = await interaction.reply({
|
||||||
|
@ -83,13 +93,13 @@ class Giveaway extends BaseCommand {
|
||||||
if (!duration) return i.update({ content: interaction.translate("moderation/giveaway:INVALID_CREATE") });
|
if (!duration) return i.update({ content: interaction.translate("moderation/giveaway:INVALID_CREATE") });
|
||||||
if (ms(duration) > ms("10d")) return i.update({ content: interaction.translate("moderation/giveaway:MAX_DURATION") });
|
if (ms(duration) > ms("10d")) return i.update({ content: interaction.translate("moderation/giveaway:MAX_DURATION") });
|
||||||
|
|
||||||
const winnersCount = interaction.options.getString("winners_count");
|
const winnersCount = interaction.options.getInteger("winners_count");
|
||||||
if (!winnersCount) return i.update({ content: interaction.translate("moderation/giveaway:INVALID_CREATE") });
|
if (!winnersCount) return i.update({ content: interaction.translate("moderation/giveaway:INVALID_CREATE") });
|
||||||
if (isNaN(winnersCount) || winnersCount > 10 || winnersCount < 1) return i.update({ content: interaction.translate("misc:INVALID_NUMBER_RANGE", { min: 1, max: 10 }) });
|
if (winnersCount > 10 || winnersCount < 1) return i.update({ content: interaction.translate("misc:INVALID_NUMBER_RANGE", { min: 1, max: 10 }) });
|
||||||
|
|
||||||
const prize = interaction.options.getString("prize");
|
const prize = interaction.options.getString("prize");
|
||||||
if (!prize) return i.update({ content: interaction.translate("moderation/giveaway:INVALID_CREATE") });
|
if (!prize) return i.update({ content: interaction.translate("moderation/giveaway:INVALID_CREATE") });
|
||||||
const isdrop = interaction.options.getString("isdrop");
|
const isdrop = interaction.options.getBoolean("isdrop");
|
||||||
|
|
||||||
client.giveawaysManager.start(interaction.channel, {
|
client.giveawaysManager.start(interaction.channel, {
|
||||||
duration: ms(duration),
|
duration: ms(duration),
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
"DESCRIPTION": "Управление раздачами",
|
"DESCRIPTION": "Управление раздачами",
|
||||||
"USAGE": "[create/reroll/delete/end] [время] [кол-во победителей] [приз] (Дроп?)",
|
"USAGE": "[create/reroll/delete/end] [время] [кол-во победителей] [приз] (Дроп?)",
|
||||||
"EXAMPLES": "giveaway create 1d 2 Discord Нитро!\ngiveaway create 1d 2 true Discord Нитро\ngiveaway reroll 597812898022031374",
|
"EXAMPLES": "giveaway create 1d 2 Discord Нитро!\ngiveaway create 1d 2 true Discord Нитро\ngiveaway reroll 597812898022031374",
|
||||||
|
"CREATE": "Создать",
|
||||||
|
"REROLL": "Заролить снова",
|
||||||
|
"DELETE": "Удалить",
|
||||||
|
"END": "Закончить принудительно",
|
||||||
"INVALID_CREATE": "Какой-то из аргументов указан неверно, попробуйте снова!",
|
"INVALID_CREATE": "Какой-то из аргументов указан неверно, попробуйте снова!",
|
||||||
"GIVEAWAY_ID": "ID сообщения раздачи",
|
"GIVEAWAY_ID": "ID сообщения раздачи",
|
||||||
"WINNERS_COUNT": "Количество победителей",
|
"WINNERS_COUNT": "Количество победителей",
|
||||||
|
|
Loading…
Reference in a new issue