mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Formatted code and clean up
This commit is contained in:
+164
-160
@@ -1,180 +1,179 @@
|
||||
import Logger from "../libs/Logger";
|
||||
import DiscordProvider from "../providers/Discord";
|
||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
|
||||
import DiscordProvider from '../providers/Discord';
|
||||
import Logger from '../libs/Logger';
|
||||
|
||||
export const GLOBAL_COMMANDS: Object[] = [];
|
||||
|
||||
export const GUILD_COMMANDS: Object[] = [];
|
||||
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('help')
|
||||
.setDescription('Show help menu')
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder().setName('help').setDescription('Show help menu'));
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder().setName('ping').setDescription('Measure network latency')
|
||||
);
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('ping')
|
||||
.setDescription('Measure network latency')
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder().setName('invite').setDescription('Invite me to your server!')
|
||||
);
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('invite')
|
||||
.setDescription('Invite me to your server!')
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder()
|
||||
.setName('say')
|
||||
.setDescription('Make me say something')
|
||||
.addStringOption((option) =>
|
||||
option.setName('message').setDescription('Message you want me to say').setRequired(true)
|
||||
)
|
||||
);
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('say')
|
||||
.setDescription('Make me say something')
|
||||
.addStringOption(option => option
|
||||
.setName('message')
|
||||
.setDescription('Message you want me to say')
|
||||
.setRequired(true)
|
||||
)
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder()
|
||||
.setName('interaction')
|
||||
.setDescription('[Developer Only] Manage interaction')
|
||||
.addSubcommand((info) =>
|
||||
info.setName('info').setDescription('[Developer Only] Interaction modules information')
|
||||
)
|
||||
.addSubcommand((reloadAll) =>
|
||||
reloadAll
|
||||
.setName('reloadall')
|
||||
.setDescription('[Developer Only] Reload interaction for global and all guilds')
|
||||
)
|
||||
);
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('interaction')
|
||||
.setDescription('[Developer Only] Manage interaction')
|
||||
.addSubcommand(info => info
|
||||
.setName('info')
|
||||
.setDescription('[Developer Only] Interaction modules information')
|
||||
)
|
||||
.addSubcommand(reloadAll => reloadAll
|
||||
.setName('reloadall')
|
||||
.setDescription('[Developer Only] Reload interaction for global and all guilds')
|
||||
)
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder()
|
||||
.setName('settings')
|
||||
.setDescription('Change settings')
|
||||
.addSubcommand((info) =>
|
||||
info
|
||||
.setName('setprefix')
|
||||
.setDescription('Change what prefix to use on this guild')
|
||||
.addStringOption((prefix) =>
|
||||
prefix.setName('prefix').setDescription('New prefix to use').setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand((info) =>
|
||||
info
|
||||
.setName('setenableserviceannouncement')
|
||||
.setDescription('Enable or disable service announcement feature')
|
||||
.addStringOption((prefix) =>
|
||||
prefix.setName('status').setDescription('New status').setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand((info) =>
|
||||
info
|
||||
.setName('setserviceannouncementchannel')
|
||||
.setDescription('Set channel where service announcement will be sent')
|
||||
.addChannelOption((prefix) =>
|
||||
prefix.setName('channel').setDescription('New status').setRequired(true)
|
||||
)
|
||||
)
|
||||
);
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('settings')
|
||||
.setDescription('Change settings')
|
||||
.addSubcommand(info => info
|
||||
.setName('setprefix')
|
||||
.setDescription('Change what prefix to use on this guild')
|
||||
.addStringOption(prefix => prefix
|
||||
.setName('prefix')
|
||||
.setDescription('New prefix to use')
|
||||
.setRequired(true)
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder()
|
||||
.setName('membershipscreening')
|
||||
.setDescription('Membership screening')
|
||||
.addSubcommand((info) =>
|
||||
info.setName('info').setDescription('Show more information for membership screening')
|
||||
)
|
||||
)
|
||||
.addSubcommand(info => info
|
||||
.setName('setenableserviceannouncement')
|
||||
.setDescription('Enable or disable service announcement feature')
|
||||
.addStringOption(prefix => prefix
|
||||
.setName('status')
|
||||
.setDescription('New status')
|
||||
.setRequired(true)
|
||||
.addSubcommand((enable) =>
|
||||
enable.setName('enable').setDescription('Enable membership screening')
|
||||
)
|
||||
)
|
||||
.addSubcommand(info => info
|
||||
.setName('setserviceannouncementchannel')
|
||||
.setDescription('Set channel where service announcement will be sent')
|
||||
.addChannelOption(prefix => prefix
|
||||
.setName('channel')
|
||||
.setDescription('New status')
|
||||
.setRequired(true)
|
||||
.addSubcommand((enable) =>
|
||||
enable.setName('disable').setDescription('Disable membership screening')
|
||||
)
|
||||
.addSubcommand((setrole) =>
|
||||
setrole
|
||||
.setName('setrole')
|
||||
.setDescription('Set a role that user will be granted when approved to join')
|
||||
.addRoleOption((option) =>
|
||||
option
|
||||
.setName('role')
|
||||
.setDescription(
|
||||
'Select a role that user will be granted when approved to join'
|
||||
)
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand((setchannel) =>
|
||||
setchannel
|
||||
.setName('setchannel')
|
||||
.setDescription(
|
||||
'Set channel where membership screening approval request will be sent'
|
||||
)
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName('channel')
|
||||
.setDescription('Select a channel where approval request will be sent')
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand((createmessage) =>
|
||||
createmessage
|
||||
.setName('createmessage')
|
||||
.setDescription(
|
||||
'Create greeting message for membership screening into the channel. A message for new commers to read'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('membershipscreening')
|
||||
.setDescription('Membership screening')
|
||||
.addSubcommand(info => info
|
||||
.setName('info')
|
||||
.setDescription('Show more information for membership screening')
|
||||
)
|
||||
.addSubcommand(enable => enable
|
||||
.setName('enable')
|
||||
.setDescription('Enable membership screening')
|
||||
)
|
||||
.addSubcommand(enable => enable
|
||||
.setName('disable')
|
||||
.setDescription('Disable membership screening')
|
||||
)
|
||||
.addSubcommand(setrole => setrole
|
||||
.setName('setrole')
|
||||
.setDescription('Set a role that user will be granted when approved to join')
|
||||
.addRoleOption(option => option
|
||||
.setName('role')
|
||||
.setDescription('Select a role that user will be granted when approved to join')
|
||||
.setRequired(true)
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder()
|
||||
.setName('osu')
|
||||
.setDescription('Interact with the game osu!')
|
||||
.addSubcommand((user) =>
|
||||
user
|
||||
.setName('user')
|
||||
.setDescription('Get user information on osu!')
|
||||
.addStringOption((user) =>
|
||||
user.setName('user').setDescription('Username or User id').setRequired(true)
|
||||
)
|
||||
)
|
||||
)
|
||||
.addSubcommand(setchannel => setchannel
|
||||
.setName('setchannel')
|
||||
.setDescription('Set channel where membership screening approval request will be sent')
|
||||
.addChannelOption(option => option
|
||||
.setName('channel')
|
||||
.setDescription('Select a channel where approval request will be sent')
|
||||
.setRequired(true)
|
||||
.addSubcommand((beatmap) =>
|
||||
beatmap
|
||||
.setName('beatmap')
|
||||
.setDescription('Get beatmap information on osu!')
|
||||
.addStringOption((user) =>
|
||||
user.setName('beatmap').setDescription('Beatmap id').setRequired(true)
|
||||
)
|
||||
)
|
||||
)
|
||||
.addSubcommand(createmessage => createmessage
|
||||
.setName('createmessage')
|
||||
.setDescription('Create greeting message for membership screening into the channel. A message for new commers to read')
|
||||
)
|
||||
);
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('osu')
|
||||
.setDescription('Interact with the game osu!')
|
||||
.addSubcommand(user => user
|
||||
.setName('user')
|
||||
.setDescription('Get user information on osu!')
|
||||
.addStringOption(user => user
|
||||
.setName('user')
|
||||
.setDescription('Username or User id')
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand(beatmap => beatmap
|
||||
.setName('beatmap')
|
||||
.setDescription('Get beatmap information on osu!')
|
||||
.addStringOption(user => user
|
||||
.setName('beatmap')
|
||||
.setDescription('Beatmap id')
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('userinfo')
|
||||
.setDescription('Lookup discord user information')
|
||||
.addSubcommand(user => user
|
||||
.setName('user')
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder()
|
||||
.setName('userinfo')
|
||||
.setDescription('Lookup discord user information')
|
||||
.addUserOption(user => user
|
||||
.setName('user')
|
||||
.setDescription('Discord user to lookup')
|
||||
.setRequired(true)
|
||||
.addSubcommand((user) =>
|
||||
user
|
||||
.setName('user')
|
||||
.setDescription('Lookup discord user information')
|
||||
.addUserOption((user) =>
|
||||
user.setName('user').setDescription('Discord user to lookup').setRequired(true)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('stats')
|
||||
.setDescription('Show the bot stats')
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder().setName('stats').setDescription('Show the bot stats')
|
||||
);
|
||||
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('skip')
|
||||
.setDescription('Skip the current song')
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder().setName('skip').setDescription('Skip the current song')
|
||||
);
|
||||
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('nowplaying')
|
||||
.setDescription('Show the current song information')
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder()
|
||||
.setName('nowplaying')
|
||||
.setDescription('Show the current song information')
|
||||
);
|
||||
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('join')
|
||||
.setDescription('Join the voice channel')
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder().setName('join').setDescription('Join the voice channel')
|
||||
);
|
||||
|
||||
GUILD_COMMANDS.push(new SlashCommandBuilder()
|
||||
.setName('leave')
|
||||
.setDescription('Leave the voice channel')
|
||||
GUILD_COMMANDS.push(
|
||||
new SlashCommandBuilder().setName('leave').setDescription('Leave the voice channel')
|
||||
);
|
||||
|
||||
|
||||
export const registerAllGlobalCommands = async () => {
|
||||
Logger.log('info', `Registering all global interaction commands`);
|
||||
await DiscordProvider.client.application?.commands.set(JSON.parse(JSON.stringify(GLOBAL_COMMANDS)));
|
||||
}
|
||||
await DiscordProvider.client.application?.commands.set(
|
||||
JSON.parse(JSON.stringify(GLOBAL_COMMANDS))
|
||||
);
|
||||
};
|
||||
|
||||
export const unregisterAllGlobalCommands = async () => {
|
||||
//const commands = await DiscordProvider.client.application?.commands.fetch();
|
||||
@@ -187,32 +186,38 @@ export const unregisterAllGlobalCommands = async () => {
|
||||
/*for(const command of commands) {
|
||||
await DiscordProvider.client.application?.commands.delete(command[1]);
|
||||
}*/
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export const registerAllGuildsCommands = async () => {
|
||||
const guilds = DiscordProvider.client.guilds.cache.map(guild => guild.id);
|
||||
const guilds = DiscordProvider.client.guilds.cache.map((guild) => guild.id);
|
||||
|
||||
for(const guild of guilds) {
|
||||
for (const guild of guilds) {
|
||||
const guildObject = DiscordProvider.client.guilds.cache.get(guild);
|
||||
|
||||
if(!guildObject) continue;
|
||||
|
||||
Logger.log('info', `Registering all interaction commands on guild ${guildObject.name} (${guildObject.id})`);
|
||||
await DiscordProvider.client.guilds.cache.get(guildObject.id)?.commands.set(JSON.parse(JSON.stringify(GUILD_COMMANDS)));
|
||||
if (!guildObject) continue;
|
||||
|
||||
Logger.log(
|
||||
'info',
|
||||
`Registering all interaction commands on guild ${guildObject.name} (${guildObject.id})`
|
||||
);
|
||||
await DiscordProvider.client.guilds.cache
|
||||
.get(guildObject.id)
|
||||
?.commands.set(JSON.parse(JSON.stringify(GUILD_COMMANDS)));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const unregisterAllGuildsCommands = async () => {
|
||||
const guilds = DiscordProvider.client.guilds.cache.map(guild => guild.id);
|
||||
|
||||
for(const guild of guilds) {
|
||||
const guilds = DiscordProvider.client.guilds.cache.map((guild) => guild.id);
|
||||
|
||||
for (const guild of guilds) {
|
||||
const guildObject = DiscordProvider.client.guilds.cache.get(guild);
|
||||
|
||||
if(!guildObject) continue;
|
||||
if (!guildObject) continue;
|
||||
|
||||
Logger.log('info', `Unregistering all interaction commands on guild ${guildObject.name} (${guildObject.id})`);
|
||||
Logger.log(
|
||||
'info',
|
||||
`Unregistering all interaction commands on guild ${guildObject.name} (${guildObject.id})`
|
||||
);
|
||||
await DiscordProvider.client.guilds.cache.get(guildObject.id)?.commands.set([]);
|
||||
|
||||
//const commands = await guildObject.commands.fetch();
|
||||
@@ -225,6 +230,5 @@ export const unregisterAllGuildsCommands = async () => {
|
||||
Logger.log('error', `Cannot unregister all interaction commands on guild ${guildObject.name} (${guildObject.id})`);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user