#Multi server bot
80 messages · Page 1 of 1 (latest)
What is this server? It's the support to make a discord bot on java script but no one never help me! I just get links all the time. I did nothing to make that, I don't know how!!! Thats my question! There is no issue !!!
I want to make my bot to work on multiple server
bots are not specific to a single server by default
they will receive events (depending on your intents) from all guilds
For exemple, is there is a Auto role command, on one server, the role Member is given and on another, Discorder
are you trying to ask how to add a role to a guild member in multiple servers at once?
How to "personnalize" my bot on different server?
this is a very vague and subjective question
if you have a more specific question, please elaborate 🙂
I just get links all the time. I did nothing to make that, I don't know how!!!
it's very likely you're receiving links to resources that explain how or otherwise refer to the tools/methods you should be using
thanks, that explain me more about what i need to precise.
i know i can have it on multiple server at once, i was'nt precise, sorry. I want to, for exemple, there is a fonctionality that block discord server link. On on server, my bot block it and another, it does'nt.
idk how to explain, its not my primary language, sorry
it sounds like you have server specific functionality in your code
which again, isn't the default
care to share some code?
"it sounds like you have server specific functionality in your code
which again, isn't the default" idk what you mean.
Of course, just a sec
**const Discord = require('discord.js');
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('Echoo est en ligne!');
});
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 === 'clear'){
client.commands.get('clear').execute(message, args);
}
else if(command === 'kick'){
if(message.member.permissions.has("KICK_MEMBERS")){
client.commands.get('kick').execute(message, args);
}
else(message.channel.send('You need the permission **kick members** to do that command.'))
}
else if(command === 'ban'){
if(message.member.permissions.has("BAN_MEMBERS")){
client.commands.get('ban').execute(message, args);
}
else(message.channel.send('You need the permission **ban members** to do that command.'))
}
});
client.login('**
i cut the token, you know why!
that's fine
i just got 4 commands for now and thats basics command that can't be "personnalized" for each server
for more advanced command, for exemple, reaction role, thats what i need
i think...
"Echoo est en ligne!" means 'Echoo is online!' in french (Echoo is my bot).
just for info
- in future, I'd recommend putting larger bits of code in a sourcebin or something similar (I'll have the bot send something below)
not really an issue for now, since this is in a thread - this looks like v12 code, so please consider updating as v12 is no longer supported
- I don't see anything guild specific in this code, so if you have a command that doesn't work in some servers, the issue would lie elsewhere
how do I know my version of discord.js? I dont have commands that dont work in some server, i want to make some. There is no issue, i wanted to know how to do it.
i thought i had the latest...
seams not
Version 14 has released! Please update at your earliest convenience.
• Update: npm rm discord.js npm i discord.js
• Update guide (use CTRL + F to search for the old method or property)
there are a few things you would need to change
for example in v13, it became required for you to declare intents specifically
and in v14, you'd want to use the enums for permission flags, such as PermissionFlagsBits.KickMembers
and the message event was renamed to messageCreate to fit the language discord uses
I can't see any of your other files, so I'm unsure what else you would need to upgrade
so I'd heavily suggest checking out the v12 -> v13 and v13 -> v14 upgrade guides
• Websocket intents limit events and decrease memory usage: learn more
• See what intents you need here
What are the message event that i need to modify in my code?
When i type Create after message, it does'nt show up.
what do you mean "it doesn't show up"?
could you share what you changed?
Im in Visual Code Studio and there is suggestion when I type. There is not Create.
im just not sure what are event ...
the event in my code, i know what are event
For exemple, do I need to put execute(messageCreate, args); instead of execute(message, args); ?
that is the name of your parameter
you can name that whatever you want
im a newbie in coding, even more in javascript
oh
the name of the event is a string, where you do client.on(...)
oh yeah, its the const
so client.on('message', messageCreate =>{ instead of client.on('message', message =>{
no that's still the name of your parameter
bruhhh
the string 'message' is the name of the event you're listening to
if you're new to javascript and coding in general, I'd heavily suggest learning the basics before continuing
#resources
ok, thanks
that's my ping command for exemple
**module.exports = {
name: 'ping',
description: "Ping command",
execute(message, args){
message.channel.send('Pong!');
}
}**
when i do *ping, there is no error, the bot wtill works the bot dont send messages. Dont worry, i will look more into java script, i just wanted to test it
is Discord.js v12 more limited than v14?
extremely
can u show ur client constructor?
my client constructor?
where u create ur client
well, here is my code for now
like one word
**const Discord = require('discord.js');
const client = new Discord.Client({ intents: ["Guilds", "GuildMessages"] });
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('Echoo est en ligne!');
});
client.on('messageCreate', 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 === 'clear'){
client.commands.get('clear').execute(message, args);
}
else if(command === 'kick'){
if(message.member.permissions.has("PermissionFlagsBits.KickMembers")){
client.commands.get('kick').execute(message, args);
}
else(message.channel.send('You need the permission **kick members** to do that command.'))
}
else if(command === 'ban'){
if(message.member.permissions.has("PermissionFlagsBits.BanMembers")){
client.commands.get('ban').execute(message, args);
}
else(message.channel.send('You need the permission **ban members** to do that command.'))
}
});
client.login('**
here
Okay ull need the MessageContent intent as well
after guild messages?
const client = new Discord.Client({ intents: ["Guilds", "GuildMessages", "MessageContent"] });
in any order in ur intents object, just both GuildMessages and MessageContent for message commands
tho it’s reccomended u utilize slash commands
np
Creating Your Bot: Creating slash commands