82 lines
1.9 KiB
JavaScript

var client = require("./client");
var config = require("./config");
var commands = module.exports = [
{
name: "say",
description: "test command",
options: [
{
name: "text",
description: "text to say",
type: 3, // string
required: true
}
],
exec: i => {
i.reply(i.options.getString("text") || "bruh");
}
},
{
name: "owo",
description: "random owo",
options: [
{
name: "length",
description: "length of owo",
type: 4, // integer
required: false
}
],
exec: i => {
let owo = Math.round(Math.random()) ? 'O' : 'o';
let n = Math.min(i.options.getInteger("length") || 9, 1998);
for (let i = 0; i < n; i++) owo += ['o','w','O','W'][Math.floor(Math.random() * 4)];
owo += owo = Math.round(Math.random()) ? 'O' : 'o';
i.reply(owo);
}
},
{
name: "archive",
description: "Delete a channel without actually deleting it",
options: [
{
name: "channel",
description: "channel",
type: "CHANNEL",
required: true
}
],
defaultPermission: false,
permissions: [
{
id: config.admin_role,
type: "ROLE",
permission: true
}
],
exec: async i => {
let channel = i.options.getChannel("channel");
await channel.setParent(config.archive_category);
await channel.lockPermissions();
await i.reply({content: channel.toString(), ephemeral: true});
}
}
];
client.on("interactionCreate", interaction => {
commands.find(x => x.name == interaction.commandName).exec?.(interaction);
});
client.once("ready", async () => {
let guild = client.guilds.resolve(config.guild);
await guild.commands.set(commands);
await guild.commands.permissions.set({
fullPermissions: commands.map(local_command => {
let discord_command = guild.commands.cache.find(discord_command => local_command.name == discord_command.name);
return {
id: discord_command.id,
permissions: local_command.permissions || []
}
})
});
});