2022-06-06 14:59:53 +07:00
|
|
|
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
|
|
|
|
|
|
|
|
import DiscordProvider from '../providers/Discord';
|
|
|
|
|
import Logger from '../libs/Logger';
|
2021-09-16 23:54:32 -07:00
|
|
|
|
2022-06-06 18:45:45 +07:00
|
|
|
export const GLOBAL_COMMANDS: Object[] = [
|
|
|
|
|
new SlashCommandBuilder().setName('help').setDescription('Show help menu'),
|
|
|
|
|
new SlashCommandBuilder().setName('ping').setDescription('Measure network latency'),
|
|
|
|
|
new SlashCommandBuilder().setName('invite').setDescription('Invite me to your server!'),
|
|
|
|
|
new SlashCommandBuilder().setName('stats').setDescription('Show the bot stats'),
|
|
|
|
|
new SlashCommandBuilder().setName('skip').setDescription('Skip the current song'),
|
|
|
|
|
new SlashCommandBuilder()
|
|
|
|
|
.setName('nowplaying')
|
|
|
|
|
.setDescription('Show the current song information'),
|
|
|
|
|
new SlashCommandBuilder().setName('join').setDescription('Join the voice channel'),
|
|
|
|
|
new SlashCommandBuilder().setName('leave').setDescription('Leave the voice channel'),
|
|
|
|
|
new SlashCommandBuilder().setName('resume').setDescription('Resume paused music'),
|
|
|
|
|
new SlashCommandBuilder().setName('pause').setDescription('Pause the current music'),
|
2022-06-06 14:59:53 +07:00
|
|
|
new SlashCommandBuilder()
|
|
|
|
|
.setName('say')
|
|
|
|
|
.setDescription('Make me say something')
|
|
|
|
|
.addStringOption((option) =>
|
|
|
|
|
option.setName('message').setDescription('Message you want me to say').setRequired(true)
|
2022-06-06 18:45:45 +07:00
|
|
|
),
|
|
|
|
|
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)
|
|
|
|
|
)
|
2022-06-06 14:59:53 +07:00
|
|
|
)
|
2022-06-06 18:45:45 +07:00
|
|
|
.addSubcommand((beatmap) =>
|
|
|
|
|
beatmap
|
|
|
|
|
.setName('beatmap')
|
|
|
|
|
.setDescription('Get beatmap information on osu!')
|
|
|
|
|
.addStringOption((user) =>
|
|
|
|
|
user.setName('beatmap').setDescription('Beatmap id').setRequired(true)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
new SlashCommandBuilder()
|
|
|
|
|
.setName('userinfo')
|
|
|
|
|
.setDescription('Lookup discord user information')
|
|
|
|
|
.addSubcommand((user) =>
|
|
|
|
|
user
|
|
|
|
|
.setName('user')
|
|
|
|
|
.setDescription('Lookup discord user information')
|
|
|
|
|
.addUserOption((user) =>
|
|
|
|
|
user.setName('user').setDescription('Discord user to lookup').setRequired(true)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
export const GUILD_COMMANDS: Object[] = [];
|
|
|
|
|
|
|
|
|
|
/*
|
2022-06-06 14:59:53 +07:00
|
|
|
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')
|
|
|
|
|
)
|
2021-09-17 11:13:58 -07:00
|
|
|
);
|
2022-06-06 14:59:53 +07:00
|
|
|
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)
|
|
|
|
|
)
|
|
|
|
|
)
|
2021-09-18 06:28:41 -07:00
|
|
|
);
|
2022-06-06 14:59:53 +07:00
|
|
|
GUILD_COMMANDS.push(
|
|
|
|
|
new SlashCommandBuilder()
|
|
|
|
|
.setName('membershipscreening')
|
|
|
|
|
.setDescription('Membership screening')
|
|
|
|
|
.addSubcommand((info) =>
|
|
|
|
|
info.setName('info').setDescription('Show more information for membership screening')
|
2021-09-18 08:04:22 -07:00
|
|
|
)
|
2022-06-06 14:59:53 +07:00
|
|
|
.addSubcommand((enable) =>
|
|
|
|
|
enable.setName('enable').setDescription('Enable membership screening')
|
2022-01-27 17:59:59 +07:00
|
|
|
)
|
2022-06-06 14:59:53 +07:00
|
|
|
.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'
|
|
|
|
|
)
|
2022-01-27 17:59:59 +07:00
|
|
|
)
|
2022-06-06 18:45:45 +07:00
|
|
|
);*/
|
2022-06-06 02:43:17 +07:00
|
|
|
|
2021-09-16 23:54:32 -07:00
|
|
|
export const registerAllGlobalCommands = async () => {
|
|
|
|
|
Logger.log('info', `Registering all global interaction commands`);
|
2022-06-06 14:59:53 +07:00
|
|
|
await DiscordProvider.client.application?.commands.set(
|
|
|
|
|
JSON.parse(JSON.stringify(GLOBAL_COMMANDS))
|
|
|
|
|
);
|
|
|
|
|
};
|
2021-09-16 23:54:32 -07:00
|
|
|
|
|
|
|
|
export const unregisterAllGlobalCommands = async () => {
|
2021-09-18 06:28:41 -07:00
|
|
|
//const commands = await DiscordProvider.client.application?.commands.fetch();
|
2021-09-16 23:54:32 -07:00
|
|
|
|
2021-09-18 06:28:41 -07:00
|
|
|
//if(typeof commands === 'undefined') return;
|
|
|
|
|
//if(commands.size === 0) return;
|
2021-09-16 23:54:32 -07:00
|
|
|
|
|
|
|
|
Logger.log('info', `Unregistering all global interaction commands`);
|
2021-09-18 06:28:41 -07:00
|
|
|
await DiscordProvider.client.application?.commands.set([]);
|
|
|
|
|
/*for(const command of commands) {
|
2021-09-16 23:54:32 -07:00
|
|
|
await DiscordProvider.client.application?.commands.delete(command[1]);
|
2021-09-18 06:28:41 -07:00
|
|
|
}*/
|
2022-06-06 14:59:53 +07:00
|
|
|
};
|
2021-09-16 23:54:32 -07:00
|
|
|
|
|
|
|
|
export const registerAllGuildsCommands = async () => {
|
2022-06-06 14:59:53 +07:00
|
|
|
const guilds = DiscordProvider.client.guilds.cache.map((guild) => guild.id);
|
2021-09-16 23:54:32 -07:00
|
|
|
|
2022-06-06 14:59:53 +07:00
|
|
|
for (const guild of guilds) {
|
2021-09-16 23:54:32 -07:00
|
|
|
const guildObject = DiscordProvider.client.guilds.cache.get(guild);
|
|
|
|
|
|
2022-06-06 14:59:53 +07:00
|
|
|
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)));
|
2021-09-16 23:54:32 -07:00
|
|
|
}
|
2022-06-06 14:59:53 +07:00
|
|
|
};
|
2021-09-16 23:54:32 -07:00
|
|
|
|
|
|
|
|
export const unregisterAllGuildsCommands = async () => {
|
2022-06-06 14:59:53 +07:00
|
|
|
const guilds = DiscordProvider.client.guilds.cache.map((guild) => guild.id);
|
2021-09-16 23:54:32 -07:00
|
|
|
|
2022-06-06 14:59:53 +07:00
|
|
|
for (const guild of guilds) {
|
2021-09-16 23:54:32 -07:00
|
|
|
const guildObject = DiscordProvider.client.guilds.cache.get(guild);
|
|
|
|
|
|
2022-06-06 14:59:53 +07:00
|
|
|
if (!guildObject) continue;
|
2021-09-16 23:54:32 -07:00
|
|
|
|
2022-06-06 14:59:53 +07:00
|
|
|
Logger.log(
|
|
|
|
|
'info',
|
|
|
|
|
`Unregistering all interaction commands on guild ${guildObject.name} (${guildObject.id})`
|
|
|
|
|
);
|
2021-09-18 06:28:41 -07:00
|
|
|
await DiscordProvider.client.guilds.cache.get(guildObject.id)?.commands.set([]);
|
|
|
|
|
|
|
|
|
|
//const commands = await guildObject.commands.fetch();
|
|
|
|
|
|
|
|
|
|
//if(commands.size === 0) continue;
|
|
|
|
|
/*for(const command of commands) {
|
2021-09-16 23:54:32 -07:00
|
|
|
try {
|
|
|
|
|
await DiscordProvider.client.guilds.cache.get(guildObject.id)?.commands.delete(command[1]);
|
|
|
|
|
} catch(err) {
|
|
|
|
|
Logger.log('error', `Cannot unregister all interaction commands on guild ${guildObject.name} (${guildObject.id})`);
|
|
|
|
|
}
|
2021-09-18 06:28:41 -07:00
|
|
|
}*/
|
2021-09-16 23:54:32 -07:00
|
|
|
}
|
2022-06-06 14:59:53 +07:00
|
|
|
};
|