#development
1 messages · Page 902 of 1
you can, it's just wack
being explicit on array index is kinda bad when you want to edit the embed later on
There are methods like splice which can add an item at a specific index of an array.
i dont want to edit it tho lol
then use .push
dont tell me you never gonna edit the code later on?
no i'm not, why do i need to
when you need to
i don't need to
i honestly don't understand what's going on
Well, do you want the Permissions field at the end of the fields list or not?
you dont need to now, but later
ok, i'll just figure it out myself lol
lol ok so you wont fix it?
good luck with that
ping
"i need fix"
"here is fix"
"i dont want this fix"
i guess he's going to use array[6] =
oh no
nothing wrong with it lol
i guess
well, imagine if you were going to add an another field, then you would have to add that count
btw, why are you just using 6
why not array[array.count]?
ah yes, .Count()
i meant .length
i don't see how using .push would affect anything
it destroys his embed
Think the conversation is over, but you should genuinely be using .push. The method exists for this reason.
how?
how what
it destroys his embed
.push pushes everything away in the embed and just adds that one field /s
I still need help getting my custom prefix to execute commands
Anyone know how I would fetch a member within a guild when sharding?
I can't seem to get it working as all the ways I try return
"let member = guild.members.get(i);
^
TypeError: Cannot read property 'get' of undefined"
when trying to get the member
(discordjs)
when sharding, your guilds will be spit among shards
for example, at 2000 guilds and 2 shards, you will have approx 1000 guilds in one shard, and approx 1000 guilds in another shard (they are not split evenly)
so if you get a command from a channel in a guild in shard one, you cannot see guilds that are not in shard 1
It's not for a command
I've got a thing in the ready event that checks a file every so often and then gets the guild ID from the file which then I need to get a certain member from the guild
same thing applies
you get a guild id from the file, in one shard, but the guild is in the other shard
so I cant broadcast something among all shards?
yes you can
WHich is what I need help with doing
thats why broadcastEval exists
me doing this.guilds.cache.get isnt working for me.
exactly, you need to use broadcastEval
sorry
Again, I have it in a broadcastEval.
you didnt show your broadcastEval code
-botinfo 422087909634736160
422087909634736160
Discord Server List
8005
The official Discord bot for the Discord Server List!
discord.js
N/A
1642
4
No server count
@fossil oxide

@languid dragon 
@bitter sundial 
hey, i've got a warning command that writes te warning of a user in json file, the command looks like this :
if(!warns[message.guild.id]) {
warns[message.guild.id] = {}
}
if(!warns[message.guild.id][wUser.id]) {
warns[message.guild.id][wUser.id] = 0
}
warns[message.guild.id][wUser.id] = Math.round(warns[message.guild.id][wUser.id] + 1)
fs.writeFile("../warnings.json", JSON.stringify(warns), (err) => {
if (err) console.log(err)
});``` but when i restart the bot every warns are reset. Would anyone know how i could fix it ?
how do you load the warnings file?
this.client.shard.broadcastEval('this.guilds.cache.get(' + server + ')').then(results => console.log(results)).catch('Err: ' + console.error);
is the code I have for it.
@neat tinsel you cannot retrive complex data over broadcastEval
you need to find the correct server, find the correct member, and execute what you want to execute, all inside the broadcastEval
you can only retrive simple data from it, like primitives
(c), any idea why im getting an error?
#include <stdio.h>
#define CHAR_SIZE 30
#define animals 2
typedef struct animal animal;
struct animal
{
char type[CHAR_SIZE];
char name[CHAR_SIZE];
int age;
};
void scan(char* type, char* name, int* age);
int main(void)
{
animal animal1 = {"", "", 0};
scan(animal1.type, animal1.name, animal1.age);
getchar();
getchar();
return 0;
}
void scan(char* type, char* name, int* age)
{
printf("Please Enter Your Animal Type: ");
fgets(*type, CHAR_SIZE, stdin);
strtok(*type, "\n");
printf("%s", *type);
printf("Please Enter Your Animal Name: ");
fgets(*name, CHAR_SIZE, stdin);
strtok(*name, "\n");
printf("%s", *name);
printf("Please Enter Your Animal Age: ");
scanf("%d", age);
printf("%d",*age);
}
well what is the error
uh no sry
how to add a lot of emote quickly without having 100 lines of code? v11
what
this is the error, pretty sure its from the scan line(scan not scanf)
a loop
so @quartz kindle do you know why the json file is not saved ?
@hasty lotus there are a lot of ways a json file can get corrupt and/or reset, i'd need to see your full code
can we go dm ?
I usually do await msg.react("..")
but if for example I want to add a 10th it is long enough to write and especially not very optimized
just keep an array/list of your emojis and run a loop adding it (but with a rate limit)
d.js mostly handles rate limiting internally
for (const e of ['emoji', 'another emoji', 'anotha one']) {
await msg.react(e)
}```
that should work
my bot now triggers on every message
one of my bot is bugged in the event messageUpdate
:c
my bot send 15msgs
show code
@earnest phoenix ^
ok
client.on("messageUpdate", async (oldMessage, newMessage) => {
if(oldMessage.content != newMessage.content){ let count = await logs.obtener(oldMessage.guild.id);
//Obtenemos el nombre del canal donde se edito el mensaje
let nameChannel = newMessage.channel.name;
// Obtenemos el nombre del usuario que edito el mensaje
if (oldMessage.author.bot) return;
await snipedit.establecer(newMessage.channel.id, {
"author": newMessage.author.username,
"antes": oldMessage.content,
"despues": newMessage.content
})
let member = newMessage.member.displayName;
const embed = new Discord.RichEmbed()
.setTitle("**MENSAJE EDITADO**")
.setColor(0xff0000)
.setThumbnail(newMessage.author.displayAvatarURL)
.addField('Antes', oldMessage.content)
.addField('Despues', newMessage.content)
.addField('ID del mensaje', newMessage.id)
.addField('Link del mensaje',`[Link](${`https://discordapp.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.id}`})`)
.addField('Nombre del autor', newMessage.author.username)
.addField('ID del autor', newMessage.author.id)
.addField('Mencion del autor', newMessage.author)
.addField('Nombre del canal', oldMessage.channel.name)
.addField('ID del canal', oldMessage.channel.id)
.addField('Mencion del canal', oldMessage.channel)
.setTimestamp()
.setFooter(newMessage.guild.name, newMessage.guild.iconURL);
// enviamos un mensaje de información de la actualización de un emoji en un canal X
client.channels.get(count).send(embed)};
});
Hi so I have a thing that finds the channel in a server like '#memes-and-media' as a variable so I do ${channel} and it will show the channel '#memes-and-media' but if there's no channel named that, it says undefined. How would I make it so if that channel doesn't exist you get an error message saying that.
check if the channel exists
RangeError: Maximum call stack size exceeded```
I get this error when I run this code:
```js
const twitter = require("twitter")
class Stream{
constructor(client) {
super(client)
this.client = client
}
async run() {
this.client.guildData.find({ feeds: { $exists: true, $not: { $size: 0 } } }, function (err, feeds) {
if (err) throw new Error(err)
const data = new Array()
for (const feed of feeds) {
data.push(feed)
}
console.log(data)
})
}
}
module.exports = Stream;```
@summer torrent
as soon as my bot goes offline luca is like "OmG yOuR bOt Is OfF"
@summer torrent no trace?
how would i create a warn command? I've got a db
what would a db be needed for if its a warn command
you need it to store the warnings and stuff
oh like store a warning count?
i like !warn @officiallylost hi and then it'll warn me, then i do !modlogs @officiallylost or smthing and it'll show the reason, the moderator and the time etc
thats y u need a db
even if u dont want a modlogs command
p sure
cant you have all that sent to a channel?
what
you could just sent em to mod-log channels or smh and then when u do it yeah... its waaaay too complicated
msg.reactions == exists = false
well explained help: msg.reactions doesn't exists. and forEach loop cannot be ran on null/undefined item.
@pale vessel wdym
one of my bot is bugged in the event messageUpdate
:c
my bot send 15msgs
client.on("messageUpdate", async (oldMessage, newMessage) => {
if(oldMessage.content != newMessage.content){ let count = await logs.obtener(oldMessage.guild.id);
//Obtenemos el nombre del canal donde se edito el mensaje
let nameChannel = newMessage.channel.name;
// Obtenemos el nombre del usuario que edito el mensaje
if (oldMessage.author.bot) return;
await snipedit.establecer(newMessage.channel.id, {
"author": newMessage.author.username,
"antes": oldMessage.content,
"despues": newMessage.content
})
let member = newMessage.member.displayName;
const embed = new Discord.RichEmbed()
.setTitle("**MENSAJE EDITADO**")
.setColor(0xff0000)
.setThumbnail(newMessage.author.displayAvatarURL)
.addField('Antes', oldMessage.content)
.addField('Despues', newMessage.content)
.addField('ID del mensaje', newMessage.id)
.addField('Link del mensaje',`[Link](${`https://discordapp.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.id}`})`)
.addField('Nombre del autor', newMessage.author.username)
.addField('ID del autor', newMessage.author.id)
.addField('Mencion del autor', newMessage.author)
.addField('Nombre del canal', oldMessage.channel.name)
.addField('ID del canal', oldMessage.channel.id)
.addField('Mencion del canal', oldMessage.channel)
.setTimestamp()
.setFooter(newMessage.guild.name, newMessage.guild.iconURL);
// enviamos un mensaje de información de la actualización de un emoji en un canal X
client.channels.get(count).send(embed)};
});
stack trace
@pale vessel https://nmw03.is-inside.me/7HbHHU0q.png
try looking into those files and see what's wrong
What is guildData?
any help????????????????
Lil marcrock can you show more of your code
as in the file
also, instead of doing the [link](httos:..)
ok
const snipedit = new db.crearDB("snipeedit");
if(command === 'snipeback'){
if (!snipedit.tiene(message.channel.id)) { //Primero se verifica si el canal tiene algún mensaje borrado guardado en la DB o no.
message.channel.send("No hay mensaje recien editados en este canal.")
} else { //En caso contrario que si hay un mensaje borrado va mandar el snipe
var snipauthor = await snipedit.obtener(`${message.channel.id}.author`) //obtenemos el autor
var snipantes = await snipedit.obtener(`${message.channel.id}.antes`)
var snipdespues = await snipedit.obtener(`${message.channel.id}.despues`)//obtenemos el mensaje
let embed = new Discord.RichEmbed()
.setTitle('Sniped')
.addField(snipauthor, `Antes: ${snipantes}\n Despues: ${snipdespues}`)
.setColor(0xff0000)
.setThumbnail('https://media.tenor.com/images/9d727051bcfc50c615121bac07be6e9a/tenor.gif')
message.channel.send({ embed })
}
}
event: https://discordapp.com/channels/264445053596991498/272764566411149314/705827043689890184
@sudden geyser
I can't read a lot of what the code does because it's in a different language but does the number of times the messages get sent increase over time, or does it stay at 15
if it's gradually increasing you may be nesting events
so, what is the problem?
What version of Discord.js are you using @woven sundial
fetchMessages in v11 returns a promise resolving into a collection of messages. It's not meant to fetch a single message. That's what fetchMessage is for.
Not only that, fetchMessages does not include the list of reactions as it has to be fetched manually.
remove the s
i // the if
@earnest phoenix nvm that
the but is bugged
how i can reload a event?
you save the file and restart your app or you remove the event (removeListener) and add it back
@woven sundial do you happen to know what part of your code is triggering the error?
i put this in the event onready
js snipe.purgeall() snipedit.purgeall()and work, lol
That wasn't directed at you. That was to Lil Marco.
I've been skimming your code as it's hard to read, but does this look right?
const editableMessageID = messagePosted[msgID].psm
channel.fetchMessages(editableMessageID).then((message) => {
It's confusing to read as you don't define it anywhere except the bottom of your code. You also say you're using v11.5.1 but you have MessageEmbed at the bottom of your code.
Im making a snipe command, what would be the best amount of chached messages? 1000?
Allow who has ADMINISTRATOR permission to send embed message from my bot will cause thing to my bot ?
If they shared something illegal for example
Shit the event is buggedddsssdss
discord.js. I missed something?
Take screenshot for your code in BSB.js that do import to excute function @iron scroll
u have way more of ur code to fix lmao
you have a trailing comma
you are trying to use template literals in a normal string
sam ur just gonna ignore the issues and go for the unnecessary trailing comma that doesnt even cause an error
also somehow u arent passint message properly
what does your message event code look like
@mossy vine triggering
also u have an unused variable 
I wanted to make cooldown command per user please help me in dm
and what happened
No responding
and whats ur code
@knotty steeple can talk in dm?
no
Ok
Sammy
const cd = require("./cooldown.json");
const Discord = require("discord.js");
const client = new Discord.Client();
const prefix = "p!";
//LOGIN
client.login("TOKEN");
client.on("message", message => {
//RETURN IF USER IS A BOT
if (message.author.bot) return;
//GETTING CURRENT MILLISECONDS
let date = new Date().getMilliseconds();
//CHECKING IF USER CAN USER THIS COMMAND
let canUse;
if (cd[String(message.author.id)] !== undefined) canUse = (cd[String(message.author.id)] >= 21600000);
else canUse = true;
if (message.content.toLowerCase() === `${prefix}credits` && canUse && String(message.author.id) !== "460690666964385803" /*YOU*/) {
if (!canUse) {
message.channel.send("You can only use this command one time in 6 Hours");
return;
};
var numbers = [
"You have recieved 5 credits for Pokecord Bot\n\nYour reddem code is ||NwEf||\n\nDM ULTRON#4070 to recieve your gift with reddem code",
"You have recieved 10 credits for Pokecord Bot\n\nYour reddem code is ||FtwK||\n\nDM ULTRON#4070 to recieve your gift with reddem code",
"Better Luck Next time try again in 6 hours",
"Better Luck Next time try again in 6 hours",
"Better Luck Next time try again in 6 hours",
"You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is ||TraW||\n\nDM ULTRON#4070 to recieve your gift with reddem code"
];
var answer = numbers[Math.floor(Math.random() * numbers.length)];
var embed = new Discord.MessageEmbed()
.setColor("#FF4500")
.setTitle("Pokécord Credits")
.setDescription(answer);
message.channel.send(embed);
//ADDING THE USER TO THE FILE
cd[String(message.author.id)] = date;
client.on("ready", () => {
console.log("Bot was logged in"); // Output a message to the logs.
});```
Here is code
if(command === 'snipeback'){
if (!snipedit.tiene(message.channel.id)) { //Primero se verifica si el canal tiene algún mensaje borrado guardado en la DB o no.
message.channel.send("No hay mensaje recien editados en este canal.")
} else { //En caso contrario que si hay un mensaje borrado va mandar el snipe
var snipauthor = await snipedit.obtener(`${message.channel.id}.author`) //obtenemos el autor
var snipantes = await snipedit.obtener(`${message.channel.id}.antes`)
var snipdespues = await snipedit.obtener(`${message.channel.id}.despues`)//obtenemos el mensaje
let embed = new Discord.RichEmbed()
.setTitle('Sniped')
.addField(snipauthor, `Antes: ${snipantes}\n Despues: ${snipdespues}`)
.setColor(0xff0000)
.setThumbnail('https://media.tenor.com/images/9d727051bcfc50c615121bac07be6e9a/tenor.gif')
message.channel.send({ embed })
}
}
event: https://discordapp.com/channels/264445053596991498/272764566411149314/705827043689890184
whats the problem
How to define talkedrecently
@valid frigate
if (talkedRecently.has(message.author.id)) {
Ok i got it
//RETURN IF USER IS A BOT
if (message.author.bot) return;
if(message.content.toLowerCase() === `${prefix}credits`) {
var numbers = ["You have recieved 5 credits for Pokecord Bot\n\nYour reddem code is ||NwEf||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 10 credits for Pokecord Bot\n\nYour reddem code is ||FtwK||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this", "Better Luck Next time try again in 6 hours", "Better Luck Next time try again in 6 hours","Better Luck Next time try again in 6 hours","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is ||TraW||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is TraW\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this"
];
var answer = numbers[Math.floor(Math.random()*numbers.length)];
var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Pokecord Credits**").setDescription(answer)
message.channel.send(embed)
if (talkedRecently.has(message.author.id)) {
message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
} else {
// the user can type the command ... your command code goes here :)
// Adds the user to the set so that they can't talk for a minute
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 60000);
}
}
})```
I have used these codes for cooldown
But it is showing like this
well, thats cause you are sending 2 messages
your message.channel.send(embed) is right before the if statment you use to check if the user has spoken or not
that should be after the else{
are you sure?
if you restart the bot, then the cooldown wont happen if you don't the command twice
yes
Ok
Heroku
but it is not possible for meXD
i m on glitch
it is, u just to add a credit card and thats all u dont have to spend money
Can anyone help me with this? I want to make a BOT of music which also has more commands, memes, ping, all that. So, I want to make "VIP" commands which are activated with a "! Claim" code "" And I want the bot to put it in the VIPS list, the code is activated by the bot automatically, and, if I need more codes I put "! code" numbercodes "" and it sends them to the MD. I dont know how to code the "!claim" Command.
no
no
exactly
proven yourself wrong lol
btw i have coded it like that it gets ping in every 5mins
I dont mind the restarts i use the heroku database to save stuff
rip i guess :V
easy, just host a database too
I want that i could use that command anytime but others need to wait 6 hrs
@turbid bough
just compare the author id with your id
@turbid bough how?
nah
(message.author.id) !== "460690666964385803"
Like this?
Ok so where to paste it?
if (message.content.toLowerCase() === `${prefix}credits` && canUse && (message.author.id) !== "460690666964385803"
Like this?
no
why String() ?
if (message.content.toLowerCase() === `${prefix}credits` && canUse && message.author.id !== "460690666964385803"
Now?
you don't need to surround it with ()
i meant on the last if statement*
that will only make it so you cant execute it
else canUse = true;
yeah but you used &&
no
here is how i would do it
if(message.content.toLowerCase() === `${prefix}credits`) {
var numbers = [""];
var answer = numbers[Math.floor(Math.random()*numbers.length)];
var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Pokecord Credits**").setDescription(answer)
message.channel.send(embed)
if (talkedRecently.has(message.author.id)) {
message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
return;
}else if(message.author.id != 460690666964385803){
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 60000);
}
message.channel.send(embed)
}```
ok
LoL
if (talkedRecently.has(message.author.id)) {
message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
return;
}else if(message.author.id != 460690666964385803){
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 60000);
}```
that will make it so you wont have any timeout
It would be much easier to make a rate limit system by making commands modular // command handler.
if(!usersBypass.has(message.author.id))
@turbid bough but
}else if(message.author.id != 460690666964385803){
// Adds the user to the set so that they can't talk for a minute
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after 6 hours
talkedRecently.delete(message.author.id);
}, 21600000);
}
}
})```
i have done thi
this
and someone is typing anything it occurs
the ID of a user is always going to be a string
@turbid bough then where it should be
@turbid bough should i paste your codes after message.channel.send(embed)
Ok
hes learning
Strict comparison is usually considered over loose comparison (===). When you have a number that large in JS and try to compare it, some of the ending digits become rounded.
Like 460690666964385803 became 460690666964385800
oh right, i did notice that sometimes it would do that
LoL
// Adds the user to the set so that they can't talk for a minute
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after 6 hours
talkedRecently.delete(message.author.id);
}, 21600000);
}
}
})```
Where i have to put my id in these codes
i am not clear
did you read this message?
https://canary.discordapp.com/channels/264445053596991498/272764566411149314/705868828978184194


yup
then read it again

but error comes
// Adds the user to the set so that they can't talk for a minute
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after 6 hours
talkedRecently.delete(message.author.id);
}, 21600000);
}
}
})```
tell me here where i have to put it
why is that message.channel.send(embed) still there?
coz these have no error
did you even read the message

idk, you say you have error but i dont see it anywhere you send it
i only see the embed and the timeout adding
tell us the error
👀
if (talkedRecently.has(message.author.id)) {
message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
return;
}else if(message.author.id != 460690666964385803){
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 60000);
}
message.channel.send(embed)
}```
Codes!
@turbid bough ?? whats the mistake
idk, might be an error from another part of the file?
can you send the whole file?
@sudden geyser 👀 its true https://img.thaun.dev/1nrxk.png
wait
javascript is so stupid
no u
lol
where is line 71?
ah nvm
Ohh
on line 35
heyo, how can i change my bots presence so it switches between two games every 30 seconds or so?
.then(console.log)
.catch(console.error);```
What should i put in place of then ?
?
is the code right ?
@earnest phoenix
console.log("Bot was logged in"); // Output a message to the logs.
});```
Maybe this
what you want to do?
for warns/bans/kicks/mutes
then after an if statement wont work
Ohh
@turbid bough and how should i do the code?
you remove then ?
its true
yeah
@turbid bough yes
hi, hoping someone can help me here but I am trying to list a promise for csgo stats but it gets cut off. I am using Windows powershell 7 for this. How can I view the entire list?
nvm - got it, parse into json and then list array of names
require("fs").writeFileSync("./result.json", jsonData);
I always get that error in the logs after i run certain command.
Does anyone know why?
It says this in the logs:
I don't know if i need to change something.... or if its ok.
wherever you're doing commandFile.run(), you're doing it on a command that has no .run() function
if (!commandfile) return;
commandfile.run(client, message, args);
}
};
@quartz kindle ^
So do i add () to the end of commandfile.run?
no
that code is correct
the problem is that the command you're using has no run function
@quartz kindle tim
i need ur big brain real quick
cause idk
should I have functions for each section
e.g. getGeneralSection(), getXSection()
or
getSection(sectionName)
personal preference?
My boat log error
At timeout.client.setTimeout (/rbd/pnpm-volume/437b153a-b0c4-4ced-947e-2129d4329dfb/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/ClientManager.js:40:57)
at Timeout.setTimeout [as _onTimeout] (/rbd/pnpm-volume/437b153a-b0c4-4ced-947e-2129d4329dfb/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/Client.js:436:7)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5) at Timer.listOnTimeout (timers.js:290:5)
(node:3202) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:3202) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
Pls help me
Are you using glitch? @prisma locust
yes @split hazel
Discord bans some glitch ip's for abuse. While your bot might've not necessarily abused the API, others may have on that ip which caused the ban
Glitch has a thread for this I believe
Hey guys I have some server questions.
I am attempting to migrate hosts, currently I pay for the Digital Ocean $15 2 vCore 2gb of RAM plan.
I would like to move to a stronger system, we are running into lag issues with this one and I kinda wanna pick a new one due to the demand the bot is using. What host should I aim for or should I go straight dedicated?
How many guilds? And what's your average memory usage
what lib 
wanted to add that
DiscordJS / DiscordJDA / 1500 Guilds / 80k Users / avg RAM usage is like 1GB
why both jda and js?
A couple different bots but they are small so it doesnt matter much
well im using galaxygate and im satisfied with it
but my bot its extremely optimized
I'll take a look
tim speaks for me 
@quartz kindle they're kinda sold out lmao
oh ok.
i wanna start using intents but the lib is outdated on my side, and too many breaking changes to fix
lmao
they have a stock role tho so you'll get pinged when they're back
(if you join and ask for it)
obviously if it becomes mandatory (which i think it will) then i'll have to put in effort
over 50 files so its not gonna be fun
rip
I just use intellij refactor
What plan do you guys use?
for GG?
i use the $3 one
Yea
I use the $10 one
how many guilds / users do you server?
about 3000 guilds for me
around 2.5k for mine
around 18k for mine (almost 19)
@earnest phoenix ^^^
memory usage isn't very kind
you guys can get more than verified
yes with your cool modified lib 
i might migrate to use yours if i get the time
Yeah mine is pretty quick, I just think its something to do with being shared on DO
or i'll make my own memory efficient lib based on yours 
🍴
if you wait a month or two, you can try using my next lib
👀 fancy
i will need testers and contributors
Me, I'd be down haha
why not sounds epic
How can I stack these on top of each other?
Yes
^
if you're using .map join it with \n
if it's an array of command you can join by doing array.join('\n')
for example: "abc\nxyz" becomes
abc
xyz
yup
\n
can I put the `` on the outside of that?
you can do "candy,\ncuddle,\netc..."
I'm not sure how to make it so my bot can respond to commands with spaces
you can as well
because if I use if(command === "help 2") { it doesnt work
only without space
anyone know the solution?
how do you define command?
Correct??
Ok
let prefix = "-";
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ + /g);
const command = args.shift().toLowerCase();
and then the command part
you split the message into words
so help would be one word, 2 would be another word
2 would be counted as args[0]
so args[2].shift() ?
so you need to do some if nesting
no
just this
if(command === "help"){
if(args[0] === "1") {
} else if(args[0] === "2") {
}
}```
etc
or use a switch case
Yeah, Fixed. Thanks!
not working
if(command === "help 2"){
if(args[0] === "1") {
message.channel.send("hello")
} else if(args[0] === "2") {
message.channel.send("hello2")
}
}
});
I mean like I need spaces in my commands
because I can do it normally but doesnt work with spaces
done
done
now it should work
also, consider using switches
@quartz kindle still doesnt
show full code
my problem is that I have a custom prefix command, The custom prefix works but I'm unable to change it. It gives me execute as undefined, here's the code for said command```const Discord = require('discord.js');
const Keyv = require('keyv');
const prefixes = new Keyv('I am kinda dumb');
const config = require('../config');
const globalPrefix = config.globalPrefix;
module.exports = {
name: 'prefix',
description: 'changes server-wide prefix',
execute: async (message, args) => {
if (args.length) {
await prefixes.set(message.guild.id, args[0]);
return message.channel.send(`Successfully set prefix to \`${args[0]}\`:sc3:`);
}
return message.channel.send(`Prefix is \`${await prefixes.get(message.guild.id) || globalPrefix}\``);
}
}```
which part doesnt work?
if (command === "help") {
if(args[0] === "2") {
message.channel.send("hello2")
} else if(args[0] === "3") {
message.channel.send("hello3")
}
}
});
I changed the split too
when you give it a new prefix, does it set it successfully? or does it throw the error?
@royal portal that part is correct, show more
the part if (args.length)
so if I do help 2 it should work?
but if its a command so only members with that role can use then would the message.member.roles.cache.some be after the if(args[0] === "2") { or before it?
@quartz kindle gives back cannot read property 'execute' of undefined
viewing it works, setting it gives error
your problem is likely elsewhere, not there
in the code that calls the execute function
would you like to see the main file?
@royal portal it would be after yes, first you need to figure out which command the user wants, then you check for permissions and what not
yes
bot.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}
bot.on('debug', console.log);
bot.once('ready', () => {
console.log('Bot Started With No Errors');
bot.user.setPresence({
activity: {
name: 'Crying Without Knowing Why | chelp to Start'
},
status: 'idle'
})
})
bot.on('message', async message => {
if (message.author.bot) return;
const args = message.content.slice(globalPrefix.length).split(/\+/);
const commandName = args.shift().toLowerCase();
const command = bot.commands.get(commandName) ||
bot.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (message.content.startsWith(globalPrefix)) {
prefix = globalPrefix;
} else {
const guildPrefix = await prefixes.get(message.guild.id);
if (message.content.startsWith(guildPrefix)) prefix = guildPrefix;
}
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.channel.send('there was an error trying to execute that command!');
if (typeof execute !== 'undefined') {}
if (!message.content.startsWith(guildPrefix)) return;
}
})
bot.login(token);```
@earnest phoenix your split is also wrong
wym add an s?
/ +/ splits on regular spaces
/\s+/ splits on all kinds of spaces
the + makes it treat consecutive spaces as a single space
show full code
hey would anyone know an open source starboard with djs 11 or 12 that i could use ?
or just take example on
^^
@royal portal like you pp :p
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = "!"
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', message => {
let prefix = "!";
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command === "help") {
if (!message.member.roles.cache.some(role => role.name === 'allowed')) return;
if(args[0] === "two") {
message.channel.send("helptwo")
} else if(args[0] === "three") {
message.channel.send("helpthree")
}
}
});
client.login('token');
what is the pblm with this code ?
with what code
yep
?
https://github.com/1Computer1/hoshi @hasty lotus
@royal portal you didnt fix your split
yes
yes
Umm can i ask a question in here?
sure
How can I create a bot?
Ok
Im there
Do I have to install the app?
Because if so, imma try it not now
you need basic knowledge of programming
start by learning the basics of a programming language
Im good at programming
bots can be done with many programming languages
do you have experience with any particular language?
Python?
sure
A little bit
intents are easy
lmao
if(message.content.startsWith(prefix + 'poll')){
if(message.author.bot) return;
if(!args[0]) return message.reply("please include a question for the poll")
message.channel.send(
new Discord.RichEmbed()
.setTitle(`${message.author.username}'s poll`)
.setColor("#FF0000")
.setDescription("poll")
.addField("question", args[0])
).then(message.react("👍"), message.react("👎"))
}
It reacts to the command not to the embed
because message is the message sent by the user
How could I get it to react to the embed?
since .send returns a promise of the sent message, you can do ```js
.then(msg => {
// Whatever you want to do with msg.
})
make sure to do await msg.react()
so they get added in a specific order
Why await?
if not it'll get added in whatever order
np
hey, i'm making a reset server command, that deletes every channels and every roles, and i would like to do a kind of verification, so for the moment the code is like that :
msg.reply("Doeing this will erase every channels and every roles of your server. Type /resetconfirm to confirm")```
Would you know how i could do this ?
d.js?
channel.awaitMessages()
^
yes but after the await ?
they give an example
ok thx
the easier way is always whichever language you're the most comfortable with
are you jumping into coding or learning it before hand
you should be doing the latter
and then start coding
Im not the best in enhlish sry
if you already know a little python, stick with python, unless you actually want to learn a different language from scratch
if(message.author.bot) return;
if(!args[0]) return message.reply("please include a question for the poll")
message.channel.send(
new Discord.RichEmbed()
.setTitle(`${message.author.username}'s poll`)
.setColor("#FF0000")
.setDescription("Poll")
.addField("question", args[0])
).then(msg => {
await msg.react("👍"), msg.react("👎")
})
}
``` await only able to be used I. A async function?
Ifk anything about python
you can do
How would I fix that?
Idk*
[WS => Manager] Manager was destroyed. Called by:
Error: MANAGER_DESTROYED?
in you message event
@earnest phoenix do you know any other language besides python?
Umm i am good in html
and it should allow you
uh, I think I destroyed my ws manager
@earnest phoenix do you know basic javascript? javascript is user a lot together with html
No idk javaskript but imma look on google
Thank
how did you accomplish that? lmao
constantly changing the already good code
in my mind it was like, yea this code is good, but lets make it better
well, thats a good mindset for a programmer to have, it will help you learn faster
but to someone who has a better understand of javascript would think my thought process is yea this code is good, lets make it not work anymore : D
yes but you learn by making mistakes
better be like that than using a lot of bad code just because "it works"
Error: MANAGER_DESTROYED
gonna check all my code right away
none in my main file
Ok Javascript looks definezly easier
Thx @quartz kindle
py is way simpler
my token is invalid
my opinion at least
ok so
@quartz kindle the error is back https://gist.github.com/IF64/1753e819ce2ff60a354c51817dfc1e7f
if i dont provide the guild presences in intents, will i still have access to guild members as normal?
yes, you need presences if your bot relies on user's statuses
How do I make a bot say something different at a different time of day? (Discord.js)
no i mean
i dont care about presences
if i dont provide the guild presences in intents, meaning i dont recieve presence packets, will i still have access to guild members as normal?

Okay, I have this issue where whenever I play music using the play command everything works until I make the bot leave using the leave command which works but when after I run leave I try running play but it only sends the embed and not join vc and play music. leave.js: https://sourceb.in/bbbb69758f, play.js: https://srcb.in/88771e5df8.
are you using v12
or v11
yes
v12
if i dont provide the guild presences in intents, meaning i dont recieve presence packets, will i still have access to guild members as normal?
@grizzled raven I said yes
nah but you said if my bot relies on user statuses, which wasnt my question
my bot doesnt rely on them
you need to have the server members privileged intent if you want to be able to download all members of the guild
otherwise the only users you receive are the ones in GUILD_CREATE
hello does anyone know how to make my bot ignore a channel?
compare the the message channel's id against the channel id you want to ignore
Ok
Does anyone know any good images or videos for discord.js to show me how to grab images from apis
use axios or node-fetch
Videos or articles*
Thsnkvyou
or you can use the built in http/s package
ew
yeah see thats what i initally though
t
but
this
TIP
GUILD_PRESENCESis required in order to receive the initial GuildMember data. If you do not supply it your member caches will be empty and not updates, even if you do provideGUILD_MEMBERS! Before you disable intents think about what your bot does and how not receiving the listed events might prevent it from doing this. Version 12 of discord.js does not yet fully support any combination of intents without loosing seemingly unrelated data.
that was just something to make me confused xdd
actually wait that wasnt really answered
if i dont subscribe to the guild presences intent, will i still have access to guild members as normal?
well uhh, my prefix command won't execute and of my commands, but I can change my prefix. here's my code: ```const Discord = require('discord.js');
const Keyv = require('keyv');
const prefixes = new Keyv('im dumb don't mind this, you saw nothing');
const config = require('../config');
const globalPrefix = config.globalPrefix;
module.exports = {
name: 'prefix',
description: 'changes server-wide prefix',
execute: async (message, args) => {
const member = message.member;
if (!message.member.hasPermission('MANAGE_GUILD')) {
return message.channel.send("You can't use this command, You don't have the permission :sc1:")
}
if (args.length) {
await prefixes.set(message.guild.id, args[0]);
return message.channel.send(`Prefix Is Now \`${args[0]}\` :sc3:`);
}
return message.channel.send(`Prefix is \`${await prefixes.get(message.guild.id) || globalPrefix}\``);
}
}```
Could someone give me an example of how to make my bot delete a message with a message inside it without being at the beginning or end?
Erm are you suppose to be leaking your mongo key and url stuff... @earnest phoenix
nice
better change the credentials
how I do dat

mhm
Heroku? 
yes
bot.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}
bot.on('debug', console.log);
bot.once('ready', () => {
console.log('Bot Started With No Errors');
bot.user.setPresence({
activity: {
name: 'Crying Without Knowing Why | chelp to Start'
},
status: 'idle'
})
})
bot.on('message', async message => {
if (message.author.bot) return;
const args = message.content.slice(globalPrefix.length).split(/\+/);
const commandName = args.shift().toLowerCase();
const command = bot.commands.get(commandName) ||
bot.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (message.content.startsWith(globalPrefix)) {
prefix = globalPrefix;
} else {
const guildPrefix = await prefixes.get(message.guild.id);
if (message.content.startsWith(guildPrefix)) prefix = guildPrefix;
}
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.channel.send('there was an error trying to execute that command!');
if (typeof execute !== 'undefined') {}
if (!message.content.startsWith(guildPrefix)) return;
}
})
bot.login(token);```'
my custom prefix command
at Client.<anonymous> (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\bot.js:48:21)
at processTicksAndRejections (internal/process/task_queues.js:97:5) ```
only thing I really like about heroku is that it updates with yout github commits
if i fetch
if i fetch a message with message.fetch(), does the message automatically update or do i redefine it?
async (message) => {
if (message.partial) await message.fetch()
// or...
if (message.partial) message = await message.fetch()
}
try the first
is that like a try it and see or are you certain
cause like
actually well they could just patch
yeah nvm
i'm not sure generally lol
each lib does it diff
looks like the second one (in d.js anyways)
message = await fetch sounds like the right way
it does
although first way looks cooler 
i'll just be safe
and go with the second one
want to be extra cool? make a global function called f that returns the result of fetch
no thanks

wait
also no offence cry, dont cry 
well i wouldnt do r.users.cache = await r.users.fetch(), would i 
but eh
speaking of, if i fetch a reaction, what gets fetched with it? like do i fetch the message seperatly too and the
the
nevermind
discord doesn't return the message object when fetching the reaction
don't know how d.js handles it
nah im stupid, yeah i fetch the message seperatly
im actually leaning towards thinking we dont need to reassign when fetching
let me dig deep
Is. There anyway I could send a message to a user like ^send @userrr hi and it send a DM to that person that was mentioned
the mention won't do anything if you're already sending the dm by the way
anyways
what's your lib
Discord.js
Well I would want to send the DM to the mentioned person
In case I need to
keep in mind that this method will fail if the user either
a) doesn't share a guild with your bot
b) has dms disabled
Well I would implement a method that checks if their DMS are open of not say they aren't right?
you can't check that but sending them a message
Oh
would there be a point where fetching a reaction fails?
it's been removed
it's been removed, the message has been removed or the bot lost perms to read message history iirc
ok if you fetch a reaction in the reaction remove event, its not fully removed until the last person removes the reaction, right?
correct
so fetching the reaction always works, until the last person removes the reaction
meaning that there is always a slight chance that fetching the reaction isnt possible 
guess i should jst
yeah i'll just ignore it
there's also times when discord is having a stroke and the fetch will spit out a 500
wait i should actually log the error code instead of the path
or both but eh
one time i decided to log the ratelimits like any other error
yeah bad idea
i only log ratelimits when i cross a global one e.g IDENTIFY payloads
if something is partial, in the d.js docs will the properties that dont return a ?<thing> always be there?
yes
? means nullable
yeah ik just wanted to make sure
so how would I make my bot not ignore my custom prefix but ignore literally every other message
because my bot got muted for not not ignoring every message
check if the message content starts with your prefix
if (!message.content.startsWith(globalPrefix, guildPrefix, prefixes)) return;
^ thats the command I use to ignore everything thats not my prefix
that's not how startsWith works
well it seems to work, how would u suggest I start it
read the docs I sent you'll see your problem with your parameters
@earnest phoenix pro tip whatever lang you use make sure the startswith is not case sensitive because some mobile users have the first letter being uppercase so if someone wanted a custom prefix for pls and Pls to match
wait if a message is partial then wouldnt the deleted property always be false
@grizzled raven uh...no?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
nah i mean
because deleted is a property set by discord.js when creating the message
eh whatever tbh
xd
oh i misread that
i thought you said reaction for whatever reason
also no
partial entities are entities which aren't in the cache and discord doesn't provide all data for it in events
question: is there a way for guild#invites to for each invite and log it to console
filter by what
sorry I meant get the guild invites by forEach then log it to consoles
but filter by what
no i meant get the guld invites by using forEach not filter omg my brain is dead af
im dumb lmao
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=fetchInvites
https://discord.js.org/#/docs/collection/master/class/Collection?scrollTo=each
what I'm trying to ask is will the forEach function work on invites
use each on a collection
I'm still on v11 so i think its each still
how often does the debug event get fired?
you showed the error but you didn't show the snippet one line above the screenshot.
Check all your command files and make sure there's a help object export.
if you don't want to do it manually
just log the command name while running your command loader
then the last one it displays is likely the one you're missing
thats the same thing
@sudden geyser and that would be,,?
what do you mean
im clueless on how to fix
You debug it. If you don't want to check each file one by one or using some sort of search regex, you can instead log the name of the command in your command loader. The last command name displayed that then triggers the error is likely the file that's missing a help export.
as in a console.log in your code. the basics
This message explains how to debug: https://ptb.discordapp.com/channels/264445053596991498/272764566411149314/534107507220807695
how would I make my bot ignore everything execept my globalPrefix and custom prefix, here's my main file code:
bot.on('message', async message => {
if (message.author.bot) return;
const args = message.content.slice(globalPrefix.length).split(/\s+/);
const commandName = args.shift().toLowerCase();
const command = bot.commands.get(commandName) ||
bot.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (message.content.startsWith(globalPrefix)) {
prefix = globalPrefix;
} else {
const guildPrefix = await prefixes.get(message.guild.id);
if (message.content.startsWith(guildPrefix)) prefix = guildPrefix;
if (!message.content.startsWith(globalPrefix, prefix)) return;
}
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.channel.send('there was an error trying to execute that command!');
if (typeof execute !== 'undefined') {}
}
})```
and here's the custom prefix code:
const member = message.member;
if (!message.member.hasPermission('MANAGE_GUILD')) {
return message.channel.send("You can't use this command, You don't have the permission :sc1:")
}
if (args.length) {
await prefixes.set(message.guild.id, args[0]);
return message.channel.send(`Prefix Is Now \`${args[0]}\` :sc3:`);
}
return message.channel.send(`Prefix is \`${await prefixes.get(message.guild.id) || globalPrefix}\``);
}
}```
Does anybody know the embed color code for twitch
#6441a5
That's hex not in embed
what
There's a difference between a hex and an embed color code
ok and
i mean you can still use hex
Embed color codes only have numbers though
well u can convert them into "embed color codes" by replacing # with 0x.
afaik this should be the right order to allow dynamic routing on express, right?
ones with more params being higher
is there any way to find similar versions of string?
look up the levenshtein distance algorithm
@surreal notch you have to make the bot only listen for its prefix
something like if (!message.content.startsWith('yourprefix', 0)) return;
with 'yourprefix' being your prefix
as in ! . > or whatever you used
@surreal notch
No
what's your prefix
const Discord = require("discord.js");
const client = new Discord.Client();
const prefix = "p!";
//LOGIN
client.login("Token");
client.on("message", message => {
//RETURN IF USER IS A BOT
if (message.author.bot) return;
if (talkedRecently.has(message.author.id)) {
message.channel.send("__**You can use this command one time in 6 Hours**__");
} else {
message.channel.send(embed)
// the user can type the command ... your command code goes here :)
if(message.content.toLowerCase() === `${prefix}credits`) {
var numbers = ["You have recieved 5 credits for Pokecord Bot\n\nYour reddem code is ||NwEf||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 10 credits for Pokecord Bot\n\nYour reddem code is ||FtwK||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this", "Better Luck Next time", "Better Luck Next time","Better Luck Next time","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is ||TraW||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is TraW\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this","You have recieved 20 credits for Pokecord Bot\n\nYour reddem code is ||TraW||\n\nDM ULTRON#4070 to recieve your gift with reddem code and screenshot of this"
];
var answer = numbers[Math.floor(Math.random()*numbers.length)];
var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Pokecord Credits**").setDescription(answer)
message.channel.send(embed)
// Adds the user to the set so that they can't talk for a minute
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after 6 hours
talkedRecently.delete(message.author.id);
}, 21600000);
}
}
})
See
so you see const prefix
Yes
you would make that take that and add it to the if statement I sent you
where 'yourprefix' is but without the quotes
??
like this if (!message.content.startsWith(prefix, 0)) return;
ya?
Lib: DJS
How can I check if a message was edited?
@surreal notch add this to your code
if (!message.content.startsWith(prefix, 0)) return;
yw
How can I check if a message was edited?
There's editedAt, editedTimestamp, and edits, but there's no edited property--this is in DJS
@earnest phoenixlisten
?
I want like that I can use that anytime time but others have cooldown
I have done cooldown for everyone
Now I have to wait 6 hrs
so basically you'd want to have permissions and permissionOverrides
?? uhh
oh uh danny what do you mean by check if a message was edited
Like I want to check if the message passed* in the event was edited--I use a command handler and I'm implementing this on the command level just for extra info so


ku
