#development

1 messages Β· Page 1422 of 1

fallow vapor
#

I've a regex for discord invite if you want

lusty quest
#

member.nickname will give you the name too

atomic vault
lusty quest
#

did you run normal Discord.js? or something like discord.js-light?

atomic vault
#

discord.js

lusty quest
atomic vault
#

ya it run
but

sour oxide
#

NOW it works without admin!!! yay thx

summer torrent
#

did you enable GUILD_MEMBERS intent

atomic vault
summer torrent
#

Developer Portal > Bot's page

atomic vault
#

wate

summer torrent
atomic vault
summer torrent
#

Read the guide I sent

earnest phoenix
#

bruh

#

you r so new

atomic vault
rustic nova
#

dmChannel is null

lusty quest
#

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

hasty mulch
#

How do I have datetime give 12 hour format for time in Python?

young flame
#

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

lusty quest
#

and what does happen?

young flame
#

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

lusty quest
#

its on but it just ignores the prefix

young flame
#

why?

lusty quest
#

Β―_(ツ)_/Β―

#

its your code

young flame
#

the prefix

lusty quest
#

not sure but the loading of the prefix should be probably async

young flame
#

hmmm

#

ima just try to use the normal prefix

#

and take that out

#

thats for like changing it per guild

slender thistle
#

Try to log the prefix

young flame
#

ok

lusty quest
#

if its undefined you need to load it async, if its defined its fine

#

or if you get a pending promise

young flame
#

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

young flame
#

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: ('![RosesNo](https://cdn.discordapp.com/emojis/782971149260685312.webp?size=128 "RosesNo") | 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?

slender thistle
#

You need to use .includes on each of those strings

lusty quest
#

your includes

young flame
#

oh

#

for each one.

#

bruh wut

lusty quest
#

or use regex for detecting the urls

young flame
#

like?

slender thistle
young flame
#

bruH

#

ok

#

brb

slender thistle
#

I'd stay away from regex for now bgl

young flame
#

and fuck u shiv

#

smh

lusty quest
#

/(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li)|discordapp\.com\/invite)\/.+[a-z]/g

slender thistle
#

Glad to be helpful

young flame
#

oo

young flame
#

but can you like be supportive when i try to show you how it works smh

slender thistle
#

I'm reading

#

But can't respond

young flame
#
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: ('![RosesNo](https://cdn.discordapp.com/emojis/782971149260685312.webp?size=128 "RosesNo") | Link Deleted:\n**Invite links are not permitted on this server**') } }));
     }
#

that should work right?

lusty quest
#

try and see

young flame
#

i am

#

lets see if my prefix breaks lol

#

nope

#

prefix brokE

slender thistle
#

Google how to do regexes in JS mmLol

young flame
#

i did

fathom nymph
#

Hello

#

how may i help you?

young flame
#

it said

#

this

#
discord(?:\.com|app\.com|\.gg)/(?:invite/)?([a-zA-Z0-9\-]{2,32})
lusty quest
somber oak
#

I erased all the code from my bot so I can start from scratch and it’s still online somehow πŸ˜‚

young flame
#

idk

#

hmm

quartz kindle
#

you dont need to name functions twice

delicate shore
#

oh

quartz kindle
#
function bla() {}
// same as
bla = function() {}
delicate shore
#

but it works for everything else except delete

delicate shore
#

btw

#

how to add classes

#

in npm package

quartz kindle
#

your package?

delicate shore
#

ys

quartz kindle
#

the same way as anywhere else

#

you can export a class directly for example

#
module.exports = class {}
delicate shore
#

wait so like

knotty obsidian
#

java.lang.IllegalArgumentException
Wots this

quartz kindle
#

illegal argument exception

delicate shore
#
module.exports = image {
    triggered: function triggered(string) {
}
}```
WIll be api.image.triggered()
quartz kindle
#

no

knotty obsidian
quartz kindle
#

that you supplied a function with an invalid or not accepted argument

knotty obsidian
#

it doesnt show me where the error is coming from

delicate shore
#

so like many packages

#

do

#

i wana do

#

api.image.triggered()

knotty obsidian
#
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
quartz kindle
delicate shore
#

thnx

#

no

#

Can i have a class in a class

#

wait so

quartz kindle
knotty obsidian
#

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();
        }
    }```
delicate shore
#

ok see

knotty obsidian
#

also second error comes from ```java
.build()

delicate shore
#
    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
knotty obsidian
#

i made another bot i just copied the code from my prev bot but its not working

#

:(

delicate shore
#

so will it be

#
module.exports = image {
    triggered: async function(string) {

}
}```
#

will it work

quartz kindle
#

no

delicate shore
#

oh

quartz kindle
#

what are you trying to do?

quartz kindle
knotty obsidian
#

ok

delicate shore
#

Like

#

In my npm package

#

people do api.dog() to get dog image

quartz kindle
#

does api require an api key?

delicate shore
#

no

#

api is just how they required

#

my package

quartz kindle
#

then you dont need a class

delicate shore
#

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

quartz kindle
#

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

delicate shore
quartz kindle
#

to do what you want just put one object inside the other

quartz kindle
#
obj = {
  somefunc: function() {}
  somesection: {
    otherfunc: function() {}
  }
}

obj.somesection.otherfunc()

module.exports = obj
delicate shore
#

okk tHanks

lucid prawn
#

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'
lusty quest
#

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");
quartz kindle
#

also

#

substring, not subsring

#

also, you cant have two else in a row

#

you have else {} else {}

lucid prawn
#

ok

boreal iron
lucid prawn
quartz kindle
#

from the looks of it, you want the content of the second else to be inside the first, otherwise your code makes no sense

lucid prawn
#

ok

lucid prawn
# quartz kindle from the looks of it, you want the content of the second else to be inside the f...

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')
 }}}
quartz kindle
#

without the else

lucid prawn
#

ok

quartz kindle
#

and without the extra }

young flame
#

@lusty quest ok so i put the regex in the thing

#

hwo would i filter it though?

lusty quest
#

? regex will find all matching ones

young flame
#

so regx.match?

pale vessel
#

regex.test()

young flame
#

oH

pale vessel
#

or string.match()

distant light
#

I used πŸ”΄πŸŸ’βšͺ
and it showed this error:
DiscordAPIError: Unknown Emoji

young flame
#
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

pale vessel
#

Yes

young flame
#

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: ('![RosesNo](https://cdn.discordapp.com/emojis/782971149260685312.webp?size=128 "RosesNo") | Link Deleted:\n**Invite links are not permitted on this server**') } }));
     }
#

how would i put that on this though

quartz kindle
distant light
#

what are unicode versions?

young flame
#
\:emoji:
#

thats how you get them

quartz kindle
#

\πŸ”΄\🟒\βšͺ this

carmine summit
#

its a custom emoji?!?!

distant light
#

:red_circle;

#

?

quartz kindle
#

no, the literal character

carmine summit
#

πŸ”΄

delicate shore
young flame
#

\πŸ”΄

delicate shore
#

BUt i have it installed

young flame
delicate shore
#

It gives an error

distant light
lucid prawn
# quartz kindle without the else

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

quartz kindle
#

you type the literal character in your code

rustic nova
delicate shore
#

It's ablut my npm package

#

About

rustic nova
#

oh wait nvm im stupid

lusty quest
young flame
#

idiot

delicate shore
#

It's my npm package and it's not related to discord

delicate shore
lusty quest
#

ohh sry wrong person

#

yea wanted to reply but someone send a message at the same moment

quartz kindle
# delicate shore

i dont think canvas works in runkit, because its a native C module, it requires build tools

carmine summit
#

I am not dreaming.... 30 people invited my potato bot lmao

#

it does not do nothing other than send random potato images

lucid prawn
#

@quartz kindle what do i do

lusty quest
#

30 People loving potatos

carmine summit
#

im so confused

#

lmao

quartz kindle
carmine summit
#

LMAO

young flame
#
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**') } }));
     }
delicate shore
boreal iron
#

Ouch.. that regex πŸ‘€

delicate shore
#

I uninstalled canvas

delicate shore
#

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

quartz kindle
#

are you.... literally publishing in npm for testing in runkit?

quartz kindle
#

what the fuck

delicate shore
#

how else can I check

quartz kindle
#

run it locally?

#

LOL

delicate shore
#

we can run it locally?

#

wtf

quartz kindle
#

of course

#

wtf

delicate shore
#

oh

carmine summit
delicate shore
distant light
# quartz kindle

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'
}```
delicate shore
#

but tim , How can i test it locally

lucid prawn
#

@quartz kindle what do i fix

quartz kindle
pale vessel
#

Why client.once()?

quartz kindle
#

it has to be inside client.on("message")

carmine summit
#

lol

pale vessel
#

Wouldn't that only trigger once

carmine summit
#

why is it outside

#

the

#

πŸ˜„

#

tf?

carmine summit
pale vessel
quartz kindle
#

yes, they have no idea what they're doing lul

distant light
slender thistle
#

You ever just

#

PAIN

quartz kindle
#

yes bread

quartz kindle
distant light
#

no

slender thistle
#

baguette

quartz kindle
#

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

full socket
#

Sa.

quartz kindle
#

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

lucid prawn
quartz kindle
#

for example .send().catch(error => console.log(error)) if you want to show the error in your console

pale vessel
#

I see some people use just .catch(), does that actually work?

quartz kindle
#

nope

pale vessel
#

Same

#

I tried it

#

Thought it's something new or whatever

young flame
#
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: ('![RosesNo](https://cdn.discordapp.com/emojis/782971149260685312.webp?size=128 "RosesNo") | Link Deleted:\n**Invite links are not permitted on this server**') } }));
     }
#

gotta love over complicating things

pale vessel
#

Use ||

#

Makes your code look hotter

young flame
#

ah sure

pale vessel
#

Wait...what?

quartz kindle
#

LOL

pale vessel
#

Uh

#

Okay

#

Role doesn't exist? Return. Exists? Nah, still return

boreal iron
#

Better to just remove both statements and put a return into the line, one line less KEKW

young flame
#

thats for whitelist

pale vessel
#

It's still wrong

young flame
#

if it oH

#

brb

young flame
pale vessel
#

I don't know what you're trying to do

young flame
#

like check to see if they have the role

pale vessel
#

But that code just stops working either way

young flame
#

it stores the role by id so it searches the guild for the role

glad shell
#

tΓΌrk olan varmΔ±

young flame
#

i want it to check to see if they have the role

pale vessel
#

So remove that if (role) return;

young flame
#

ok

lucid prawn
pale vessel
#

That literally means if the role exists, return

young flame
#

i removed both returns

pale vessel
#

You only want to return it if it doesn't exist

#

Only remove that one

young flame
#

ok

distant light
quartz kindle
#

newMessage = await message.channel.send(...)
newMessage.react()

young flame
#

@pale vessel would i do like

#
.then( 
message.member.roles.find(role));
pale vessel
#

What is the .then() for?

young flame
#

after it gets the role

pale vessel
#

Ah, you don't need that

young flame
#

ok

pale vessel
#

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)

young flame
#
 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: ('![RosesNo](https://cdn.discordapp.com/emojis/782971149260685312.webp?size=128 "RosesNo") | 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

pale vessel
#

No

boreal iron
#

Why checking it two times? Whitelist is your role.id already

young flame
#

O

boreal iron
#

.has(whitelist) <β€” if whitelist is a the role id

young flame
#

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

boreal iron
#

Oh for multiple server purpose

pale vessel
#

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.

young flame
#

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;
pale vessel
#

Yes

young flame
#

hM

pale vessel
#

You can replacemessage.guild.roles.cache.find(role => role.id === whitelist); with message.guild.roles.cache.get(whitelist);

young flame
#

no commands will work

pale vessel
#

Oh that's in the message event?

young flame
#

yes

delicate shore
#

Looks like I'm not getting anywhere today :(

pale vessel
#

Make it delete the message if the member doesn't have the role, without returning

young flame
#

wut

#

wait

boreal iron
#

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.

young flame
#

h

boreal iron
#

As it is right now it will query the db each time even if your regex isn’t found

pale vessel
#
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

boreal iron
pale vessel
boreal iron
#

You don’t need to query the database in the first place if the regex isn’t found

pale vessel
#

Well that's on them

delicate shore
#

I'll come tomorrow with a fresh mind to ask questions

#

Bye

boreal iron
#

As first action return if your regex is NOT found

delicate shore
#

Cya

pale vessel
#

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

young flame
boreal iron
#

Yeah I got that but the logical aspect is important

pale vessel
#

That would return

young flame
#

o

#

just the return part

#

or the whole thing

pale vessel
#

The whole line

young flame
#

command still wont work

#

commands*

pale vessel
#

That returns

#

Like FakE said lol

distant light
# quartz kindle newMessage = await message.channel.send(...) newMessage.react()
        .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(...)*
boreal iron
#

Why would you query your db 2 times? Check if whitelist is false

young flame
#

i have

#

the return for that

#

because its a enable disable thing

pale vessel
#

But you process commands after it

young flame
#

if they enabled it

#

H

#

idk

boreal iron
#

Wut? You check if this feature in activated in that guild?

#

Which means it can be activated/deactivated?

young flame
#

ok nvm

young flame
#

it doesn't go threw the regex though

boreal iron
#

Aha okay

cinder sandal
#

the {message.author} etc don't work somehow, how do i fix it?
ive putted them in `

young flame
young flame
#

use that

#

message author doesnt return anything

pale vessel
#

That won't mention though

cinder sandal
#

but

boreal iron
#

Yeah because the regex is awful and that’s not how you use it

young flame
#

you have to add something at the end

pale vessel
#

It's in a field title

young flame
#

like

#

it will work

pale vessel
#

You have to use their username/tag for field titles

cinder sandal
#

but

young flame
#

oh yeah

pale vessel
#

and it's ${} not {}

cinder sandal
#

for field values

young flame
#

message.author.tag

cinder sandal
#

oh

#

i forgot

#

ty @pale vessel

pale vessel
#

πŸ‘

young flame
#

but i looked up how to use regexs and it said like that

boreal iron
#

It’s the first result on google, I see, but still used wrongly

pale vessel
#

How would you use it?

young flame
#
message.content.match(new RegExp(
#

like that

pale vessel
#

Both work

young flame
#

?

#

oH

#

brb

pale vessel
#

regex.test(string) works too

#
/test/.test("abctest"); // true```
young flame
#
let cdu = message.content.match(new RegExp(`/(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g`))
#

like that

pale vessel
#

Your previous code should work

#

Why are you changing it

young flame
#

it didnt

pale vessel
#

Then that's not the problem

boreal iron
#

Nope it can’t work because you can’t declare the regex as string

young flame
#

remove ``

#

right

pale vessel
#

You can

boreal iron
#

Nope not how he’s doing it

young flame
#

not a he

young flame
#

then like that?

pale vessel
#

(true on that one)

#

If it's already a regex then you don't need new RegExp()

delicate shore
#

ok so

pale vessel
#

But on this context your previous code (regex.test(message.content)) does the same

delicate shore
#

why isn't promise resolved

#

my code is this

pale vessel
#

I don't know why you think this is where the problem is

young flame
#

because the regex isnt testing for invites

sour oxide
#

Hey, does anyone know if on Discord, if a member leaves, are their channel permissions removed automatically?

young flame
#

period.

delicate shore
#
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);
        }
    }
}}```
young flame
#

yes

delicate shore
#

My code is this

#

I am resolving

#

promise

pale vessel
#

Have you tried the code itself?

young flame
#

yes

pale vessel
#

Your other code can be the one that stops it from working

young flame
#

i know the regex is working but it doesnt check it

pale vessel
#

Not that regex code

#

Then why are you changing the regex code lol

#

This is just bruh

cinder sandal
#

how do i make an if statement if the variable is the same number as another variable

#

test = test2 doesn't work

pale vessel
#

===

#

= is for assigning

young flame
#

i didnt change the regex?

pale vessel
#

Not the regex itself

young flame
#

probs should remeove new

pale vessel
#

The code that checks the regex

young flame
#

should that check it to?

#

shouldn't*

delicate shore
#

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

young flame
#

whats the problem

delicate shore
#

It says promise is not resolved but I'm resolving it

young flame
#

i dunno

delicate shore
#

Ok.....

quartz kindle
#

you need to await it

#

console.log(await test.random.joke())

delicate shore
#

But means all the users will have to await it ?

quartz kindle
#

yes

delicate shore
#

Is there any way I can do smth in my code to avoid that

quartz kindle
#

nope

delicate shore
#

Alright thanks

#

And sorry for being impatient

young flame
pale vessel
boreal iron
#

Stop define a var for the regular expression, you just use it once

young flame
boreal iron
#

Undefined because one of your conditions in your statement is not what it should be

young flame
#

hm

boreal iron
#

And I can tell you which one okeh

young flame
#

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

delicate shore
#

yay

#

Tim it worked

young flame
delicate shore
#

it worked

#

pog

boreal iron
#

Oh god since you will never get it working, gimme a second to switch to the PC

young flame
#

h-

delicate shore
#

Btw how can I add a rate limit ?

#

in my npm package

pale vessel
#

Just /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|st)|discord\.com\/invite)\/.+[a-z]/g.test(message.content.toLowerCase().replace(/\s+/g, ''))

young flame
#

where regx is

pale vessel
#

bruh

#

on the front

boreal iron
#

Still completely nonsense

young flame
#

front of regx

#

wut

young flame
pale vessel
#

never mind

#

But you don't need to assign it to a variable, just use <regex>.test(string)

young flame
#

oo

#

so i dont need regx

pale vessel
#

It's there

boreal iron
#
message.content.match(/.*(discord\.(gg|io|me|li)|discordapp\.com\/invite)\/.*/gi)
pale vessel
#

That works too

#

But .test() returns a boolean and it was their code so that should have worked too

#

No reason to change it

boreal iron
#

bullshitting double regex, declaring it as var and so on...

young flame
#

where woould that go?

cinder sandal
#

how do i edit my bot's embed message with an if statement
or if statement in .then?

pale vessel
#

An if statement

iron swift
#

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}`);
     };
   };
 });
boreal iron
#

did you actually post the code somewhere? can't find it @young flame

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: ('![RosesNo](https://cdn.discordapp.com/emojis/782971149260685312.webp?size=128 "RosesNo") | Link Deleted:\n**Invite links are not permitted on this server**') } }));
#

@boreal iron this?

pale vessel
#

They just assigned the regex to a variable

#

It's not that bad?

boreal iron
#

and using lowercase, and another regex to place

carmine summit
#

I wanna benchmark my cpu but vs code stops at 20% cpu usage....

boreal iron
#

... ocuh

young flame
#

O

pale vessel
#

and another regex to place
What do you mean Think

iron swift
carmine summit
#

what is the most resource hungry javascript function??

boreal iron
#
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**') } }));
pale vessel
#

Not sure but I thnk require("v8").getHeapSnapshot() is one of them

#

That's node though

carmine summit
#

javascript

#

i want vanilla

#

need*

young flame
#

hmmmmm?

iron swift
#

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}`);
     };
   };
 });
carmine summit
#

no wait

#

you need guild members intent

young flame
#
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?

carmine summit
#

you need guild members intent

#

that you can get

#

by contacting discord

#

and having your bot

#

verified

iron swift
#

Thanks man ❀️

young flame
#

probally should have blurred the invite

boreal iron
#

did u turn it on before testing?

cinder sandal
young flame
#

uh

#

yes

#

it was on

#

should i turn it off then on and try?

#

@boreal iron

pale vessel
#

how would that change anything

boreal iron
#

do it, dont ask for it

#

does is even change your db value?

young flame
#

uh

#

when i turn it on it puts it in my db

young flame
#

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

boreal iron
#

you turn it on to see if it's enabled ... WHAT KEKW

young flame
#

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?

boreal iron
#

yo it needs to add/remove modinvite_${message.guild.id}

#

does this step even WORK?

drifting wedge
#

i have this box that when u hover it shows a div

boreal iron
#

the regex is not your issue anymore

drifting wedge
#

in html

#

but it makes all the boxes bigger, not show the div

#

but just the place where the div shows opens

slender wagon
#

Hey anyone has a solution to a music bot running on errors whenever someone manually disconects them from the voice chat

cinder sandal
#

is editing a message after 10 seconds good? will it get ratelimit?

drifting wedge
#
    .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;
    }```
boreal iron
#

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

cinder sandal
#

is editing a message after 5 seconds good

pale vessel
#

No

boreal iron
#

display: inline-block;

pale vessel
#

Well it's fine if only once

boreal iron
#

or table, i dunno, don't see the elements

willow mirage
#

CSS brrrr

young flame
#

it works

slender wagon
boreal iron
#

console.log your conditions on your statement to check which one isn’t as it should be

young flame
#

ok

earnest phoenix
#

is it normal my nodejs cpu usage is at constant 100+%

pale vessel
#

No

willow mirage
#

lmao

#

upgrade ur vps

earnest phoenix
#

im using

#

ec2

#

t4g.large

willow mirage
#

tf is that

earnest phoenix
#

ec2 instance

#

aws

willow mirage
#

ah

earnest phoenix
#

and the cpu utilization in that doesnt reach 50%

willow mirage
#

then upgrade it

earnest phoenix
#

which is weird

willow mirage
#

idk

#

i don't use aws

#

so i dunno

drifting wedge
#

im back doe

boreal iron
quick ridge
drifting wedge
#

well i dont want inline block

#

i more like want like only that one to move

#

not all of them

drifting wedge
quick ridge
#

javascript

earnest phoenix
boreal iron
young flame
#

now it workS

boreal iron
#

I mean the regex wasn’t your issue but who cares... it works is what matters

lucid prawn
#
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
tribal siren
boreal iron
#

What do you think where we are?

tribal siren
#

in development

#

oh wait

#

oooooh

lucid prawn
#

lol

tribal siren
#

sry

carmine summit
#

Why is the typingStart seem buggy???

narrow marten
lucid prawn
#

i try that @tribal siren

carmine summit
#

no no

#

it doesnt register

#

sometimes

young flame
carmine summit
#

sometimes it register

narrow marten
carmine summit
#

sometimes it dont

narrow marten
#

probably u will get like 10 seconds instead of 15

#

mm what help do u need

south aspen
#

is discord-mongoose-money is better than discord-money for making currency system

young flame
#

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: ("`![RosesNo](https://cdn.discordapp.com/emojis/782971149260685312.webp?size=128 "RosesNo") | 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
narrow marten
#

its funny how I still dont know how to collect messages with bot

#

rip

pale vessel
#

const messages = messages.collect();

young flame
#

should the wrole be like args 2 or something

narrow marten
pale vessel
#

that was a joke

narrow marten
#

knew it

#

its like on something then collect message

lucid prawn
narrow marten
#

aaaa I forgot gotta see docs

boreal iron
tribal siren
#

@lucid prawn did it work

lucid prawn
valid grotto
#

@narrow marten const collector = new Discord.MessageCollector() ?

boreal iron
young flame
#

oki

boreal iron
#

If not stop return the function always without any output

boreal iron
#

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

valid grotto
# narrow marten mhm and?

collector.on('collect', message => {}) to collect it make sure to put the filters in MessageCollector(<filters>)

narrow marten
#

ooo

#

then message is the message collected right

astral yoke
#

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"

tardy hornet
#

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"});```
astral yoke
#

are the servers cached

tardy hornet
#

yes

#

i hope

astral yoke
#
cacheGuilds: true
})```
#

does it look like that

tardy hornet
#

no

#

like that

pale vessel
#

Don't think that's a valid ClientOptions

tardy hornet
#
const bot = new Discord.Client({disableEveryone: true,
    partials:["MESSAGE", "CHANNEL", "REACTION"]
  })
pale vessel
#

Add "GUILDS"

tardy hornet
#

okay

pale vessel
#

oh wait that's partial

devout frost
#

guilds are cached by default.

#

No need for any special needs.

tardy hornet
#

so how do i fix that?

#

please

#

someone

devout frost
rustic nova
#

from the discord oauth screen

tardy hornet
#

^

ebon topaz
#

Hi

tardy hornet
#

so what should i do?

rustic nova
tardy hornet
#

should i do that:

#
const bot = new Discord.Client({cacheGuilds: true, disableEveryone: true,
    partials:["MESSAGE", "CHANNEL", "REACTION"]
  })
#

will it work then?

devout frost
#

Thats not a valid clientOption, so no

sudden geyser
#

must go partials -> ws -> intents

devout frost
#

disableEveryone is also not a valid clientOption

sudden geyser
#

where did you even get cacheGuilds from

tardy hornet
#

just please what to do

devout frost
#

I suggest you try to ask on the djs server, maybe they have a clue.

sudden geyser
#

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

tardy hornet
#

so what to do?!?!

devout frost
#

if you don't specify any intents in the clientoptions, all should be used by default

sudden geyser
#

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: [...] } }

sudden geyser
tardy hornet
#

so, i still dont get what i need to do here

young flame
#

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

devout frost
tardy hornet
#

@devout frost and @sudden geyser , in the website it says the right amount

#

and its the same code

sudden geyser
#

can you show us how you're posting it

tardy hornet
#

yes

quartz kindle
#

then thats why

#

its showing the guilds for the current shard

tardy hornet
#

how do i make it show the total tho

quartz kindle
#

if you're using the sharding manager you need broadcastEval

tardy hornet
#

i do

#

use the sharding manager

tardy hornet
#

how do i use broadcastEval

quartz kindle
#

scroll to broadcastEval or fetchClientValues

#

both work

young flame
summer torrent
#

just use has()

tardy hornet
#

@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);
knotty obsidian
#

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

tardy hornet
#

${results.reduce((prev, val) => prev + val, 0)}

#

this?

#

@earnest phoenix ^

young flame
#

nope

quartz kindle
#

they dont want to post it

#

they want to show it in their bot status

#

the posting already works

tardy hornet
#

the web is working

#

its giving me errors

#

SyntaxError: await is only valid in async function

ember lodge
#

Someone knows a npm package to read bar codes? steve_lol

tardy hornet
#

but what do i do with the await

#

i think i know why wait

twilit geode
#

is there a way to convert an integer into ascii in js

#

so like 65 would go to a

quartz kindle
#
async () => {
  result = await promise()
  // use result here
}
// or

() => {
  promise.then(result => {
    // use result here
  })
}
``` @tardy hornet
tardy hornet
#

@earnest phoenix okay i fixed that

#

i fixed that

#

ty guys

reef stag
young flame
#

nopee

#

didn't work

#

nope

valid grotto
young flame
#

role id yes

#

yes

valid grotto
#

if it's an id try cache.get(whitelist) instead

young flame
twilit geode
quartz kindle
#

if its an id you dont need to get it

#

roles.cache.has(whitelist)

young flame
#

ok

quartz kindle
twilit geode
#

range is max-min+1; im probably doing something really dumb, i just dont see it

young flame
#

still doesn't work

reef stag
#

ok

#

how i can fix it? MegaThonk

young flame
#

im storing the role like

quartz kindle
hollow sedge
#

Import it from the correct package @reef stag

#

Look at the link I sent

young flame
#

whitelistedil_guildid_role id

hollow sedge
#

At the top

dapper ocean
#

What is the best database for a discord bot okeh

twilit geode
quartz kindle
#

there is no best database, but there are many good ones

#

i personally like sqlite

dapper ocean
#

Is sqlite better than mongo?

hollow sedge
#

They both have different use cases

reef stag
#

i can't import it "right"

hollow sedge
#

net.dv8tion.jda.bot.sharding

delicate shore
#

I would say use MongoDB

reef stag
hollow sedge
dapper ocean
#

Hm

hollow sedge
#

If I'm not mistaken, I believe that SQL is faster

young flame
#

@quartz kindle im storing the roleby guild

#

loike

hollow sedge
#

Also MongoDB does not have a good async driver (on Python at least)

young flame
#

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

earnest phoenix
hollow sedge
#

@reef stag mb, you had the correct import

#

I looked up an older version

reef stag
#

which

#

version

carmine summit
#

I would say use quickdb

reef stag
hollow sedge
#

3 I think lol

#

And I just looked at the github repo

carmine summit
#

Be simple. You might not have enough knowledge to do mongo db

#

Start with quickdb

quartz kindle
hollow sedge
reef stag
carmine summit
#

Even I don't understand it :D

ember lodge
#

Someone knows a npm package to read bar codes?

reef stag
#

no

hollow sedge
#

@reef stag

reef stag
#

3.4.0_317?

earnest phoenix
#

is there a way i can get only 10 documents with collection.find(); mongodb?

hollow sedge
#

@reef stag either way you should just update to the latest version

#

if you are not already on it

reef stag
#

i use the newest version of JDA

#

and it doesnt work after export

hollow sedge
#

Then you're good

earnest phoenix
#

ah i see

reef stag
earnest phoenix
#

thanks

hollow sedge
knotty obsidian
#

how can i remove a permission overwrite

tardy hornet
#

why its not showing the status on him?

quartz kindle
#

blame discord

tardy hornet
#

oki

young flame
tardy hornet
#

in one server it dose

young flame
#

blame discord

kindred musk
#

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)```

tardy hornet
knotty obsidian
#

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

quartz kindle
young flame
#

How would you save it in quick.db then?

quartz kindle
#

how did you save it?

earnest phoenix
#

Pls @ me Do developers have to make it so the bot can only say nsfw things in a nsfw channel?

quartz kindle
#

yes

eternal osprey
#

@earnest phoenix YES

ivory seal
#

hey are there any alternative to setTimeout for timed mutes?

solemn latch
#

scheduling

ivory seal
#

wdym

quartz kindle
#

there are no alternatives to the setTimeout function, but there are alternative ways to use it, depending on your needs

sudden geyser
ivory seal
#

oh could you link me to those?

#

cause setTimeout's are not "persistant"

#

it resets after restart/crashj

quartz kindle
#

no they are not, you have to take care of that yourself

ivory seal
#

ah kk

quartz kindle
#

store timestamps in a file or a database, then restart the timeout based on those timestamps

ivory seal
#

ah ok

#

got it

solemn latch
#

ive never used scheduler, but isnt that what it does?

quartz kindle
#

the node-schedule package uses cron

earnest phoenix
ivory seal
#

did u install node?

earnest phoenix
#

no

old latch
#

lol

earnest phoenix
#

they why are you here?

pale vessel
#

Well you need to

rustic nova
#

dbl in a nutshell ladies and gentlemen

#

This is still not a marketplace dude

latent cave
#

Wait what

#

I'm asking for a help

rustic nova
#

if you don't know where to add the token, then you're not ready to code a bot. see #502193464054644737

latent cave
#

Okie

ivory seal
latent cave
#

So where do I have to add the token?

rustic nova
fierce ether
#

how do i grab a random user id from db, this dosent work, returns dup error const player1 = await queueConfig.findOne('userId');

cinder patio
#

Give us more details

ivory seal
#

lel

fierce ether
#
    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

latent cave
#

oops

#

Hold on

#

@rustic nova Thanks for saying, Is this right?

rustic nova
earnest phoenix
latent cave
#

:/

sudden geyser
#

keep waiting

sudden geyser
surreal sage
#

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?

sudden geyser
#

What language are you writing in, and what is the collection (is it a custom class, like discord.js' Collection class)

surreal sage
#

discord.js's

sudden geyser
#

I think the method .last() exists.

surreal sage
#

that would get the last last

#

the actual last

#

but i want the one before the last

#

um

#

your taking your time i see

earnest phoenix
#

@sudden geyser wdym

#

i did node .

sudden geyser
#

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.

earnest phoenix
#

im confused ahah

sudden geyser
#

are you sure you did node .

earnest phoenix
#

ye

sudden geyser
#

can you show your full console