temp commit

main
kry008 2024-05-23 14:03:01 +02:00
parent 192cd1d2c5
commit 8e08a932bf
1 changed files with 0 additions and 107 deletions

View File

@ -1,107 +0,0 @@
//optiona name of the command
var fs = require('fs');
function getAllCommands(client) {
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const allCommands = [];
for (const file of commandFiles) {
const command = require(`./${file}`);
allCommands.push(command);
}
return allCommands;
}
function allCommandsNames(guild = true)
{
//check if it is in dm or guild
if(guild)
{
const commands = getAllCommands();
let str = '';
for(const command of commands)
{
if(command.admin === false)
str += command.name + '\n';
}
return str;
}
else
{
const commands = getAllCommands();
let str = '';
for(const command of commands)
{
if(command.canBeUsedInDm)
if(command.admin === false)
str += command.name + '\n';
}
return str;
}
}
function getCommand(name, guild = true)
{
//check if it is in dm or guild
if(guild)
{
const commands = getAllCommands();
for(const command of commands)
{
if(command.name === name)
return command;
}
}
else
{
const commands = getAllCommands();
for(const command of commands)
{
if(command.name === name && command.canBeUsedInDm)
return command;
}
}
return null;
}
module.exports = {
name: 'help',
description: 'Get a list of all commands or information about a specific command',
help: 'Get a list of all commands or information about a specific command',
options: [
{
name: 'command',
description: 'Command to get information about',
type: 3,
required: false,
},
],
slash: true,
text: true,
admin: false,
requireKick: false,
premium: false,
requireBan: false,
canBeUsedInDm: true,
contexts: ['GUILD_TEXT', 'GUID_VOICE', 'DM'],
integration_types: [0,1],
execute: async (message, args) => {
if(args.length === 0)
{
const commands = allCommandsNames();
message.channel.send(commands);
return;
}
const command = getCommand(args[0]);
if(command === null)
{
message.channel.send('Command not found');
return;
}
message.channel.send('Name: ' + command.name + '\nDescription: ' + command.description + '\nHelp: ' + command.help);
},
executeSlash: async interaction => {
const command = getCommand(interaction.options.getString('command'));
if(command === null)
{
interaction.reply('Command not found');
return;
}
interaction.reply('Name: ' + command.name + '\nDescription: ' + command.description + '\nHelp: ' + command.help);
},
};