Skip to content

Commit

Permalink
Fix deploy command
Browse files Browse the repository at this point in the history
  • Loading branch information
KwikKill committed Sep 12, 2024
1 parent 6c4912c commit 207f8ab
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 148 deletions.
73 changes: 37 additions & 36 deletions commands/adminlol.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
//const { EmbedBuilder } = require('discord.js');
const { PermissionsBitField, ApplicationCommandOptionType } = require('discord.js');
const parse = require('node-html-parser');

module.exports = {
name: 'adminlol',
group: 'lol',
description: "admin league of legends related commands",
permission: "none",
permission: PermissionsBitField.Flags.ManageMessages,
owner: true,
serverid: ["513776796211085342"],
hidden: false,
options: [
{
name: 'update',
description: 'update all lol accounts',
type: 'SUB_COMMAND_GROUP',
type: ApplicationCommandOptionType.SubcommandGroup,
options: [
{
name: 'all',
description: 'update all lol accounts',
type: 'SUB_COMMAND',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'first',
description: 'first',
type: 'BOOLEAN',
type: ApplicationCommandOptionType.Boolean,
required: true
}
]
},
{
name: 'swain',
description: 'add swain main summoners to the database',
type: 'SUB_COMMAND'
type: ApplicationCommandOptionType.Subcommand,
},
{
name: 'add',
description: 'add more summoners to the database',
type: 'SUB_COMMAND'
type: ApplicationCommandOptionType.Subcommand,
},
{
name: 'transition',
description: 'transition to the new database',
type: 'SUB_COMMAND'
type: ApplicationCommandOptionType.Subcommand,
},
{
name: 'populate',
description: 'populate the database',
type: 'SUB_COMMAND',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'limit',
description: 'limit',
type: 'INTEGER',
type: ApplicationCommandOptionType.Integer,
required: true
},
{
name: 'account',
description: 'account',
type: 'BOOLEAN',
type: ApplicationCommandOptionType.Boolean,
required: true
}
]
Expand All @@ -66,71 +67,71 @@ module.exports = {
{
name: 'analyze',
description: 'analyze a game comp post launch',
type: 'SUB_COMMAND_GROUP',
type: ApplicationCommandOptionType.SubcommandGroup,
options: [
{
name: 'test',
description: 'update all lol accounts',
type: 'SUB_COMMAND',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'top',
description: 'allied TOP laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'jungle',
description: 'allied JUNGLE laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'mid',
description: 'allied MID laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'adc',
description: 'allied ADC laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'supp',
description: 'allied SUPPORT laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'entop',
description: 'enemy TOP laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'enjungle',
description: 'enemy JUNGLE laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'enmid',
description: 'enemy MID laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'enadc',
description: 'enemy ADC laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
},
{
name: 'ensupp',
description: 'enemy SUPPORT laner',
type: 'STRING',
type: ApplicationCommandOptionType.String,
autocomplete: true,
}
]
Expand All @@ -140,23 +141,23 @@ module.exports = {
{
name: 'add',
description: 'add a summoner to the database',
type: 'SUB_COMMAND_GROUP',
type: ApplicationCommandOptionType.SubcommandGroup,
options: [
{
name: 'summoner',
description: 'add a summoner to the database',
type: 'SUB_COMMAND',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'summonerid',
description: 'summoner id',
type: 'STRING',
type: ApplicationCommandOptionType.String,
required: true,
},
{
name: 'region',
description: 'region',
type: 'STRING',
type: ApplicationCommandOptionType.String,
required: true,
choices: [
{
Expand Down Expand Up @@ -208,32 +209,32 @@ module.exports = {
{
name: 'discordid',
description: 'discord id',
type: 'STRING',
type: ApplicationCommandOptionType.String,
required: true,
},
{
name: 'priority',
description: 'priority',
type: 'INTEGER',
type: ApplicationCommandOptionType.Integer,
required: true,
}
]
},
{
name: 'game',
description: 'add a game to the database',
type: 'SUB_COMMAND',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'gameid',
description: 'game id',
type: 'STRING',
type: ApplicationCommandOptionType.String,
required: true,
},
{
name: 'region',
description: 'region',
type: 'STRING',
type: ApplicationCommandOptionType.String,
required: true,
choices: [
{
Expand Down Expand Up @@ -285,7 +286,7 @@ module.exports = {
{
name: 'debug',
description: 'debug',
type: 'BOOLEAN',
type: ApplicationCommandOptionType.Boolean,
required: true
}
]
Expand All @@ -295,17 +296,17 @@ module.exports = {
{
name: 'status',
description: 'check the status of the bot',
type: 'SUB_COMMAND_GROUP',
type: ApplicationCommandOptionType.SubcommandGroup,
options: [
{
name: 'summarized',
description: 'summarized status',
type: 'SUB_COMMAND',
type: ApplicationCommandOptionType.Subcommand,
},
{
name: 'maintenance',
description: 'send a maintenance message',
type: 'SUB_COMMAND',
type: ApplicationCommandOptionType.Subcommand,
},
]
}
Expand Down
52 changes: 36 additions & 16 deletions commands/deploy.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
const { PermissionsBitField, ApplicationCommandOptionType } = require("discord.js");

module.exports = {
name: 'deploy',
group: 'moderation',
description: "Allow to redeploy commands and context menus.",
permission: "owner",
permission: PermissionsBitField.Flags.Administrator,
owner: true,
hidden: false,
place: "guild",
options: undefined,
options: [
{
name: "global",
description: "Deploy global commands",
type: ApplicationCommandOptionType.Boolean,
required: false
}
],
commande_channel: true,
serverid: ["513776796211085342", "890915473363980308", "962329252550807592"],
async run(message, client, interaction = undefined, mssg = true) {

let number;

if (interaction === undefined) {
number = await deploy(client, message.guild);
if (interaction !== undefined && interaction.options.getBoolean("global") === true) {

number = await deploy_global(client);

} else {
number = await deploy(client, interaction.guild);

if (interaction === undefined) {
number += await deploy(client, message.guild);
} else {
number += await deploy(client, interaction.guild);
}
}

if (interaction === undefined) {
Expand All @@ -42,7 +59,7 @@ async function auto_deploy(client) {
console.log("- auto-deploy for guild " + guild.id + " : " + number);
}
}
deploy_global(client);
return deploy_global(client);
}

async function deploy(client, guild) {
Expand All @@ -69,21 +86,21 @@ async function deploy(client, guild) {
name: item.name,
description: item.description,
options: item.options,
defaultMemberPermissions: item.permission === "none",
defaultMemberPermissions: item.permission,
});
} else {
if (item.options !== undefined) {
commands.push({
name: item.name,
description: item.description,
options: item.options,
defaultMemberPermissions: item.permission === "none",
defaultMemberPermissions: item.permission,
});
} else {
commands.push({
name: item.name,
description: item.description,
defaultMemberPermissions: item.permission === "none",
defaultMemberPermissions: item.permission,
});
}
}
Expand All @@ -95,13 +112,13 @@ async function deploy(client, guild) {
commands.push({
name: item.name,
type: item.type,
defaultMemberPermissions: item.permission === "none",
defaultMemberPermissions: item.permission,
});
}
});

await guild.commands.set(commands);
return commands.length.toString();
return commands.length;

/*
command.forEach((commande) => {
Expand Down Expand Up @@ -210,21 +227,24 @@ async function deploy_global(client) {
name: item.name,
description: item.description,
options: item.options,
defaultMemberPermissions: item.permission === "none",
defaultMemberPermissions: item.permission,
integration_types: item.integration_types || [0],
});
} else {
if (item.options !== undefined) {
commands.push({
name: item.name,
description: item.description,
options: item.options,
defaultMemberPermissions: item.permission === "none",
defaultMemberPermissions: item.permission,
integration_types: item.integration_types || [0],
});
} else {
commands.push({
name: item.name,
description: item.description,
defaultMemberPermissions: item.permission === "none",
defaultMemberPermissions: item.permission,
integration_types: item.integration_types || [0],
});
}
}
Expand All @@ -236,11 +256,11 @@ async function deploy_global(client) {
commands.push({
name: item.name,
type: item.type,
defaultMemberPermissions: item.permission === "none",
defaultMemberPermissions: item.permission,
});
}
});

await client.application.commands.set(commands);
return commands.length.toString();
return commands.length;
}
Loading

0 comments on commit 207f8ab

Please sign in to comment.