I'm trying to only allow people with the Staff role to run this command.
Basically what the command does, is allowing a bot to DM users
the command is <prefix>send #RandomUserName <message>
I am trying to prevent random users from abusing this command to flood other players DMs.
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (message.member.roles.cache.some(role => role.name === 'Staff')) return;
if (command === 'send'){
function getUserFromMention(mention) {
if (!mention) return;
if (mention.startsWith('<#') && mention.endsWith('>')) {
mention = mention.slice(2, -1);
if (mention.startsWith('!')) {
mention = mention.slice(1);
}
return mention;
}
}
const user = getUserFromMention(args[0])
let MessageDM = args[1]
client.users.cache.get(user).send(MessageDM);
}
// ...
});
You're missing a negation (!) in your role-check. Your current if only evaluates to true, when the role is present. But you want to return if the role is not present.
Change your line
if (message.member.roles.cache.some(role => role.name === 'Staff')) return;
to
if (!message.member.roles.cache.some(role => role.name === 'Staff')) return;
Also, as I mentioned in my comment, putting a function inside an if is never a good idea. I'd just put it into the upper scope:
function getUserFromMention(mention) {
if (!mention) return;
if (mention.startsWith('<#') && mention.endsWith('>')) {
mention = mention.slice(2, -1);
if (mention.startsWith('!')) {
mention = mention.slice(1);
}
return mention;
}
}
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (!message.member.roles.cache.some(role => role.name === 'Staff')) return;
if (command === 'send'){
const user = getUserFromMention(args[0]);
let MessageDM = args[1];
client.users.cache.get(user).send(MessageDM);
}
// ...
});
Related
I am trying to create a command that kicks people, unfortunately, it doesn't work and no errors in the console, when I type -kick without mentioning anyone, the expected message comes, but when I mention someone it doesn't kick them.
Here is my code in my command handler:
module.exports = {
name: 'kick',
decription: 'Kick command',
execute(message, args) {
if (!message.guild) return;
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.kick()
.then(() => {
message.reply(`Successfully kicked ${user.tag}`);
})
.catch(err => {
message.reply('I was unable to kick the member');
console.error(err);
});
} else {
message.reply("That user isn't in this guild!");
}
} else {
message.reply("You didn't mention the user to kick!");
};
}
}
EDIT: here is my main file code:
const Discord = require("discord.js");
const keepAlive = require("./server");
const client = new Discord.Client();
const prefix = ('-');
const fs = require('fs');
client.on("ready", () => {
console.log(`logged in as ${client.user.tag}`);
});
client.commands = new Discord.Collection();
const commandFiles = fs
.readdirSync('./commands/')
.filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.on('message', (message) => {
if(!message.content.startsWith(prefix) || message.author.bot)
return;
const args = message.content.slice(prefix.length).split("/ +/");
const command = args.shift().toLowerCase();
if (command === 'help') {
client.commands.get('help').execute(message, args);
} else if (command === 'clear') {
client.commands.get('clear').help(message,args);
} else if(command === 'ban') {
client.commands.get('ban').execute(message, args);
} else if(command === 'kick') {
client.commands.get('kick').execute(message);
} else if(command === 'mute') {
client.commands.get('mute').execute(message,args);
}
});
keepAlive();
client
.login("TOKEN")
.catch(console.error);
TypeScript has a feature that tells you if you declared an unnecessary variable (you never used the variable). You could remove it, or ignore it. Your code will work either way.
For example, using this code, TypeScript will tell you b is declared but its value is never read
const a = 1
const b = 2
console.log(a)
//b is not used anywhere except for the declaration
Why is your code not working?
You are using Guild.member. This relies on cache and is deprecated. Use message.mentions.members.first() instead to directly retrieve the member
const member = message.mentions.members.first();
args is not defined
This just means that the parameter args to your execute function is unnecessary here and you could remove it.
guild.member() does not exist, use guild.members.resolve(user.id) instead.
Also if you're just accessing a member of a guild, you should use message.mentions.members instead.
So in the end it would look something like this:
module.exports = {
name: 'kick',
decription: 'Kick command',
execute(message) {
if (!message.guild) return;
const member = message.mentions.members.first();
if (member) {
member
.kick()
.then(() => {
message.reply(`Successfully kicked ${member.user.tag}`);
})
.catch(err => {
message.reply('I was unable to kick the member');
console.error(err);
});
} else {
message.reply("You didn't mention a member to kick!");
};
}
}
I have solved this problem by editing my code a bit. I also moved the code from my command handler to my main file. Here is the code for anyone who needs it.
else if(message.content.startsWith("-kick")) {
message.content.split("-kick ")[1]
if (!message.guild) return;
const member = message.mentions.members.first();
if (member) {
member
.kick()
.then(() => {
message.reply(`Successfully kicked ${member.user.tag}`);
})
.catch(err => {
message.reply('I was unable to kick the member');
console.error(err);
});
} else {
message.reply("You didn't mention a member to kick!");
};
}
I only added the following piece of code:
message.content.split("-kick ")[1]
EDIT: I figured out what was wrong
const args = message.content.slice(prefix.length).split("/ +/");
I needed to remove the quotation marks at the end, so it is basically like this:
const args = message.content.slice(prefix.length).split(/ +/);
I've tried a few methods to stop people from pinging everyone but what i want is something where if the message has "#everyone" or "#here" i can make the bot reply a few different ways
here is my current code
const Discord = require ('discord.js');
const { FILE } = require('dns');
const client = new Discord.Client();
const prefix = ".";
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('IM ONLINE GUYS!!!');
});
client.on('message', message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/)
const command = args.shift().toLowerCase();
if(command === 'ping'){
client.commands.get('ping').execute(message, args);
} else if (command == 'pong'){
client.commands.get('pong').execute(message, args);
} else if (command == 'help'){
client.commands.get('help').execute(message, args, Discord);
} else if (command == 'kill'){
client.commands.get('kill').execute(message, args);
} else if (command == 'quote'){
client.commands.get('quote').execute(message, args);
} else if (command == 'kiss'){
client.commands.get('kiss').execute(message, args);
} else if (command == 'hug'){
client.commands.get('hug').execute(message, args);
} else if (command == 'pet'){
client.commands.get('pet').execute(message, args);
} else if (command === 'say'){
const sayMessage = message.content.split(' ').slice(1).join(' ');
message.channel.send(sayMessage);
} else if (command === 'music-h'){
client.commands.get('music-h').execute(message, args, Discord)
}
})
client.login('token')
and i am refering to the
} else if (command === 'say'){
const sayMessage = message.content.split(' ').slice(1).join(' ');
message.channel.send(sayMessage);
part
Im going to explain it better here: I am trying to make the bot respond with something else when someone pings #everyone or #here in their ".say" message
example:
".say #everyone"
"Nice try bub, its not gonna work with me"
and maybe a couple other responses along with that.
Yes of course!
if (message.content.includes('#everyone') || message.content.includes('#here')) {
message.channel.send('Nice try bub, its not gonna work with me')
Let me know if you need further help, cheers!
I've been making a discord bot recently with a few features, this bot has an advanced command handler and i was wondering how to make a command where the bot says what you tell it to.
example:
".say (message)"
bot responds with "(message)"
this is my command handler
const Discord = require ('discord.js');
const { FILE } = require('dns');
const client = new Discord.Client();
const prefix = ".";
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('alpha 0.2.9, IM ONLINE!!!');
});
client.on('message', message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/)
const command = args.shift().toLowerCase();
if(command === 'ping'){
client.commands.get('ping').execute(message, args);
} else if (command == 'pong'){
client.commands.get('pong').execute(message, args);
} else if (command == 'help'){
client.commands.get('help').execute(message, args, Discord);
} else if (command == 'kill'){
client.commands.get('kill').execute(message, args);
} else if (command == 'quote'){
client.commands.get('quote').execute(message, args);
} else if (command == 'kiss'){
client.commands.get('kiss').execute(message, args);
} else if (command == 'hug'){
client.commands.get('hug').execute(message, args);
} else if (command == 'pet'){
client.commands.get('pet').execute(message, args);
} else if (command == 'bruh'){
client.commands.get('bruh').execute(message, args);
}
})
client.login('no')
No tutorials exist on how to do this with an advanced command handler
right now the bot is for fun but i might make it into moderation.
Use a combination of String#split(), Array#slice() and Array#join()
else if (command === 'say') {
const sayMessage = message.content.split(' ').slice(1).join(' ');
message.channel.send(sayMessage);
}
So, recently i started making my own bot, Im not the most experienced person too, but I know a bit of what im doing. I went off the basic Discord.js index provided on Discord.js Guide, and just added my own code to it, without actually touching the command handler.
For some commands I wanted to have a perm level that only with that perm level
permlvl 1 = Manage Message
^ not actual code just an example, That way only users with that perm level can use it.
Here is my index.js At the moment.:
const Discord = require('discord.js');
const config = require('./commands/config.json');
const fs = require('fs');
const { dir } = require('console');
const client = new Discord.Client();
client.commands = new Discord.Collection();
const Fun = fs.readdirSync(`./commands/Fun/`).filter(file => file.endsWith('.js'));
for (const file of Fun) {
const command = require(`./commands/Fun/${file}`);
client.commands.set(command.name, command);
}
const General = fs.readdirSync(`./commands/General/`).filter(file => file.endsWith('.js'));
for (const file of General) {
const command = require(`./commands/General/${file}`);
client.commands.set(command.name, command);
}
const Information = fs.readdirSync(`./commands/Information/`).filter(file => file.endsWith('.js'));
for (const file of Information) {
const command = require(`./commands/Information/${file}`);
client.commands.set(command.name, command);
}
client.elevation = message => {
if (message.channel.type === 'dm') return;
let permlvl = 0;
if (message.member.hasPermission("MANAGE_MESSAGES")) permlvl = 1;
if (message.member.hasPermission("BAN_MEMBERS")) permlvl = 2;
if (message.member.hasPermission("MANAGE_GUILD")) permlvl = 3;
if (message.member.id === message.guild.ownerID) permlvl = 4;
if (message.author.id === config.devID) permlvl = 5;
return permlvl;
};
client.on("ready", () => {
console.log(`${client.user.tag} has started, with ${client.users.cache.size} users, in ${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.`);
client.user.setActivity(`Serving ${client.users.cache.size} users in ${client.guilds.cache.size} server.`, { url: 'https://www.twitch.tv/discordsstream', type: 'STREAMING' });
)};
client.on('message', message => {
if (!message.content.startsWith(config.prefix) || message.author.bot) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName)
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return;
if (command.guildOnly && message.channel.type === 'dm') {
return message.reply('I can\'t execute that command inside DMs!');
}
if (command.args && !args.length) {
let reply = `You didn't provide any arguments, ${message.author}!`;
if (command.usage) {
reply += `\nThe proper usage would be: \`${config.prefix}${command.name} ${command.usage}\``;
}
return message.channel.send(reply);
}
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
});
with the exception of my other client.on and some of the main code in client.on and stuff at the bottom. This is everything having to do with the command handler in the index, Here is the config in the actual commands:
module.exports = {
name: 'ping',
description: 'See the bots response time!',
usage: '',
guildOnly: false,
permLevel: 0,
aliases: ['responsetime', 'pong'],
execute(message, args, async) {
}
The thing is, It works with 0 errors when the command is run, But the permlvl doesnt work,
I tried adding it the the "say" command as only permlvl 1 which is
if (message.member.hasPermission("MANAGE_MESSAGES")) permlvl = 1;
but members could still use it. -- They dont have the permissions on their roles either.
I tried a few things with the config, I tried replacing it with AwesomeCommandHandler, in which that code it didnt work, So i reverted back. I searched a few discord.js sites, And some Stack Questions, but no where could I find the answer, itd be great if someone could help me, Either in finding the answer or giving it, Either way.
You also need to check if the user permLevel is higher or equal to the command one:
const Discord = require('discord.js');
const config = require('./commands/config.json');
const fs = require('fs');
const { dir } = require('console');
const client = new Discord.Client();
client.commands = new Discord.Collection();
const Fun = fs.readdirSync(`./commands/Fun/`).filter(file => file.endsWith('.js'));
for (const file of Fun) {
const command = require(`./commands/Fun/${file}`);
client.commands.set(command.name, command);
}
const General = fs.readdirSync(`./commands/General/`).filter(file => file.endsWith('.js'));
for (const file of General) {
const command = require(`./commands/General/${file}`);
client.commands.set(command.name, command);
}
const Information = fs.readdirSync(`./commands/Information/`).filter(file => file.endsWith('.js'));
for (const file of Information) {
const command = require(`./commands/Information/${file}`);
client.commands.set(command.name, command);
}
client.elevation = message => {
if (message.channel.type === 'dm') return;
let permlvl = 0;
if (message.member.hasPermission("MANAGE_MESSAGES")) permlvl = 1;
if (message.member.hasPermission("BAN_MEMBERS")) permlvl = 2;
if (message.member.hasPermission("MANAGE_GUILD")) permlvl = 3;
if (message.member.id === message.guild.ownerID) permlvl = 4;
if (message.author.id === config.devID) permlvl = 5;
return permlvl;
};
client.on("ready", () => {
console.log(`${client.user.tag} has started, with ${client.users.cache.size} users, in ${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.`);
client.user.setActivity(`Serving ${client.users.cache.size} users in ${client.guilds.cache.size} server.`, { url: 'https://www.twitch.tv/discordsstream', type: 'STREAMING' });
)};
client.on('message', message => {
if (!message.content.startsWith(config.prefix) || message.author.bot) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName)
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return;
if (command.guildOnly && message.channel.type === 'dm') {
return message.reply('I can\'t execute that command inside DMs!');
}
if (command.args && !args.length) {
let reply = `You didn't provide any arguments, ${message.author}!`;
if (command.usage) {
reply += `\nThe proper usage would be: \`${config.prefix}${command.name} ${command.usage}\``;
}
return message.channel.send(reply);
}
const userPermLevel = client.elevation(message);
const commandPermLevel = command.permLevel;
if(commandPermLevel > userPermLevel){
return message.channel.send('You do not have required permissions');
}
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
});
I would like to break up my following code into multiple files for management instead of having everything run on the main file. The whole code is located as one Node.js modal know as index.js I would like to break the code up into multiple files management.js and interantion.js and they communicate with node.js
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config.json");
const ms = require("ms");
client.on("ready", () => {
console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
client.user.setGame(config.game);
});
client.on("guildCreate", guild => {
console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
client.user.setGame(`on ${client.guilds.size} servers`);
});
client.on("guildDelete", guild => {
console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
});
client.on("guildMemberAdd", function(member) {
//Welcomes a user
member.guild.channels.find("name", "general").send("Please welcome " + member.toString() + " to the server! " + member.toString() + " Make sure to read the rules and enjoy your stay :heart:." + " https://imgur.com/a/pCcSm");
});
//managment
client.on("message", async message => {
if (message.author.bot) return;
if (message.content.indexOf(config.prefix) !== 0) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
var mutedrole = message.guild.roles.find("name", "muted");
//Managment
if (command === "say") {
if (!message.member.roles.some(r => ["Management"].includes(r.name))) return message.reply("Sorry, you don't have permissions to use this!");
const sayMessage = args.join(" ");
message.delete().catch(O_o => {});
message.channel.send(sayMessage);
}
if (command === "kick") {
if (!message.member.roles.some(r => ["Management"].includes(r.name))) return message.reply("Sorry, you don't have permissions to use this!");
let member = message.mentions.members.first();
if (!member) return message.reply("Please mention a valid member of this server");
if (!member.kickable) return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
let reason = args.slice(1).join(' ');
if (!reason) return message.reply("Please indicate a reason for the kick!");
await member.kick(reason).catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`);
}
if (command === "ban") {
if (!message.member.roles.some(r => ["Management"].includes(r.name))) return message.reply("Sorry, you don't have permissions to use this!");
let member = message.mentions.members.first();
if (!member) return message.reply("Please mention a valid member of this server");
if (!member.bannable) return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
let reason = args.slice(1).join(' ');
if (!reason) return message.reply("Please indicate a reason for the ban!");
await member.ban(reason).catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
}
if (command === "purge") {
if (!message.member.roles.some(r => ["Management"].includes(r.name))) return message.reply("Sorry, you don't have permissions to use this!");
const deleteCount = parseInt(args[0], 10);
if (!deleteCount || deleteCount < 2 || deleteCount > 100) return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
const fetched = await message.channel.fetchMessages({
count: deleteCount
});
message.channel.bulkDelete(fetched).catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
}
if (command == "mute") {
let member = message.mentions.members.first();
if (!member) return message.reply("Please mention a member");
let muteRole = message.guild.roles.find("name", "Muted");
if (!muteRole) return message.reply("Role: Muted not found.");
let params = message.content.split(" ").slice(1);
let time = args[1];
if (!time) return message.reply("Please specify how long the user should be muted.");
member.addRole(muteRole.id);
message.channel.send(`You've been muted for ${ms(ms(time), {long: true})}, ${member.user.tag}`);
setTimeout(function() {
member.removeRole(muteRole.id);
message.channel.send(`${member.user.tag} You were unmuted! The mute lasted: ${ms(ms(time), {long: true})}`)
}, ms(time));
}
//interaction
if (command === "ping") {
const m = await message.channel.send("Pong");
m.edit(`Fine here you go >.<! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
}
if (command == "drops") {
message.channel.send("https://docs.google.com/spreadsheets/d/1_SlTjrVRTgHgfS7sRqx4CeJMqlz687HdSlYqiW-JvQA/htmlview?sle=true#gid=0");
}
});
client.login(config.token);
The result look something like this:
index.js
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config.json");
const ms = require("ms");
client.on("ready", () => {
console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
client.user.setGame(config.game);
});
client.on("guildCreate", guild => {
console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
client.user.setGame(`on ${client.guilds.size} servers`);
});
client.on("guildDelete", guild => {
console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
});
client.on("guildMemberAdd", function(member) {
//Welcomes a user
member.guild.channels.find("name", "general").send("Please welcome " + member.toString() + " to the server! " + member.toString() + " Make sure to read the rules and enjoy your stay :heart:." + " https://imgur.com/a/pCcSm");
});
//managment
client.on("message", async message => {
if (message.author.bot) return;
if (message.content.indexOf(config.prefix) !== 0) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
});
client.login(config.token);
managment.js
//Managment
if (command === "say") {
if (!message.member.roles.some(r => ["Management"].includes(r.name))) return message.reply("Sorry, you don't have permissions to use this!");
const sayMessage = args.join(" ");
message.delete().catch(O_o => {});
message.channel.send(sayMessage);
}
if (command === "kick") {
if (!message.member.roles.some(r => ["Management"].includes(r.name))) return message.reply("Sorry, you don't have permissions to use this!");
let member = message.mentions.members.first();
if (!member) return message.reply("Please mention a valid member of this server");
if (!member.kickable) return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
let reason = args.slice(1).join(' ');
if (!reason) return message.reply("Please indicate a reason for the kick!");
await member.kick(reason).catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`);
}
if (command === "ban") {
if (!message.member.roles.some(r => ["Management"].includes(r.name))) return message.reply("Sorry, you don't have permissions to use this!");
let member = message.mentions.members.first();
if (!member) return message.reply("Please mention a valid member of this server");
if (!member.bannable) return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
let reason = args.slice(1).join(' ');
if (!reason) return message.reply("Please indicate a reason for the ban!");
await member.ban(reason).catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
}
if (command === "purge") {
if (!message.member.roles.some(r => ["Management"].includes(r.name))) return message.reply("Sorry, you don't have permissions to use this!");
const deleteCount = parseInt(args[0], 10);
if (!deleteCount || deleteCount < 2 || deleteCount > 100) return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
const fetched = await message.channel.fetchMessages({
count: deleteCount
});
message.channel.bulkDelete(fetched).catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
}
if (command == "mute") {
let member = message.mentions.members.first();
if (!member) return message.reply("Please mention a member");
let muteRole = message.guild.roles.find("name", "Muted");
if (!muteRole) return message.reply("Role: Muted not found.");
let params = message.content.split(" ").slice(1);
let time = args[1];
if (!time) return message.reply("Please specify how long the user should be muted.");
member.addRole(muteRole.id);
message.channel.send(`You've been muted for ${ms(ms(time), {long: true})}, ${member.user.tag}`);
setTimeout(function() {
member.removeRole(muteRole.id);
message.channel.send(`${member.user.tag} You were unmuted! The mute lasted: ${ms(ms(time), {long: true})}`)
}, ms(time));
}
interaction.js
//interaction
if (command === "ping") {
const m = await message.channel.send("Pong");
m.edit(`Fine here you go >.<! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
}
if (command == "drops") {
message.channel.send("https://docs.google.com/spreadsheets/d/1_SlTjrVRTgHgfS7sRqx4CeJMqlz687HdSlYqiW-JvQA/htmlview?sle=true#gid=0");
}
I have tried using a required method, but it gives me file not found error.
I'm not entirely sure how you could do this, possibly by using fs or something similar. You could, however, use commando.js rather than discord.js.
Commando.js has one index file for logging in and so on, and then each command is set up into different categories under folders and each command has its own file. It's certainly something to look into.