mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-01-18 16:37:40 +01:00
first commit
This commit is contained in:
42
commands.js
42
commands.js
@@ -1,5 +1,5 @@
|
||||
import 'dotenv/config';
|
||||
import { getRPSChoices } from './game.js';
|
||||
import { getRPSChoices, getTimesChoices } from './game.js';
|
||||
import { capitalize, InstallGlobalCommands } from './utils.js';
|
||||
|
||||
// Get the game choices from game.js
|
||||
@@ -17,6 +17,20 @@ function createCommandChoices() {
|
||||
return commandChoices;
|
||||
}
|
||||
|
||||
function createTimesChoices() {
|
||||
const choices = getTimesChoices();
|
||||
const commandChoices = [];
|
||||
|
||||
for (let choice of choices) {
|
||||
commandChoices.push({
|
||||
name: capitalize(choice.name),
|
||||
value: choice.value.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
return commandChoices;
|
||||
}
|
||||
|
||||
// Simple test command
|
||||
const TEST_COMMAND = {
|
||||
name: 'test',
|
||||
@@ -44,6 +58,30 @@ const CHALLENGE_COMMAND = {
|
||||
contexts: [0, 2],
|
||||
};
|
||||
|
||||
const ALL_COMMANDS = [TEST_COMMAND, CHALLENGE_COMMAND];
|
||||
// Timeout vote command
|
||||
const TIMEOUT_COMMAND = {
|
||||
name: 'timeout',
|
||||
description: 'Vote démocratique pour time out un boug',
|
||||
options: [
|
||||
{
|
||||
type: 6,
|
||||
name: 'akhy',
|
||||
description: 'Qui ?',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
type: 3,
|
||||
name: 'temps',
|
||||
description: 'Combien de temps ?',
|
||||
required: true,
|
||||
choices: createTimesChoices(),
|
||||
}
|
||||
],
|
||||
type: 1,
|
||||
integration_types: [0, 1],
|
||||
contexts: [0, 2],
|
||||
}
|
||||
|
||||
const ALL_COMMANDS = [/*TEST_COMMAND, CHALLENGE_COMMAND, */TIMEOUT_COMMAND];
|
||||
|
||||
InstallGlobalCommands(process.env.APP_ID, ALL_COMMANDS);
|
||||
|
||||
Reference in New Issue
Block a user