style: Eslint changes to get rid of errors

imgbot
Kieran 2022-09-21 19:06:13 +01:00
parent dc4098703e
commit 53a5a7f003
4 changed files with 352 additions and 337 deletions

View File

@ -1,9 +1,13 @@
{
"extends": ["airbnb-base", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": 2018
},
"env": {
"node": true,
"commonjs": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
"prettier/prettier": "error",
"no-unused-vars": "warn",
@ -18,4 +22,4 @@
"no-plusplus": "off",
"no-underscore-dangle": "off"
}
}
}

View File

@ -1,298 +1,313 @@
const client = require("../index");
const discord = require("discord.js")
const client = require('../index');
const discord = require('discord.js');
client.on("interactionCreate", async (interaction) => {
// Slash Command Handling
if (interaction.isCommand()) {
const cmd = client.slashCommands.get(interaction.commandName);
if (!cmd)
return interaction.reply({ content: "An error has occurred" });
client.on('interactionCreate', async (interaction) => {
// Slash Command Handling
if (interaction.isCommand()) {
const cmd = client.slashCommands.get(interaction.commandName);
if (!cmd) return interaction.reply({ content: 'An error has occurred' });
const args = [];
const args = [];
for (let option of interaction.options.data) {
if (option.type === "SUB_COMMAND") {
if (option.name) args.push(option.name);
option.options?.forEach((x) => {
if (x.value) args.push(x.value);
});
} else if (option.value) args.push(option.value);
}
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
for (let option of interaction.options.data) {
if (option.type === 'SUB_COMMAND') {
if (option.name) args.push(option.name);
option.options?.forEach((x) => {
if (x.value) args.push(x.value);
});
} else if (option.value) args.push(option.value);
}
interaction.member = interaction.guild.members.cache.get(
interaction.user.id
);
cmd.run(client, interaction, args);
}
cmd.run(client, interaction, args);
}
// Context Menu Handling
if (interaction.isContextMenu()) {
await interaction.deferReply({ ephemeral: false });
const command = client.slashCommands.get(interaction.commandName);
if (command) command.run(client, interaction);
}
// Button Handling
if (interaction.isButton()) {
if(interaction.customId == "codeOfConduct"){
if(interaction.member.roles.cache.has("973646380771979304"))
{
interaction.reply({ content: 'You already have agreed to the code of conduct!', ephemeral: true})
}
else
{
interaction.member.roles.add("973646380771979304")
await interaction.reply({ content: 'Thank you for agreeing to the code of conduct!\r\nYou can now access the rest of the server!', ephemeral: true});
}
}
// Context Menu Handling
if (interaction.isContextMenu()) {
await interaction.deferReply({ ephemeral: false });
const command = client.slashCommands.get(interaction.commandName);
if (command) command.run(client, interaction);
}
// Button Handling
if (interaction.isButton()) {
if (interaction.customId == 'codeOfConduct') {
if (interaction.member.roles.cache.has('973646380771979304')) {
interaction.reply({
content: 'You already have agreed to the code of conduct!',
ephemeral: true,
});
} else {
interaction.member.roles.add('973646380771979304');
await interaction.reply({
content:
'Thank you for agreeing to the code of conduct!\r\nYou can now access the rest of the server!',
ephemeral: true,
});
}
}
if (interaction.customId == 'paidModal') {
if (interaction.member.roles.cache.has(`427878753008353292`)) {
await interaction.deferReply({ ephemeral: true });
interaction.followUp({
content: 'You already have the paid member role.',
ephemeral: true,
});
} else {
const modal = new discord.Modal()
.setCustomId('modal-paidmember')
.setTitle('Paid Member Discord Access');
const studentname = new discord.TextInputComponent()
.setLabel('Student Name')
.setStyle('SHORT')
.setCustomId('studentname')
.setPlaceholder(`Joe Blogs`);
const studentnumber = new discord.TextInputComponent()
.setLabel('Student Number')
.setStyle('SHORT')
.setCustomId('studentnumber')
.setPlaceholder(`202001234`);
const firstActionRow = new discord.MessageActionRow().addComponents(
studentname
);
const secondActionRow = new discord.MessageActionRow().addComponents(
studentnumber
);
modal.addComponents(firstActionRow, secondActionRow);
await interaction.showModal(modal);
}
}
if(interaction.customId == "paidModal")
{
if(interaction.member.roles.cache.has(`427878753008353292`))
{
await interaction.deferReply({ ephemeral: true })
interaction.followUp({ content: 'You already have the paid member role.', ephemeral: true })
if (interaction.customId == 'deletemessage') {
await interaction.message.delete();
await interaction.reply({
content: 'Message has been deleted',
ephemeral: true,
});
}
}
else{
const modal = new discord.Modal()
.setCustomId('modal-paidmember')
.setTitle('Paid Member Discord Access')
const studentname = new discord.TextInputComponent()
.setLabel("Student Name")
.setStyle("SHORT")
.setCustomId("studentname")
.setPlaceholder(`Joe Blogs`)
const studentnumber = new discord.TextInputComponent()
.setLabel("Student Number")
.setStyle("SHORT")
.setCustomId("studentnumber")
.setPlaceholder(`202001234`)
const firstActionRow = new discord.MessageActionRow().addComponents(studentname);
const secondActionRow = new discord.MessageActionRow().addComponents(studentnumber);
modal.addComponents(firstActionRow, secondActionRow);
await interaction.showModal(modal);
if (interaction.customId == 'CloseThread') {
interaction.reply(
`This channel has been archived, you can unarchive this thread by sending another message.`
);
interaction.channel.setArchived(true);
}
}
}
}
// Select Menu Handling
if (interaction.isSelectMenu()) {
if (interaction.customId == 'yearSelect') {
if (interaction.values.includes('0')) {
interaction.member.roles.add('974754114296741948'); // Add Foundation
interaction.member.roles.remove('441276956089122836'); // Remove First Year
interaction.member.roles.remove('441276979514441741'); // Remove Second Year
interaction.member.roles.remove('441277048003100684'); // Remove Year In Industry Year
interaction.member.roles.remove('441277001744121856'); // Remove Third Year
interaction.member.roles.remove('441277023873138743'); // Remove Masters Year
interaction.member.roles.remove('460435898660683778'); // Remove PhD Year
interaction.member.roles.remove('441277481488613386'); // Remove Graduate Year
} else if (interaction.values.includes('1')) {
interaction.member.roles.add('441276956089122836'); // Add First Year
interaction.member.roles.remove('974754114296741948'); // Remove Foundation Year
interaction.member.roles.remove('441276979514441741'); // Remove Second Year
interaction.member.roles.remove('441277048003100684'); // Remove Year In Industry Year
interaction.member.roles.remove('441277001744121856'); // Remove Third Year
interaction.member.roles.remove('441277023873138743'); // Remove Masters Year
interaction.member.roles.remove('460435898660683778'); // Remove PhD Year
interaction.member.roles.remove('441277481488613386'); // Remove Graduate Year
} else if (interaction.values.includes('2')) {
interaction.member.roles.add('441276979514441741'); // Add Second Year
interaction.member.roles.remove('974754114296741948'); // Remove Foundation Year
interaction.member.roles.remove('441276956089122836'); // Remove First Year
interaction.member.roles.remove('441277048003100684'); // Remove Year In Industry Year
interaction.member.roles.remove('441277001744121856'); // Remove Third Year
interaction.member.roles.remove('441277023873138743'); // Remove Masters Year
interaction.member.roles.remove('460435898660683778'); // Remove PhD Year
interaction.member.roles.remove('441277481488613386'); // Remove Graduate Year
} else if (interaction.values.includes('3')) {
interaction.member.roles.add('441277048003100684'); // Add Year In Industry Year
interaction.member.roles.remove('974754114296741948'); // Remove Foundation Year
interaction.member.roles.remove('441276956089122836'); // Remove First Year
interaction.member.roles.remove('441276979514441741'); // Remove Second Year
interaction.member.roles.remove('441277001744121856'); // Remove Third Year
interaction.member.roles.remove('441277023873138743'); // Remove Masters Year
interaction.member.roles.remove('460435898660683778'); // Remove PhD Year
interaction.member.roles.remove('441277481488613386'); // Remove Graduate Year
} else if (interaction.values.includes('4')) {
interaction.member.roles.add('441277001744121856'); // Add Third Year
interaction.member.roles.remove('974754114296741948'); // Remove Foundation Year
interaction.member.roles.remove('441276956089122836'); // Remove First Year
interaction.member.roles.remove('441276979514441741'); // Remove Second Year
interaction.member.roles.remove('441277048003100684'); // Remove Year In Industry Year
interaction.member.roles.remove('441277023873138743'); // Remove Masters Year
interaction.member.roles.remove('460435898660683778'); // Remove PhD Year
interaction.member.roles.remove('441277481488613386'); // Remove Graduate Year
} else if (interaction.values.includes('5')) {
interaction.member.roles.add('441277023873138743'); // Add Masters Year
interaction.member.roles.remove('974754114296741948'); // Remove Foundation Year
interaction.member.roles.remove('441276956089122836'); // Remove First Year
interaction.member.roles.remove('441276979514441741'); // Remove Second Year
interaction.member.roles.remove('441277048003100684'); // Remove Year In Industry Year
interaction.member.roles.remove('441277001744121856'); // Remove Third Year
interaction.member.roles.remove('460435898660683778'); // Remove PhD Year
interaction.member.roles.remove('441277481488613386'); // Remove Graduate Year
} else if (interaction.values.includes('6')) {
interaction.member.roles.add('460435898660683778'); // Add PhD Year
interaction.member.roles.remove('974754114296741948'); // Remove Foundation Year
interaction.member.roles.remove('441276956089122836'); // Remove First Year
interaction.member.roles.remove('441276979514441741'); // Remove Second Year
interaction.member.roles.remove('441277048003100684'); // Remove Year In Industry Year
interaction.member.roles.remove('441277001744121856'); // Remove Third Year
interaction.member.roles.remove('441277023873138743'); // Remove Masters Year
interaction.member.roles.remove('441277481488613386'); // Remove Graduate Year
} else if (interaction.values.includes('7')) {
interaction.member.roles.add('441277481488613386'); // Add Graduate Year
interaction.member.roles.remove('974754114296741948'); // Remove Foundation Year
interaction.member.roles.remove('441276956089122836'); // Remove First Year
interaction.member.roles.remove('441276979514441741'); // Remove Second Year
interaction.member.roles.remove('441277048003100684'); // Remove Year In Industry Year
interaction.member.roles.remove('441277001744121856'); // Remove Third Year
interaction.member.roles.remove('441277023873138743'); // Remove Masters Year
interaction.member.roles.remove('460435898660683778'); // Remove PhD Year
}
await interaction.reply({
content: 'Roles have been updated',
ephemeral: true,
});
}
if(interaction.customId == "deletemessage")
{
await interaction.message.delete();
await interaction.reply({ content: 'Message has been deleted', ephemeral: true});
}
if (interaction.customId == 'pronounSelect') {
if (interaction.values.includes('HeHim')) {
interaction.member.roles.add('851148987271479385');
} else {
interaction.member.roles.remove('851148987271479385');
}
if (interaction.values.includes('HeThey')) {
interaction.member.roles.add('974762127762010162');
} else {
interaction.member.roles.remove('974762127762010162');
}
if(interaction.customId == "CloseThread")
{
interaction.reply(`This channel has been archived, you can unarchive this thread by sending another message.`)
interaction.channel.setArchived(true)
}
}
if (interaction.values.includes('SheHer')) {
interaction.member.roles.add('851149045241085963');
} else {
interaction.member.roles.remove('851149045241085963');
}
// Select Menu Handling
if(interaction.isSelectMenu()) {
if(interaction.customId == "yearSelect")
{
if(interaction.values.includes("0"))
{
interaction.member.roles.add("974754114296741948") // Add Foundation
interaction.member.roles.remove("441276956089122836") // Remove First Year
interaction.member.roles.remove("441276979514441741") // Remove Second Year
interaction.member.roles.remove("441277048003100684") // Remove Year In Industry Year
interaction.member.roles.remove("441277001744121856") // Remove Third Year
interaction.member.roles.remove("441277023873138743") // Remove Masters Year
interaction.member.roles.remove("460435898660683778") // Remove PhD Year
interaction.member.roles.remove("441277481488613386") // Remove Graduate Year
}
else if(interaction.values.includes("1"))
{
interaction.member.roles.add("441276956089122836") // Add First Year
interaction.member.roles.remove("974754114296741948") // Remove Foundation Year
interaction.member.roles.remove("441276979514441741") // Remove Second Year
interaction.member.roles.remove("441277048003100684") // Remove Year In Industry Year
interaction.member.roles.remove("441277001744121856") // Remove Third Year
interaction.member.roles.remove("441277023873138743") // Remove Masters Year
interaction.member.roles.remove("460435898660683778") // Remove PhD Year
interaction.member.roles.remove("441277481488613386") // Remove Graduate Year
}
else if(interaction.values.includes("2"))
{
interaction.member.roles.add("441276979514441741") // Add Second Year
interaction.member.roles.remove("974754114296741948") // Remove Foundation Year
interaction.member.roles.remove("441276956089122836") // Remove First Year
interaction.member.roles.remove("441277048003100684") // Remove Year In Industry Year
interaction.member.roles.remove("441277001744121856") // Remove Third Year
interaction.member.roles.remove("441277023873138743") // Remove Masters Year
interaction.member.roles.remove("460435898660683778") // Remove PhD Year
interaction.member.roles.remove("441277481488613386") // Remove Graduate Year
}
else if(interaction.values.includes("3"))
{
interaction.member.roles.add("441277048003100684") // Add Year In Industry Year
interaction.member.roles.remove("974754114296741948") // Remove Foundation Year
interaction.member.roles.remove("441276956089122836") // Remove First Year
interaction.member.roles.remove("441276979514441741") // Remove Second Year
interaction.member.roles.remove("441277001744121856") // Remove Third Year
interaction.member.roles.remove("441277023873138743") // Remove Masters Year
interaction.member.roles.remove("460435898660683778") // Remove PhD Year
interaction.member.roles.remove("441277481488613386") // Remove Graduate Year
}
else if(interaction.values.includes("4"))
{
interaction.member.roles.add("441277001744121856") // Add Third Year
interaction.member.roles.remove("974754114296741948") // Remove Foundation Year
interaction.member.roles.remove("441276956089122836") // Remove First Year
interaction.member.roles.remove("441276979514441741") // Remove Second Year
interaction.member.roles.remove("441277048003100684") // Remove Year In Industry Year
interaction.member.roles.remove("441277023873138743") // Remove Masters Year
interaction.member.roles.remove("460435898660683778") // Remove PhD Year
interaction.member.roles.remove("441277481488613386") // Remove Graduate Year
}
else if(interaction.values.includes("5"))
{
interaction.member.roles.add("441277023873138743") // Add Masters Year
interaction.member.roles.remove("974754114296741948") // Remove Foundation Year
interaction.member.roles.remove("441276956089122836") // Remove First Year
interaction.member.roles.remove("441276979514441741") // Remove Second Year
interaction.member.roles.remove("441277048003100684") // Remove Year In Industry Year
interaction.member.roles.remove("441277001744121856") // Remove Third Year
interaction.member.roles.remove("460435898660683778") // Remove PhD Year
interaction.member.roles.remove("441277481488613386") // Remove Graduate Year
}
else if(interaction.values.includes("6"))
{
interaction.member.roles.add("460435898660683778") // Add PhD Year
interaction.member.roles.remove("974754114296741948") // Remove Foundation Year
interaction.member.roles.remove("441276956089122836") // Remove First Year
interaction.member.roles.remove("441276979514441741") // Remove Second Year
interaction.member.roles.remove("441277048003100684") // Remove Year In Industry Year
interaction.member.roles.remove("441277001744121856") // Remove Third Year
interaction.member.roles.remove("441277023873138743") // Remove Masters Year
interaction.member.roles.remove("441277481488613386") // Remove Graduate Year
}
else if(interaction.values.includes("7"))
{
interaction.member.roles.add("441277481488613386") // Add Graduate Year
interaction.member.roles.remove("974754114296741948") // Remove Foundation Year
interaction.member.roles.remove("441276956089122836") // Remove First Year
interaction.member.roles.remove("441276979514441741") // Remove Second Year
interaction.member.roles.remove("441277048003100684") // Remove Year In Industry Year
interaction.member.roles.remove("441277001744121856") // Remove Third Year
interaction.member.roles.remove("441277023873138743") // Remove Masters Year
interaction.member.roles.remove("460435898660683778") // Remove PhD Year
}
await interaction.reply({ content: 'Roles have been updated', ephemeral: true});
}
if (interaction.values.includes('SheThey')) {
interaction.member.roles.add('974762040969273404');
} else {
interaction.member.roles.remove('974762040969273404');
}
if (interaction.values.includes('TheyThem')) {
interaction.member.roles.add('851149362582913074');
} else {
interaction.member.roles.remove('851149362582913074');
}
if(interaction.customId == "pronounSelect")
{
if(interaction.values.includes("HeHim"))
{ interaction.member.roles.add("851148987271479385")}
else{interaction.member.roles.remove("851148987271479385")}
if (interaction.values.includes('Any')) {
interaction.member.roles.add('851149407050137631');
} else {
interaction.member.roles.remove('851149407050137631');
}
if(interaction.values.includes("HeThey"))
{ interaction.member.roles.add("974762127762010162")}
else{interaction.member.roles.remove("974762127762010162")}
if (interaction.values.includes('Ask')) {
interaction.member.roles.add('851149443738107934');
} else {
interaction.member.roles.remove('851149443738107934');
}
if(interaction.values.includes("SheHer"))
{ interaction.member.roles.add("851149045241085963")}
else{interaction.member.roles.remove("851149045241085963")}
if(interaction.values.includes("SheThey"))
{ interaction.member.roles.add("974762040969273404")}
else{interaction.member.roles.remove("974762040969273404")}
await interaction.reply({
content: 'Roles have been updated',
ephemeral: true,
});
}
if(interaction.values.includes("TheyThem"))
{ interaction.member.roles.add("851149362582913074")}
else{interaction.member.roles.remove("851149362582913074")}
if (interaction.customId == 'bcsSelect') {
if (interaction.values.includes('bscStudent')) {
interaction.member.roles.add('891422426133581895'); // Add BCS Student
interaction.member.roles.remove('891422508555829288'); // Remove Associate
interaction.member.roles.remove('891422669575184436'); // Remove Prof
interaction.member.roles.remove('891422900182204487'); // Remove Fellow
} else if (interaction.values.includes('bcsAss')) {
interaction.member.roles.add('891422508555829288'); // Add BCS Associate
interaction.member.roles.remove('891422426133581895'); // Remove Student
interaction.member.roles.remove('891422669575184436'); // Remove Prof
interaction.member.roles.remove('891422900182204487'); // Remove Fellow
} else if (interaction.values.includes('bcsProf')) {
interaction.member.roles.add('891422669575184436'); // Add Prof
interaction.member.roles.remove('891422426133581895'); // Remove Student
interaction.member.roles.remove('891422508555829288'); // Remove Associate
interaction.member.roles.remove('891422900182204487'); // Remove Fellow
} else if (interaction.values.includes('bcsFellow')) {
interaction.member.roles.add('891422900182204487'); // Add Fellow
interaction.member.roles.remove('891422426133581895'); // Remove Student
interaction.member.roles.remove('891422508555829288'); // Remove Associate
interaction.member.roles.remove('891422669575184436'); // Remove Prof
}
await interaction.reply({
content: 'Roles have been updated',
ephemeral: true,
});
}
if(interaction.values.includes("Any"))
{ interaction.member.roles.add("851149407050137631")}
else{interaction.member.roles.remove("851149407050137631")}
if (interaction.customId == 'miscSelect') {
if (interaction.values.includes('courserep')) {
interaction.member.roles.add('493738161713709077');
} else {
interaction.member.roles.remove('493738161713709077');
}
if(interaction.values.includes("Ask"))
{ interaction.member.roles.add("851149443738107934")}
else{interaction.member.roles.remove("851149443738107934")}
if (interaction.values.includes('ACWPing')) {
interaction.member.roles.add('904354161561309184');
} else {
interaction.member.roles.remove('904354161561309184');
}
await interaction.reply({ content: 'Roles have been updated', ephemeral: true});
}
await interaction.reply({
content: 'Roles have been updated',
ephemeral: true,
});
}
}
if(interaction.customId == "bcsSelect")
{
if(interaction.values.includes("bscStudent"))
{
interaction.member.roles.add("891422426133581895") // Add BCS Student
interaction.member.roles.remove("891422508555829288") // Remove Associate
interaction.member.roles.remove("891422669575184436") // Remove Prof
interaction.member.roles.remove("891422900182204487") // Remove Fellow
}
else if(interaction.values.includes("bcsAss"))
{
interaction.member.roles.add("891422508555829288") // Add BCS Associate
interaction.member.roles.remove("891422426133581895") // Remove Student
interaction.member.roles.remove("891422669575184436") // Remove Prof
interaction.member.roles.remove("891422900182204487") // Remove Fellow
}
else if(interaction.values.includes("bcsProf"))
{
interaction.member.roles.add("891422669575184436") // Add Prof
interaction.member.roles.remove("891422426133581895") // Remove Student
interaction.member.roles.remove("891422508555829288") // Remove Associate
interaction.member.roles.remove("891422900182204487") // Remove Fellow
}
else if(interaction.values.includes("bcsFellow"))
{
interaction.member.roles.add("891422900182204487") // Add Fellow
interaction.member.roles.remove("891422426133581895") // Remove Student
interaction.member.roles.remove("891422508555829288") // Remove Associate
interaction.member.roles.remove("891422669575184436") // Remove Prof
}
await interaction.reply({ content: 'Roles have been updated', ephemeral: true});
}
// Modal Handling
if (interaction.isModalSubmit) {
if (interaction.customId === 'modal-paidmember') {
const execchannel = client.channels.cache.get('981678376655921153');
if(interaction.customId == "miscSelect")
{
if(interaction.values.includes("courserep"))
{ interaction.member.roles.add("493738161713709077")}
else{interaction.member.roles.remove("493738161713709077")}
if(interaction.values.includes("ACWPing"))
{ interaction.member.roles.add("904354161561309184")}
else{interaction.member.roles.remove("904354161561309184")}
await interaction.reply({ content: 'Roles have been updated', ephemeral: true});
}
}
// Modal Handling
if(interaction.isModalSubmit) {
if(interaction.customId === 'modal-paidmember'){
const execchannel = client.channels.cache.get('981678376655921153')
const embed = new discord.MessageEmbed()
.setTitle("New Paid Member Request")
.setColor('GREEN')
.addField('Discord Tag', `${ interaction.user} <- Click to add role.`)
.addField('Discord Discriminator', `${interaction.user.tag}`)
.addField('Student Name', `${ interaction.fields.getTextInputValue("studentname")}`)
.addField('Student Number',`${ interaction.fields.getTextInputValue("studentnumber")}`)
.setDescription('https://hulluniunion.com/')
const row = new discord.MessageActionRow()
.addComponents(
new discord.MessageButton()
.setCustomId('deletemessage')
.setEmoji('')
.setLabel('Delete Message')
.setStyle('DANGER')
)
execchannel.send({embeds: [embed], components: [row] });
await interaction.deferReply({ ephemeral: true })
interaction.followUp({ content: 'Your request has been sent to execs!', ephemeral: true })
}
}
});
const embed = new discord.MessageEmbed()
.setTitle('New Paid Member Request')
.setColor('GREEN')
.addField('Discord Tag', `${interaction.user} <- Click to add role.`)
.addField('Discord Discriminator', `${interaction.user.tag}`)
.addField(
'Student Name',
`${interaction.fields.getTextInputValue('studentname')}`
)
.addField(
'Student Number',
`${interaction.fields.getTextInputValue('studentnumber')}`
)
.setDescription('https://hulluniunion.com/');
const row = new discord.MessageActionRow().addComponents(
new discord.MessageButton()
.setCustomId('deletemessage')
.setEmoji('')
.setLabel('Delete Message')
.setStyle('DANGER')
);
execchannel.send({ embeds: [embed], components: [row] });
await interaction.deferReply({ ephemeral: true });
interaction.followUp({
content: 'Your request has been sent to execs!',
ephemeral: true,
});
}
}
});

View File

@ -1,24 +1,23 @@
const client = require("../index");
require("dotenv").config();
const discord = require('discord.js');
const client = require('../index');
require('dotenv').config();
client.on("messageCreate", async (message) => {
client.on('messageCreate', async (message) => {
if (
message.author.bot ||
!message.guild ||
!message.content.toLowerCase().startsWith(process.env.PREFIX)
)
return;
if (
message.author.bot ||
!message.guild ||
!message.content.toLowerCase().startsWith(process.env.PREFIX)
)
return;
const [cmd, ...args] = message.content
.slice(process.env.PREFIX.length)
.trim()
.split(/ +/g);
const [cmd, ...args] = message.content
.slice(process.env.PREFIX.length)
.trim()
.split(/ +/g);
const command =
client.commands.get(cmd.toLowerCase()) ||
client.commands.find((c) => c.aliases?.includes(cmd.toLowerCase()));
const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));
if (!command) return;
await command.run(client, message, args);
});
if (!command) return;
await command.run(client, message, args);
});

View File

@ -1,6 +1,5 @@
const { glob } = require("glob");
const { promisify } = require("util");
const { Client } = require("discord.js");
const { glob } = require('glob');
const { promisify } = require('util');
const globPromise = promisify(glob);
@ -8,43 +7,41 @@ const globPromise = promisify(glob);
* @param {Client} client
*/
module.exports = async (client) => {
// Commands
const commandFiles = await globPromise(`${process.cwd()}/src/commands/**/*.js`);
commandFiles.map((value) => {
const file = require(value);
const splitted = value.split("/");
const directory = splitted[splitted.length - 2];
// Commands
const commandFiles = await globPromise(
`${process.cwd()}/src/commands/**/*.js`
);
commandFiles.map((value) => {
const file = require(value);
const splitted = value.split('/');
const directory = splitted[splitted.length - 2];
if (file.name) {
const properties = { directory, ...file };
client.commands.set(file.name, properties);
}
});
if (file.name) {
const properties = { directory, ...file };
client.commands.set(file.name, properties);
}
});
// Events
const eventFiles = await globPromise(`${process.cwd()}/src/events/*.js`);
eventFiles.map((value) => require(value));
// Events
const eventFiles = await globPromise(`${process.cwd()}/src/events/*.js`);
eventFiles.map((value) => require(value));
// Slash Commands
const slashCommands = await globPromise(`${process.cwd()}/src/slashCommands/*/*.js`);
// Slash Commands
const slashCommands = await globPromise(
`${process.cwd()}/src/slashCommands/*/*.js`
);
const arrayOfSlashCommands = [];
slashCommands.map((value) => {
const file = require(value);
if (!file?.name) return;
client.slashCommands.set(file.name, file);
const arrayOfSlashCommands = [];
slashCommands.map((value) => {
const file = require(value);
if (!file?.name) return;
client.slashCommands.set(file.name, file);
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
arrayOfSlashCommands.push(file);
});
client.on("ready", async () => {
const guild1 = client.guilds.cache.get("969944638498680872");
guild1.commands.set([]);
const guild2 = client.guilds.cache.get("427865794467069962");
guild2.commands.set([]);
// Register for all the guilds the bot is in
await client.application.commands.set(arrayOfSlashCommands);
});
if (['MESSAGE', 'USER'].includes(file.type)) delete file.description;
arrayOfSlashCommands.push(file);
});
client.on('ready', async () => {
// Register for all the guilds the bot is in
await client.application.commands.set(arrayOfSlashCommands);
});
};