#Multi server bot

80 messages · Page 1 of 1 (latest)

remote marsh
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

steady mortar
#

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 !!!

lofty quail
#

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

steady mortar
#

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

lofty quail
#

it sounds like you have server specific functionality in your code
which again, isn't the default
care to share some code?

steady mortar
#

"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!

lofty quail
#

that's fine

steady mortar
#

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

lofty quail
#
  1. 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
  2. this looks like v12 code, so please consider updating as v12 is no longer supported
  3. 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
ebon mothBOT
#

To share long code snippets use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks.

steady mortar
#

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

ebon mothBOT
#

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)

steady mortar
#

i feel stupid xd...

#

ok...

#

will my code still work?

#

its not big but still

lofty quail
#

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

steady mortar
#

thank you!

#

the intents?

ebon mothBOT
#

• Websocket intents limit events and decrease memory usage: learn more
• See what intents you need here

steady mortar
#

What are the message event that i need to modify in my code?

#

When i type Create after message, it does'nt show up.

lofty quail
steady mortar
#

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); ?

lofty quail
#

that is the name of your parameter
you can name that whatever you want

steady mortar
#

im a newbie in coding, even more in javascript

lofty quail
#

the name of the event is a string, where you do client.on(...)

steady mortar
#

oh yeah, its the const

#

so client.on('message', messageCreate =>{ instead of client.on('message', message =>{

lofty quail
#

no that's still the name of your parameter

steady mortar
#

bruhhh

lofty quail
#

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

steady mortar
#

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

steady mortar
#

is Discord.js v12 more limited than v14?

unkempt inlet
steady mortar
#

oh

#

i cant make my bot to talk now because of v14

unkempt inlet
steady mortar
#

my client constructor?

unkempt inlet
#

where u create ur client

steady mortar
unkempt inlet
#

u must’ve changed it by now right

#

when u updated

steady mortar
#

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

unkempt inlet
#

Okay ull need the MessageContent intent as well

steady mortar
#

after guild messages?

#

const client = new Discord.Client({ intents: ["Guilds", "GuildMessages", "MessageContent"] });

unkempt inlet
#

in any order in ur intents object, just both GuildMessages and MessageContent for message commands

#

tho it’s reccomended u utilize slash commands

steady mortar
#

its better?

#

i can

#

if i find how

#

wow

#

im soooo stupid. It worked

#

thanks...

unkempt inlet
#

np

ebon mothBOT
#

Suggestion for @steady mortar:
guide Creating Your Bot: Creating slash commands
read more