#development
1 messages Β· Page 1422 of 1
member.nickname will give you the name too
ya
i tryed that also
did you run normal Discord.js? or something like discord.js-light?
discord.js
where did you added the code? does the file is loaded
ya it run
but
NOW it works without admin!!! yay thx
did you enable GUILD_MEMBERS intent
where
Developer Portal > Bot's page
wate
in which page of discord developer portal?
Read the guide I sent
it working
dmChannel is null
discord.js
wired, looks like the member is for some reason not cached -> returns as null
just to make sure add a console,log(msg.member) before you check the permission
How do I have datetime give 12 hour format for time in Python?
ok so
now my commands wont run
im using args to define different things in my automod command
but when i run +automod it should send this
and what does happen?
which would look like this
it doesnt work like
the entire command wont run
just to get it to send that i had to turn prefix off and restart the bot 5 times
its on but it just ignores the prefix
why?
not sure but the loading of the prefix should be probably async
hmmm
ima just try to use the normal prefix
and take that out
thats for like changing it per guild
Try to log the prefix
ok
if its undefined you need to load it async, if its defined its fine
or if you get a pending promise
it says + the second plus is when it sends the message
i have an idea
im gonna remove all the commands and add them bad one by one
it has to be a problem with the commands and not the prefix
ok found the issue
if (message.content.includes('discord.gg/'||'discordapp.com/invite/'||'discord.io'||'discord.st')) {
if(!db.has(`modinvite_${message.guild.id}`)) return; //if it cenabled
message.delete() //delete the message
.then(message.channel.send({ embed: { color: ('RANDOM'), description: (' | Link Deleted:\n**Invite links are not permitted on this server**') } }));
}
my bot hates this for some reason
@lusty quest you have any idea why?
You need to use .includes on each of those strings
your includes
or use regex for detecting the urls
like?
if message content includes discord.gg or if message includes discord.com/invite
I'd stay away from regex for now bgl
/(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li)|discordapp\.com\/invite)\/.+[a-z]/g
Glad to be helpful
oo
okay ik you like making fun of me
but can you like be supportive when i try to show you how it works smh
if (message.content.includes('/(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li)|discordapp\.com\/invite)\/.+[a-z]/g')) {
if(!db.has(`modinvite_${message.guild.id}`)) return; //if it cenabled
message.delete() //delete the message
.then(message.channel.send({ embed: { color: ('RANDOM'), description: (' | Link Deleted:\n**Invite links are not permitted on this server**') } }));
}
that should work right?
try and see
Google how to do regexes in JS 
i did
Regular Expression to Capture any discord link
I erased all the code from my bot so I can start from scratch and itβs still online somehow π
you dont need to name functions twice
oh
function bla() {}
// same as
bla = function() {}
but it works for everything else except delete
ok thanks
btw
how to add classes
in npm package
your package?
ys
the same way as anywhere else
you can export a class directly for example
module.exports = class {}
wait so like
java.lang.IllegalArgumentException
Wots this
illegal argument exception
module.exports = image {
triggered: function triggered(string) {
}
}```
WIll be api.image.triggered()
no
ye no shit but what does it mean
that you supplied a function with an invalid or not accepted argument
it doesnt show me where the error is coming from
package me.scorpion37.scorp;
import java.io.IOException;
import javax.security.auth.login.LoginException;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.events.ReadyEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.ChunkingFilter;
import net.dv8tion.jda.api.utils.cache.CacheFlag;
public class Main {
private Main() throws IOException{
try {
JDABuilder.createDefault("e")
.setStatus(OnlineStatus.ONLINE)
.setActivity(Activity.playing("Refusing to Boot Up..."))
.addEventListeners(new OnReadyEvent())
.addEventListeners(new BotCode())
.enableIntents(GatewayIntent.GUILD_PRESENCES, GatewayIntent.GUILD_BANS, GatewayIntent.GUILD_PRESENCES, GatewayIntent.GUILD_MEMBERS)
.enableCache(CacheFlag.ACTIVITY)
.setChunkingFilter(ChunkingFilter.ALL)
.build()
.awaitReady();
} catch (LoginException | InterruptedException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
new Main();
} catch (IOException e) {
e.printStackTrace();
}
}
}```
im guessing its coming from the main class
// export object
module.exports = {
triggered: function() {}
}
// or
let obj = {
triggered: function() {}
}
module.exports = obj;
// export class
module.exports = class {
triggered() {}
}
// or
class Abc {
triggered() {}
}
module.exports = Abc
does your error not have a stack trace that shows you which lines its coming from?
at me.scorpion37.scorp.Main.<init>(Main.java:31) at me.scorpion37.scorp.Main.main(Main.java:40)
line 40 and 31
in this area
public static void main(String[] args) {
try {
new Main(); //Error comes from here
} catch (IOException e) {
e.printStackTrace();
}
}```
ok see
also second error comes from ```java
.build()
triggered: async function(string) {
}
}
What I code
What user does to get output
const api = require('random-stuff-api')
api.triggered(image url)
But I want them to do api.image.triggered()11```
@quartz kindle
i made another bot i just copied the code from my prev bot but its not working
:(
so will it be
module.exports = image {
triggered: async function(string) {
}
}```
will it work
no
oh
what are you trying to do?
try starting from scratch and follow the official docs https://github.com/DV8FromTheWorld/JDA/wiki/3)-Getting-Started#Connecting-to-Discord-with-a-Bot-Account
Java wrapper for the popular chat & VOIP service: Discord https://discord.com - DV8FromTheWorld/JDA
ok
Ok so see
Like
In my npm package
people do api.dog() to get dog image
does api require an api key?
then you dont need a class
i want them to do api.image.dog()
But i want to do this ^^
like canvacord does
Canvacord.Canvas.trigger(image)
Like this
Canvacord is how we require
canvacord
classes are the same as objects, just that classes contain a "state" that they remember throughout the class's existence, for example ```js
bla = require("bla") // returns a class
instance = new bla(some data here)
instance.function() // everytime you use instance, it will always have "some data here" ready to be used inside it
if you dont need data to be stored inside it, then you dont need a class, you can just use objects
But in canvacord we don't define Canvas anywhere
to do what you want just put one object inside the other
I need to arange that's it
obj = {
somefunc: function() {}
somesection: {
otherfunc: function() {}
}
}
obj.somesection.otherfunc()
module.exports = obj
okk tHanks
my coded
if(cmd === 'mute'){
if(!msg.member.hasPermission(['BAN_MEMBERS' , 'KICK_MEMBERS']) return msg.channel.send("You don't have permission to ban members cutie");
)
}
else {
let memberId = message.content.subsring(message.content.indexOf('')+1);
let member = message.guild.members.cache.get(memberId)
if(member) {
if(member.hasPermission(['BAN_MEMBERS' , 'KICK_MEMBERS']) && !message.member.hasPermission('ADMINISTRATOR'))
message.send.channel('You cant mute that person')
}
}
else {
let mutedRole = message.guild.roles.cache.get('772660072065138761')
if(mutedRole) {
member.roles.add(mutedRole)
message.send.channel('User was muted')
}
else {
message.send.channel('Muted role not found')
}
}
my error
unepected token 'return'
your ) is at the wrong position
if(!msg.member.hasPermission(['BAN_MEMBERS' , 'KICK_MEMBERS'])) return msg.channel.send("You don't have permission to ban members cutie");
also
substring, not subsring
also, you cant have two else in a row
you have else {} else {}
ok
That would open new and exciting possibilities 
should i put one as if else or remove it
from the looks of it, you want the content of the second else to be inside the first, otherwise your code makes no sense
ok
like this
if(cmd === 'mute'){
if(!msg.member.hasPermission(['BAN_MEMBERS' , 'KICK_MEMBERS'])) return msg.channel.send("You don't have permission to ban members cutie");
}
else {
let memberId = message.content.substring(message.content.indexOf('')+1);
let member = message.guild.members.cache.get(memberId)
if(member) {
if(member.hasPermission(['BAN_MEMBERS' , 'KICK_MEMBERS']) && !message.member.hasPermission('ADMINISTRATOR'))
message.send.channel('You cant mute that person')
else
let mutedRole = message.guild.roles.cache.get('772660072065138761')
if(mutedRole) {
member.roles.add(mutedRole)
message.send.channel('User was muted')
}}}
without the else
ok
and without the extra }
? regex will find all matching ones
so regx.match?
regex.test()
oH
or string.match()
I used π΄π’βͺ
and it showed this error:
DiscordAPIError: Unknown Emoji
let regx = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g
let cdu = regx.test(message.content.toLowerCase().replace(/\s+/g, ''))
so like this
Yes
ah
k brb
if (message.content.includes("")) {
if(!db.get(`modinvite_${message.guild.id}`)) return; //if it cenabled
message.delete().then(message.channel.send({ embed: { color: ('RANDOM'), description: (' | Link Deleted:\n**Invite links are not permitted on this server**') } }));
}
how would i put that on this though
did you use their unicode versions?
what are unicode versions?
\π΄\π’\βͺ this
its a custom emoji?!?!
no, the literal character
π΄
\π΄
@lusty quest
It gives an error
so how to use it? I used the :: emojis only.
like this
if(cmd === 'mute'){
if(!msg.member.hasPermission(['BAN_MEMBERS' , 'KICK_MEMBERS'])) return msg.channel.send("You don't have permission to ban members cutie");
}
else {
let memberId = message.content.substring(message.content.indexOf('')+1);
let member = message.guild.members.cache.get(memberId)
if(member) {
if(member.hasPermission(['BAN_MEMBERS' , 'KICK_MEMBERS']) && !message.member.hasPermission('ADMINISTRATOR'))
message.send.channel('You cant mute that person')
}
}
{
let mutedRole = message.guild.roles.cache.get('772660072065138761')
if(mutedRole) {
member.roles.add(mutedRole)
message.send.channel('User was muted')
}}
my error
illegal return statement
you type the literal character in your code
if(!msg.member.hasPermission(['BAN_MEMBERS' , 'KICK_MEMBERS'])) return msg.channel.send("You don't have permission to ban members cutie");
You're sending a message after return
you can test your message.content as example
idiot
Means ?
It's my npm package and it's not related to discord
You replied to wrong person lol
ohh sry wrong person
yea wanted to reply but someone send a message at the same moment
i dont think canvas works in runkit, because its a native C module, it requires build tools
I am not dreaming.... 30 people invited my potato bot lmao
it does not do nothing other than send random potato images
@quartz kindle what do i do
30 People loving potatos
your code is still wrong, but the return is correct, if the return is causing the error, it means something else is wrong, show your full code
let regx = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g
let cdu = regx.test(message.content.toLowerCase().replace(/\s+/g, ''))
how would you put this in this
if (message.content.includes()) {
if(!db.get(`modinvite_${message.guild.id}`)) return; //if it cenabled
message.delete().then(message.channel.send({ embed: { color: ('RANDOM'), description: (':RosesNo: | Link Deleted:\n**Invite links are not permitted on this server**') } }));
}
Alright and that somesection thing doesn't work for me
Ouch.. that regex π
I uninstalled canvas
show code
This is the error
and I am gonna send code
module.exports = {
random:{
joke: function joke() {
try {
return new Promise(async resolve => {
giveMeAJoke.getRandomDadJoke(function (jokee) {
resolve(jokee)
})
})
} catch (err) {
throw new Error("An error occurred , error: " + err);
}
}
}
}```
my code
are you.... literally publishing in npm for testing in runkit?
yes
what the fuck
how else can I check
oh
lmao
Am I doing anything wrong tho
I think the emojis work now, but another thing happend. This is my code:
.setTitle("**POLL STARTED!** " + `${message.author.tag}`, (message.author.displayAvatarURL()))
.setTimestamp()
.setColor("#1fff00");
message.channel.send(embed2);
message.react('π’').then(() => message.react('βͺ').then(() => message.react('π΄')))
const filter = (reaction, user) => {
return ['π’', 'βͺ', 'π΄'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === 'π’') {
message.author.send(`You reacted: **YES**!`)
} if (reaction.emoji.name === 'βͺ') {
message.author.send(`You reacted: **CANNOT DECIDE**!`)
} else {
message.reply('You reacted: **NO**!');
}
}
)}
}```
**and I get this:** ```node:internal/process/promises:218
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: 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(). The promise rejected with the reason "#<Collection>".] {
code: 'ERR_UNHANDLED_REJECTION'
}```
but tim , How can i test it locally
@quartz kindle what do i fix
Why client.once()?
it has to be inside client.on("message")
lol
Wouldn't that only trigger once
catch your promises
assuming message is defined
yes, they have no idea what they're doing lul
?
yes bread
you know what a promise is?
no
baguette
a promise is something that "will eventually finish, but cannot finish right now because it requires doing something that takes time"
for example, the .send() function returns a promise, because it needs to send data to discord and wait for a response, it cannot finish right now because it needs to wait, so it returns a promise saying "i will eventually finish at a later time"
if a promise errors, you need to catch the error by adding a .catch() after the promise, otherwise you get an unhandled promise rejection
Sa.
all functions that need to send something to discord return a promise, so you need to catch them all
.send().catch()
.react.catch()
etc
and inside your .catch() you need to define how to handle the error
ok fix it now
it said
member is not defined
for example .send().catch(error => console.log(error)) if you want to show the error in your console
I see some people use just .catch(), does that actually work?
nope
let regx = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g
let cdu = regx.test(message.content.toLowerCase().replace(/\s+/g, ''))
if(!db.get(`modinvite_${message.guild.id}`)) return;
let whitelist = db.get(`whitelistedil_${message.guild.id}`);
let role = message.guild.roles.cache.find(role => role.id === whitelist)
if(!role) return;
if(role) return;
if(cdu) {
message.delete()
.then(message.channel.send({ embed: { color: ('RANDOM'), description: (' | Link Deleted:\n**Invite links are not permitted on this server**') } }));
}
gotta love over complicating things
ah sure
LOL
Better to just remove both statements and put a return into the line, one line less 
oh
thats for whitelist
It's still wrong
how would i do it?
I don't know what you're trying to do
like check to see if they have the role
But that code just stops working either way
it stores the role by id so it searches the guild for the role
tΓΌrk olan varmΔ±
i want it to check to see if they have the role
So remove that if (role) return;
ok
it said the error is here member.roles.add(mutedRole)
^
That literally means if the role exists, return
i removed both returns
ok
Just added the catches and it works (also, there aren't any errors in the terminal)! π Thanks! But the bot reacts to my message (command), not to the poll message it sends. π¦
newMessage = await message.channel.send(...)
newMessage.react()
What is the .then() for?
after it gets the role
Ah, you don't need that
ok
Since roles.cache.find() does not return a promise
As for checking whether the member has the role or not, use message.member.roles.cache.has(role.id)
let regx = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g
let cdu = regx.test(message.content.toLowerCase().replace(/\s+/g, ''))
if(!db.get(`modinvite_${message.guild.id}`)) return;
let whitelist = db.get(`whitelistedil_${message.guild.id}`);
let role = message.guild.roles.cache.find(role => role.id === whitelist);
if(role) {
message.member.roles.cache.has(role);
return;
}
if(cdu) {
message.delete()
.then(message.channel.send({ embed: { color: ('RANDOM'), description: (' | Link Deleted:\n**Invite links are not permitted on this server**') } }));
}
like that?
so if they have the role it doesnt delete there message
but if they dont it deletes it
@pale vessel
No
O
.has(whitelist) <β if whitelist is a the role id
whitelist is getting the role id from the database
the role is checking the whitelisted role to see if its in the server
then if it is it checks if the user has it
Oh for multiple server purpose
Replace this with js if (role && message.member.roles.cache.has(role.id)) return;That makes sure that the role exists and that the member has it (so they're whitelisted). It would return if true so the message won't be deleted.
like this
let whitelist = db.get(`whitelistedil_${message.guild.id}`);
let role = message.guild.roles.cache.find(role => role.id === whitelist);
if (role && message.member.roles.cache.has(role.id)) return;
Yes
hM
You can replacemessage.guild.roles.cache.find(role => role.id === whitelist); with message.guild.roles.cache.get(whitelist);
no commands will work
Oh that's in the message event?
yes
Looks like I'm not getting anywhere today :(
Make it delete the message if the member doesn't have the role, without returning
The whole code doesnβt make sense anyway.
Just sort the code logically.
First check if the message contains your regex, if not return, else query your db and check for the roles and delete/not delete the message.
h
As it is right now it will query the db each time even if your regex isnβt found
if (role && !message.member.roles.cache.has(role.id) && cdu) message.delete();```This makes sure that the whitelist role exists AND the member does not have the role AND it is an invite. It would delete the message if it passes
I'm giving you code but you also have to understand what it does
Even thatβs nonsense
Replace that with the code
You donβt need to query the database in the first place if the regex isnβt found
Well that's on them
As first action return if your regex is NOT found
Cya
I'm trying to help them with this one
So yes, refactoring is needed but it seems that they need to fix the problem first
like thiS
Yeah I got that but the logical aspect is important
The whole line
.setTitle("**POLL STARTED!** " + `${message.author.tag}`, (message.author.displayAvatarURL()))
.setTimestamp()
.setColor("#1fff00");
message.channel.send(embed2);
newMessage = await message.channel.send(embed2)
message.react('π’').then(() => message.react('βͺ').then(() => message.react('π΄'))).catch(error => console.log(error))
const filter = (reaction, user) => {
return ['π’', 'βͺ', 'π΄'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === 'π’') {
message.author.send(`You reacted: **YES**!`).catch(error => console.log(error))
} if (reaction.emoji.name === 'βͺ') {
message.author.send(`You reacted: **CANNOT DECIDE**!`).catch(error => console.log(error))
} else {
message.reply('You reacted: **NO**!').catch(error => console.log(error))
}
}```
SyntaxError: await is only valid in async function
What did I do wrong this time? I added the *newMessage = await message.channel.send(...)*
Why would you query your db 2 times? Check if whitelist is false
But you process commands after it
Wut? You check if this feature in activated in that guild?
Which means it can be activated/deactivated?
ok nvm
yes
it doesn't go threw the regex though
Aha okay
the {message.author} etc don't work somehow, how do i fix it?
ive putted them in `
it wont check the regex or something idk
<@${message.author.id}>
use that
message author doesnt return anything
That won't mention though
but
Yeah because the regex is awful and thatβs not how you use it
you have to add something at the end
It's in a field title
You have to use their username/tag for field titles
but
oh yeah
and it's ${} not {}
for field values
message.author.tag
π
wut
but i looked up how to use regexs and it said like that

Itβs the first result on google, I see, but still used wrongly
How would you use it?
Both work
let cdu = message.content.match(new RegExp(`/(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g`))
like that
it didnt
Then that's not the problem
Nope it canβt work because you canβt declare the regex as string
You can
Nope not how heβs doing it
not a he
let cdu = message.content.match(new RegExp(/(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g))
then like that?
Yes
(true on that one)
If it's already a regex then you don't need new RegExp()
ok so
But on this context your previous code (regex.test(message.content)) does the same
I don't know why you think this is where the problem is
because the regex isnt testing for invites
Hey, does anyone know if on Discord, if a member leaves, are their channel permissions removed automatically?
period.
module.exports = {
random:{
joke: function joke() {
try {
return new Promise(async resolve => {
giveMeAJoke.getRandomDadJoke(function (jokee) {
resolve(jokee)
})
})
} catch (err) {
throw new Error("An error occurred , error: " + err);
}
}
}}```
yes
beacause i tried it
yes
Your other code can be the one that stops it from working
i know the regex is working but it doesnt check it
Not that regex code
Then why are you changing the regex code lol
This is just bruh
how do i make an if statement if the variable is the same number as another variable
test = test2 doesn't work
Not the regex itself
probs should remeove new
The code that checks the regex
Hi
Guys
module.exports = {
random:{
joke: function joke() {
try {
return new Promise(async resolve => {
giveMeAJoke.getRandomDadJoke(function (jokee) {
resolve(jokee)
})
})
} catch (err) {
throw new Error("An error occurred , error: " + err);
}
}
}}
(Sorry for repeating question)
I am resolving it but
whats the problem
It says promise is not resolved but I'm resolving it
i dunno
Ok.....
But means all the users will have to await it ?
yes
Is there any way I can do smth in my code to avoid that
nope
@pale vessel so this would work?
Stop define a var for the regular expression, you just use it once
Undefined because one of your conditions in your statement is not what it should be
hm
And I can tell you which one 
var regx = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g
var cdu = regx.test(message.content.toLowerCase().replace(/\s+/g, ''))
it says this is undefined
was i right?
Oh god since you will never get it working, gimme a second to switch to the PC
h-
Just /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g.test(message.content.toLowerCase().replace(/\s+/g, ''))
where regx is
Still completely nonsense
what front
never mind
But you don't need to assign it to a variable, just use <regex>.test(string)
Like #development message
message.content.match(/.*(discord\.(gg|io|me|li)|discordapp\.com\/invite)\/.*/gi)
That works too
But .test() returns a boolean and it was their code so that should have worked too
No reason to change it
bullshitting double regex, declaring it as var and so on...
where woould that go?
how do i edit my bot's embed message with an if statement
or if statement in .then?
An if statement
Hey guys !
I've got an issue with bot since yesterday. I'm trying to make a leaderboard by collecting the data from an API, anyway. But the problem is : when I want to check if a user in the data is on the server too, the bot adds him a role. But i don't know why it's not working...
Can someone help me please ?
Here is the code :
body.sort((a,b) => (a.prestige < b.prestige) ? 1 : -1).splice(0, 10).forEach(e => {
newleaderboard.addField(e.username, `${e.prestige} points`);
let guyexist = client.guilds.cache.get('guildid').members.cache.find(t => t.user.username === e.username);
let tannouncement = client.guilds.cache.get('guildid').channels.cache.find(c => c.id === 'channelid');
if(guyexist){
if(!guyexist.roles.cache.find( a => a.id === 'roleid')){
guyexist.roles.add('roleid');
tannouncement.send(`**New Guy added :** ${guyexist.user}`);
};
};
});
did you actually post the code somewhere? can't find it @young flame
what code
for what?*
var regx = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g
let cdu = regx.test(message.content.toLowerCase().replace(/\s+/g, ''))
let role = message.guild.roles.cache.get(whitelist);
if (role && !message.member.roles.cache.has(role.id) && cdu) message.delete().then(message.channel.send({ embed: { color: ('RANDOM'), description: (' | Link Deleted:\n**Invite links are not permitted on this server**') } }));
@boreal iron this?
They just assigned the regex to a variable
It's not that bad?
I don't see anything wrong with this part
and using lowercase, and another regex to place
I wanna benchmark my cpu but vs code stops at 20% cpu usage....
... ocuh
O
and another regex to place
What do you mean

what is the most resource hungry javascript function??
let invite_url_found = message.content.match(/.*(discord\.(gg|io|me|li)|discordapp\.com\/invite)\/.*/gi);
if(role && !message.member.roles.cache.has(role.id) && invite_url_found) message.delete().then(message.channel.send({ embed: { color: ('RANDOM'), description: (':RosesNo: | Link Deleted:\n**Invite links are not permitted on this server**') } }));
Not sure but I thnk require("v8").getHeapSnapshot() is one of them
That's node though
hmmmmm?
Hey guys !
I've got an issue with bot since yesterday. I'm trying to make a leaderboard by collecting the data from an API, anyway. But the problem is : when I want to check if a user in the data is on the server too, the bot adds him a role. But i don't know why it's not working...
Can someone help me please ?
Here is the code :
body.sort((a,b) => (a.prestige < b.prestige) ? 1 : -1).splice(0, 10).forEach(e => {
newleaderboard.addField(e.username, `${e.prestige} points`);
let guyexist = client.guilds.cache.get('guildid').members.cache.find(t => t.user.username === e.username);
let tannouncement = client.guilds.cache.get('guildid').channels.cache.find(c => c.id === 'channelid');
if(guyexist){
if(!guyexist.roles.cache.find( a => a.id === 'roleid')){
guyexist.roles.add('roleid');
tannouncement.send(`**New Guy added :** ${guyexist.user}`);
};
};
});
if(!db.get(`modinvite_${message.guild.id}`)) return;
let whitelist = db.get(`whitelistedil_${message.guild.id}`);
let role = message.guild.roles.cache.get(whitelist);
let invite_url_found = message.content.match(/.*(discord\.(gg|io|me|li)|discordapp\.com\/invite)\/.*/gi);
if(role && !message.member.roles.cache.has(role.id) && invite_url_found) message.delete().then(message.channel.send({ embed: { color: ('RANDOM'), description: (':RosesNo: | Link Deleted:\n**Invite links are not permitted on this server**') } }));
like that?
you need guild members intent
that you can get
by contacting discord
and having your bot
verified
Thanks man β€οΈ
did u turn it on before testing?
actually you can edit embes with if statements in this
how would that change anything
so when i turn it on all it does is check if its in the db
not change anything in the db but see if its enabled in that guild
Yes, why wouldn't it
you turn it on to see if it's enabled ... WHAT 
no
you turn it on
and it enables the filter
when you turn it off
i have the db.get thing so if it is off it doesnt keep filtering links
does that make since?
i have this box that when u hover it shows a div
the regex is not your issue anymore
in html
but it makes all the boxes bigger, not show the div
but just the place where the div shows opens
Hey anyone has a solution to a music bot running on errors whenever someone manually disconects them from the voice chat
is editing a message after 10 seconds good? will it get ratelimit?
.invbox {
background-color: #1c2024;
border-radius: 20px;
padding: 20px;
}
.invbox:hover {
background-color: #7289DA;
border-radius: 20px;
padding: 20px;
}
.hide1 {
display: none;
}
.invbox:hover .hide1 {
display: block;
}```
not needed to set the border-radius and padding again on hover
it will inherit this values
display: block; is your issue
depends on the float you need to stick with a different type
is editing a message after 5 seconds good
No
display: inline-block;
Well it's fine if only once
or table, i dunno, don't see the elements
CSS brrrr
nvm my friend coded something
console.log your conditions on your statement to check which one isnβt as it should be
ok
is it normal my nodejs cpu usage is at constant 100+%
No
tf is that
ah
and the cpu utilization in that doesnt reach 50%
then upgrade it
which is weird
Fell asleep?
#development message @drifting wedge
how can i reply with bot like that
well i dont want inline block
i more like want like only that one to move
not all of them
wat lib?
javascript
Libraries should queue actions and I'm sure djs does
Screenshot?
I mean the regex wasnβt your issue but who cares... it works is what matters
if(message.content.startsWith(prefix + "giverole" )){
if (!message.member.hasPermission('MANAGE_ROLES')) return message.channel.send(`You do not have MANAGE_ROLES permission`).then(m => m.delete({ timeout: 5000 }));
if (!args[0] || !args[1]) return message.channel.send("Incorrect usage, It's `<username || user id> <role name || id>").then(m => m.delete({ timeout: 5000 }))
try {
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
const roleName = message.guild.roles.cache.find(r => (r.name === args[1].toString()) || (r.id === args[1].toString().replace(/[^\w\s]/gi, '')));
const alreadyHasRole = member._roles.includes(roleName.Id);
if (alreadyHasRole) return message.channel.send('User already has that role').then(m => m.delete({ timeout: 5000 }));
const embed = new MessageEmbed()
.setTitle(`Role Name: ${roleName.name}`)
.setDescription(`${message.author} has successfully given the role ${roleName} to ${member.user}`)
.setColor('f3f3f3')
.setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
.setFooter(new Date().toLocaleString())
return member.roles.add(roleName).then(() => message.channel.send(embed));
} catch (e) {
return message.channel.send('Try to give a role that exists next time...').then(m => m.delete({ timeout: 5000 })).then(() => console.log(e))
}
}
cannot read property 'Id' undefined
@lucid prawn #development
What do you think where we are?
lol
Why is the typingStart seem buggy???
It starts late somehow
its id not Id
i try that @tribal siren
okay this should be my last question
sometimes it register
try typing for 15 seconds
sometimes it dont
is discord-mongoose-money is better than discord-money for making currency system
i wan to have it so by typing like
+invite-links whitelist [role id]
but i wont work like that
} else if(args[0] === "whitelist") {
let wrole = args[0]
if(isNaN(wrole)) return message.channel.send({ embed: { color: ('#ff3636'), description: ("` | You must provide a valid role id, check to make sure the one provided it valid") } });
db.set(`whilelistedil_${message.guild.id}`, wrole)
message.channel.send({ embed: { color: ('#63f736'), description: ("You have Configured set the whitelisted role to <@&" + wrole + ">") } });
}
``` it doesnt add the space between whitelist and the role id
const messages = messages.collect();
should the wrole be like args 2 or something
just that?
that was a joke
aaaa I forgot gotta see docs
let wrole = args[0] wtf?
args[0] is your whitelist argument
It should be args[1]
@lucid prawn did it work
thought so
same error @tribal siren
@narrow marten const collector = new Discord.MessageCollector() ?
And instead of just checking if the role is a number, also check if the role even exists
oki
If not stop return the function always without any output
mhm and?
Just return a message, for example role doesnβt exist, or argument is missing etc
Doesnβt make any sense to return nothing on a wrong input
collector.on('collect', message => {}) to collect it make sure to put the filters in MessageCollector(<filters>)
if i make a hastebin of the transcript of a channel, how would i make it include embeds and do something like switch it to text or be like "Embed: text"
Yes
what is wrong
its just jumping
please im scared
this is the line:
bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers and 1 shards `, {type: "PLAYING"});```
are the servers cached
Don't think that's a valid ClientOptions
const bot = new Discord.Client({disableEveryone: true,
partials:["MESSAGE", "CHANNEL", "REACTION"]
})
Add "GUILDS"
okay
oh wait that's partial
Where is that from?
from the discord oauth screen
^
Hi
so what should i do?
@devout frost https://cdn.hopefuls.de/JDg0
should i do that:
const bot = new Discord.Client({cacheGuilds: true, disableEveryone: true,
partials:["MESSAGE", "CHANNEL", "REACTION"]
})
will it work then?
Thats not a valid clientOption, so no
must go partials -> ws -> intents
disableEveryone is also not a valid clientOption
where did you even get cacheGuilds from
I suggest you try to ask on the djs server, maybe they have a clue.
Enabling the guilds intent should be all that's required. If you're sharding that'll also affect the number of servers you see. I'm not 100% sure if the guilds intents includes guilds.
cacheGuilds is not a client option
so what to do?!?!
if you don't specify any intents in the clientoptions, all should be used by default
You try as I suggested. Remove the cacheGuilds client option because it doesn't exist. Try the guilds intent to see if the server count returns to the appropriate type. And verify if you're sharding.
From the docs (https://discord.js.org/#/docs/main/stable/typedef/ClientOptions), you need to use the ws.intents option, which will take an array of intents (GUILDS). So, that could look like { ws: { intents: [...] } }
Are you sure? A number of people have come complaining about not receiving certain events when not having the intents option listed
so, i still dont get what i need to do here
uh ok
so i have a whitelisted role
for the invite filter
but when i have the role and i post a invite it still gets deleted-
@boreal iron
No, but guilds should be cached anyway.
GUILDS is not a privileged intent and enabled by default, if no intents were specified manually.
@devout frost and @sudden geyser , in the website it says the right amount
and its the same code
can you show us how you're posting it
are you sharding?
yes
how do i make it show the total tho
if you're using the sharding manager you need broadcastEval
^
how do i use broadcastEval
scroll to broadcastEval or fetchClientValues
both work
shouldn't this return if the user has that role
just use has()
@quartz kindle okay found it, dont know what to do with that code:
bot.shard.broadcastEval('this.guilds.cache.size')
.then(results => console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`))
.catch(console.error);
does anyone know where i could learn about reactions?
like for example what kinds of reaction names are there and how to detect the reactor
nope
they dont want to post it
they want to show it in their bot status
the posting already works
the web is working
its giving me errors
SyntaxError: await is only valid in async function
Someone knows a npm package to read bar codes? 
async () => {
result = await promise()
// use result here
}
// or
() => {
promise.then(result => {
// use result here
})
}
``` @tardy hornet
Hello i need Help https://hastebin.com/urapejicis.sql this is my Error
role.id === whitelist < whitelist is an id?
if it's an id try cache.get(whitelist) instead
let num = Math.floor(Math.random()*(70-65+1)+1)
let test = String.fromCharCode(num)
message.channel.send(test)
it doesnt output anything
ok
you're generating a random number between 1 and 7
range is max-min+1; im probably doing something really dumb, i just dont see it
still doesn't work
You're importing shard manager from the wrong place: https://ci.dv8tion.net/job/JDA3-Legacy/javadoc/net/dv8tion/jda/bot/sharding/ShardManager.html
im storing the role like
Math.random() * (max-min) + min
whitelistedil_guildid_role id
At the top
What is the best database for a discord bot 
yep; just big dum over here
Is sqlite better than mongo?
They both have different use cases
i can't import it "right"
net.dv8tion.jda.bot.sharding
I would say use MongoDB
nope it's doesnt work
Mongo is similar to JSON, better for dynamic data such as lists, SQL is for if you know exactly what you will be storing such as a username and password
Hm
If I'm not mistaken, I believe that SQL is faster
Also MongoDB does not have a good async driver (on Python at least)
whitelistedil_guildid_roleid
i tried just doing
if(message.member.roles.cache.has(whitelist)) return;
if(!message.member.roles.cache.has(whitelist))
but it still doesn't work
anyone got a better loading gif?
I would say use quickdb
Which version
console.log(whitelist)
MongoDB is quite simple to understand though as it works similarly to JSON files
i use 4.2.0_222
Even I don't understand it :D
Someone knows a npm package to read bar codes?
no
3.4.0_317?
is there a way i can get only 10 documents with collection.find(); mongodb?
@reef stag either way you should just update to the latest version
if you are not already on it
Then you're good
.limit(10)
ah i see
thanks
Are you trying to implement your own sharding manager? If not just follow the instructions in the README: https://github.com/DV8FromTheWorld/JDA#sharding-a-bot
how can i remove a permission overwrite
blame discord
oki
it says null
blame discord
i tried running my bot files on another testing bot it works fine, but when i try on the normal bot (which is pending verification, idk if thats a problem) it gives me this in the console π ....```
C:\Users\User\Downloads\Cooldown-master>node index.js
Bot is online
C:\Users\User\Downloads\Cooldown-master\index.js:48
if(message.member.hasPermission("ADMINISTRATOR")) return;
^
TypeError: Cannot read property 'hasPermission' of null
at Client.<anonymous> (C:\Users\User\Downloads\Cooldown-master\index.js:48:27)
at Client.emit (events.js:315:20)
at MessageCreateHandler.handle (C:\Users\User\Downloads\Cooldown-master\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\User\Downloads\Cooldown-master\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
at C:\Users\User\Downloads\Cooldown-master\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:70:12
at Array.forEach (<anonymous>)
at WebSocketPacketManager.handleQueue (C:\Users\User\Downloads\Cooldown-master\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:69:16)
at WebSocketConnection.triggerReady (C:\Users\User\Downloads\Cooldown-master\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:126:24)
at WebSocketConnection.checkIfReady (C:\Users\User\Downloads\Cooldown-master\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:141:61)
at GuildCreateHandler.handle (C:\Users\User\Downloads\Cooldown-master\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:13:31)```
now its showing how many the shard is watching
e
i created a permission overwrite
event.getGuild().getTextChannelById(channel.getId()).createPermissionOverride(event.getMember()).setAllow(Permission.MANAGE_CHANNEL).queue();
but i cant remove it.
can anyone help
if its null then you saved it wrong
Oj
How would you save it in quick.db then?

how did you save it?
Pls @ me Do developers have to make it so the bot can only say nsfw things in a nsfw channel?
yes
@earnest phoenix YES
hey are there any alternative to setTimeout for timed mutes?
scheduling
wdym
there are no alternatives to the setTimeout function, but there are alternative ways to use it, depending on your needs
You need an instance of a class that implements the PermissionOverride interface. You can then call .delete() to delete it, returning another class implementing the RestAction<T> interface.
So, if you could have a TextChannel instance and do .getPermissionOverride(...).delete().queue()
oh could you link me to those?
cause setTimeout's are not "persistant"
it resets after restart/crashj
no they are not, you have to take care of that yourself
ah kk
store timestamps in a file or a database, then restart the timeout based on those timestamps
ive never used scheduler, but isnt that what it does?
the node-schedule package uses cron
anyone help
did u install node?
no
lol
they why are you here?
Well you need to
dbl in a nutshell ladies and gentlemen
This is still not a marketplace dude
if you don't know where to add the token, then you're not ready to code a bot. see #502193464054644737
https://www.npmjs.com/package/node-schedule does this pacage work after restarts?
So where do I have to add the token?
your question is something that is very basic with bot development, best is to read #502193464054644737
how do i grab a random user id from db, this dosent work, returns dup error const player1 = await queueConfig.findOne('userId');
Give us more details
lel
userId: String,
} );
when user writes command /join adds their user id to dbasync run(client, message, args) { const queueConfig = await QueueConfig.create({ userId: message.member.id, }); const player1 = await queueConfig.findOne('userId'); //const player1 = queueConfig.get( 'userId')
i want to grab one user from that collection
@cinder patio
is it normal to take long
:/
keep waiting
What command did you run anyway
How to get the second last value of out a collection
ex:
there are 3 values
and i want the second last
in this case it would be 2
how do i get that one?
What language are you writing in, and what is the collection (is it a custom class, like discord.js' Collection class)
discord.js's
I think the method .last() exists.
that would get the last last
the actual last
but i want the one before the last
um
your taking your time i see
The Collection class does not work like an array indexed by its position. You could get all the keys of the collection and find the key by its index, then use that key with the .get method.
Sorry it took long, I was a bit confused.
im confused ahah
are you sure you did node .
ye
can you show your full console





