#development

1 messages ยท Page 1438 of 1

timber fractal
#

i cant find

quartz kindle
#

users.get(id) = User
members.get(id) = Member
members.get(id).user = User

proper bolt
#

you cant get everything spoonfed

gilded olive
#

does it not auto convert the user to an id?

earnest phoenix
ruby niche
#

Hello ! I'm trying to insert new request in sequelize dynamically but I don't find a way to do ... Here my basic request

// ...
where: {
  [Op.or]: {
    field1: {[Op.like]: `%${value}%`},
    field2 : {[Op.between]: [...]}
}
// ...

The fact is that I want to add a new value to search into field1 and being able to find rows that can contain one of both value but I don't know how to add this new value and I don't know how many new value have to be queried ... A loop is required ... but how to create this request, i don't know
PS : just doing this bellow isn't enough sadly

//...
field1: {[Op.like]: `%${value}% %${value2}%`}
//...

Is someone better than me please ;-; ?

umbral zealot
#

we need a lot more information

#

a lot more.

quartz kindle
#

looks like dblapi.js

umbral zealot
#

401 is very general lol

earnest phoenix
#

bot.js
dblapi.js error

quartz kindle
#

dblapi.js has Oops! ${err} in their example pages

proper bolt
#

probably not providing a token, or its invalid

quartz kindle
#

so i recognize the error structure

gilded olive
#

you need an key right?

quartz kindle
gilded olive
#

token is probably not being provided or it is invalid

umbral zealot
sterile lantern
#

i have an array as my cmd handler but not a collection, so how would i work with cooldowns

#

i looked at djs docs

#

but thats for cmd handlers as a disc collection

proper bolt
#

you could do something like a Set or whatever with timestamps and the command name

#

set a cooldown after its ran

earnest phoenix
#

ah sorry :/ I forgot it

#

Thank you

sterile lantern
#

yea but i dont wanna do that for all the cmds

#

i just want it

#

in index.js

#

i have a module.exports config

proper bolt
#

so how are you storing the commands

sterile lantern
#

so i can just do

proper bolt
sterile lantern
#

coooldown: 5,

#

like that

#

yes

#
const commandName = args[0].toLowerCase();
    args.shift();
    const command = commandList.find((cmd) => cmd.name === commandName || cmd.config.aliases.includes(commandName));
    if(!command) return;```
proper bolt
#

you could do something like const cooldown = {commandName:[ {user id: timestamp} ]};

#

then if it doesnt exist or is past 5 seconds

sterile lantern
#

lemme shwo u what i have for cooldowns rn

#

show*

proper bolt
#

set the value to Date.now()

sterile lantern
#
 const cooldown = new Discord.Collection();
  if (!command.config.cooldown) {
        cooldown.set(commandName, new Discord.Collection());
    }

    const now = Date.now();
    const timestamps = cooldown.get(commandName);
    const cooldownAmount = (command.config.cooldown || 3) * 1000;

    if (timestamps.has(message.author.id)) {
        const expirationTime = timestamps.get(message.author.id) + cooldownAmount;

        if (now < expirationTime) {
            const timeLeft = (expirationTime - now) / 1000;
            return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
        }
    }

    timestamps.set(message.author.id, now);
    setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);```
proper bolt
#

yeah

#

is that not working?

sterile lantern
#

nope

#

the command doesnt error

#

but

proper bolt
#

what about it doesnt work

sterile lantern
#

the cooldown

#

doesnt work

#

it lets me repeat the commands twice

#

in 5 secs

#

the cooldown is 5 sec

timber fractal
#
const canva = require('canvacord');
const Discord = require('discord.js')

module.exports = {
    name: "trigger",
    description: "Triggers somebody",

    async run (client, message, args) {
        const member =  message.mentions.members.first().user() ||  message.guild.members.cache.get(args[0]).user() ||message.author;

        let avatar = member.displayAvatarURL({dynamic: false, format: "png"});

        let image = await canva.Canvas.trigger(avatar);

        let triggered = new Discord.MessageAttachment(image, "triggered.gif")

        message.channel.send(triggered);
    }
}  ``` Why if i use this it says "cannot read property of user of undefined"?
sterile lantern
#

user isnt defined

proper bolt
#

no

sterile lantern
#

i think

#

idk

timber fractal
#

so

#

what

#

?

proper bolt
#

the property where he is getting user on is undefined

sterile lantern
#

o

proper bolt
#

message.mentions.members.first()

#

there is no mention

timber fractal
#

what

#

but

#

thats true

#

but

#

why

#

its not getting another one of them

proper bolt
#

what

timber fractal
#

like there is no mention it goes to control if there is a Id or if there is no ID it just returns the message.author

proper bolt
#

what

timber fractal
#

like

sterile lantern
#

im thinking maybe const cooldown = new Discord.Collection

proper bolt
#

ok ill take a look at your cooldown stuff

sterile lantern
#

because my commands are in an array

timber fractal
#

i made this so first it tries to see if the author mentioned somebody and if thats not true it see if the author sent someaones ID and then if there is no ID too it will returns the message.author

proper bolt
#

no but you could do

msg.mentions.members.size ? message.mentions.members.first().user() : msg.author
sterile lantern
#

i tried doing client.cooldown = cooldown

proper bolt
#

thats not the problem

sterile lantern
#

but that obvs doesnt work since cooldown is just being defined

misty sigil
#

I do

proper bolt
#

log the collection

sterile lantern
#

wym

proper bolt
#

if (!command.config.cooldown) {
cooldown.set(commandName, new Discord.Collection());
}

#

shouldnt this be

#

if (command.config.cooldown) {
cooldown.set(commandName, new Discord.Collection());
}

sterile lantern
#

no

#

its saying if theres no cooldown

#

then set one with

#

wait

#

o

#

one sec

proper bolt
#

if there is one then it doesnt set it

sterile lantern
#

i mean i did that

#

but

#

it still doesnt trigger

#

the cooldown

#
const config = {
    description: 'Shows a list of commands.',
    aliases: [],
    usage: '',
    cooldown: 5,
    rolesRequired: []
}```
#

its in the config

#

i think theres something wrong with the timestamp stuff

#
const now = Date.now();
    const timestamps = cooldown.get(commandName);
    const cooldownAmount = (command.config.cooldown || 3) * 1000;

    if (timestamps.has(message.author.id)) {
        const expirationTime = timestamps.get(message.author.id) + cooldownAmount;```
#

command.config.cooldown

#

that should work

proper bolt
#
  const cooldown = new Discord.Collection();
  if (!command.config.cooldown) {
        command.config.cooldown = 3
  }
    if (!cooldown.has(commandName)) cooldown.set(commandName, new Discord.Collection());

    const now = Date.now();
    const timestamps = cooldown.get(commandName);
    const cooldownAmount = (command.config.cooldown || 3) * 1000;

    if (timestamps.has(message.author.id)) {
        const expirationTime = timestamps.get(message.author.id) + cooldownAmount;

        if (now < expirationTime) {
            const timeLeft = (expirationTime - now) / 1000;
            return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
        }
    }

    timestamps.set(message.author.id, now);
    setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
#

try that

#

you were resetting the commands cooldown every run

sterile lantern
#

doesnt work

#

it jsut

#

just*

#

lets me use help twice

#

without restricting me

#

this is in seconds right

#

if its in millseconds then its obvs not working for a reason

#

milliseconds*

proper bolt
#

*1000 gets you ms from s

sterile lantern
#

so its in s

#

yea idk why it doesnt work

proper bolt
#

one sec ill try running it

sterile lantern
#

i think its bc my cmd file isnt requiring it?

#

not sure

#

yea bc

#

const config = {

#

when i type aliases it automatically pops up

#

doesnt happen for cooldown

proper bolt
#

wait do you have const cooldown = new Discord.collection in on message

sterile lantern
#

yes

proper bolt
#

move it out of it

sterile lantern
#

wow im so so dumb

#

it works

#

tysm

#

wait but

proper bolt
#

i thought you had it outside on message

#

lmao

sterile lantern
#

how would i set custom

slender wagon
#
 if(!reason) reason = 'Unspecified';
                           ^

TypeError: Assignment to constant variable.
``` what have i done wrong
sterile lantern
#

cooldown msgs

#

for each cmd

proper bolt
#

@slender wagon reason is a const

#

change it to let

sterile lantern
#

like You cannot rob <user> for another <>!

slender wagon
proper bolt
#

you can use ${commandName}

#

you could make like a property on the command called cooldownMsg

sterile lantern
#

hm

#

const cooldownMsg = 'msg'

proper bolt
#

and make it you cannot do whatever for <S> seconds

#

and then replace <S> with the seconds

earnest phoenix
#

Sigh.... anyone know how I can connect my coding to my discord bot?

sterile lantern
#

yeah i want to make it so u cant rob for 2 hours

#

but it will show in seconds

#

so i want that to convert to hours

earnest phoenix
proper bolt
#

what

#

thats html

midnight blaze
#

@earnest phoenix where is the coding?

proper bolt
sterile lantern
#

but then that would

#

apply to all cmds

#

eek

#

wait

proper bolt
#

no

#

you could make the thing <H> in the message

#

and replace <H> with hours

#

or

sterile lantern
#

so in the cmd

#

have

#

const cooldownMsg = 'text'

#

right

proper bolt
#

its one way of doing it

sterile lantern
#

then in index.js

proper bolt
#

yeah

sterile lantern
#

have it call the cooldownMsg

#

and send that

#

but idk how to do that exactly

proper bolt
#

you could then do command.cooldownMsg.replace('<H>', hours)

sterile lantern
#

return message.reply(cooldownMsg);

#

but how would i define cooldownMsg in

#

index.js

proper bolt
#

return message.reply(command.cooldownMsg.replace('<H>', hours))

#

or whatever

#

its one way of doing it

sterile lantern
#

ohhh

#

ok

#

command.cooldownMsg

#

would work

#

for

#

just having it in the cmd

#

ok that made no sense

#

// in index.js:

return msg.reply(command.cooldownMsg)```
#

example of a non-hour cooldown

earnest phoenix
#

how do you set a bots status? i cant seem to find anything

proper bolt
#

client.user.setActivity()

#

if its discord.js

earnest phoenix
#

its dsharpPlus

sterile lantern
#

client.user.setActivity

#

o

#

what is that?

earnest phoenix
#

C#

sterile lantern
#

o

#

yeah i never programmed in that

earnest phoenix
#

oh shit tysm

sterile lantern
#

ok i did it

#

now i just gotta uh

#

fix the cooldownMsg for robbing

#

oh uh

earnest phoenix
#

hi

sterile lantern
#

timeLeftofixed is not defined

#

oh gawd i gotta add that in all cmd files

#

oooof

earnest phoenix
#

@sterile lantern just use fs to write to every single file

sterile lantern
#

huh

fallow lichen
#

what is the best libraries and database with a bot?

sterile lantern
#

depends on how complex you code

#

not really but

#

if ur a beginner in js

#

quick.db is a great db 2 use

fallow lichen
#

do you have any with python?

sly panther
#

Hey, I'm new to discord bots, but does anyone know a bot that can do a reaction role that triggers a "@mention"?

knotty obsidian
#

how can i make a uban command
when i made it and used it, it throws an index out of bounds exeption

#

idk why

#

do i need to fetch the bans and remove the selected ban?

fallow lichen
knotty obsidian
#

how can i do that

sterile lantern
#

or honestly use the unban function

#

that should work

knotty obsidian
#

i am

sterile lantern
#

and catch error

#

if they aren't banned then it sends "user is not banned!'

#

example

knotty obsidian
sterile lantern
#

p

#

o*

#

uhh idrk about unbanning, never did anything related to it

#

lol

sly panther
outer perch
#

congrats, before verification, i could get the users' presence, now I can't ๐Ÿ˜ฆ

hollow sedge
#

You need to enable the intent in the dashboard @outer perch

outer perch
#

I haven't reached 100 members yet

hollow sedge
#

You just said you got verified?

outer perch
#

yes

#

before 100

lilac lake
#

Hi I can't get to put the bot I created in my server

hollow sedge
#

Why don't you just try enabling it

outer perch
hollow sedge
lilac lake
#

Okay

outer perch
#

๐Ÿคท๐Ÿปโ€โ™‚๏ธ

hollow sedge
#

Well I cant think of any other reason for why it would stop

sterile lantern
#

how would i make the bot say:
Please wait **1 hour 5 minutes 3 seconds** before using this command!

#

at the moment its using
const timeLeft = (expirationTime - now) / 1000;

outer perch
#

or just wait until 100?

sterile lantern
#

are you verified dev?

#

or is that on a team?

hollow sedge
#

You might as well ask them

sterile lantern
#

because if your bot is in 100 servers

#

you cant do that manually

terse berry
#

Hello

hollow sedge
#

It's not, they just explained that

terse berry
#

How do you make the up and down moving animation for your bots logo

earnest phoenix
#

discord activity doesnt exist

#

lol

hollow sedge
#

Bruh

hollow sedge
terse berry
#

Hm?

#

On your bots page

outer perch
terse berry
#

Like Carl bot has I think

hollow sedge
#

You just leaked your token

earnest phoenix
#

fuck

terse berry
#

Lmfao

earnest phoenix
#

well then

sterile lantern
#

u should regenerate that

#

there may be token snipers in here

earnest phoenix
#

already did

outer perch
#

you never know ๐Ÿ‘โ€๐Ÿ—จ

earnest phoenix
#

well gl with that i already changed it

#

:)

terse berry
#

Does someone know how to make animation for your bot's logo on top.gg page with html

hollow sedge
#

Can't you just inspect to see how it was done

terse berry
#

Hmm

sudden geyser
# sterile lantern how would i make the bot say: `Please wait **1 hour 5 minutes 3 seconds** before...

It seems you want to make the date shown relatively. You could use the ms package to show the time in a human friendly form ("X hours", "Y minutes", "Z seconds", etc.). If you want to be more specific ("X hours, Y minutes and Z seconds"), you could use the modulo operator with the ms package to get the total for each time frame.

Of course, you could implement it yourself. Get the time in ms, divide enough to get it in hours, and say how much time from there. ```js
// now is Date.now() + 10000 (10 seconds in the future)

${(now - Date.now()) / 1000} seconds


Maybe the `moment` package has something in store for you.
outer perch
#

so i did a false affirmation, the app wasn't trasnferred to the team

sterile lantern
#

uh

#
`Please wait ${timeLeft.hours}h ${timeLeft.minutes}m ${timeLeft.seconds}s before reusing the \`${command.name}\` command,` + `${message.author}` + '!'``,```
#

i have this

#

in

#

my cmd

#

but

#

timeLeft is index.js

#

so how do i define that

#

because if i define timeLeft

#

i would have to define commandList

#

then commandName

#

then command

#

in the command file

#

should i just do const timeLeft = require('../index.js')

outer perch
#

check moment.js documentation

sterile lantern
#

but i dont think that would work

#

i cant really use moment.js

#

because

hollow sedge
#

Wait whst

sterile lantern
#

the cooldown is set in index.js

hollow sedge
#

How is timeLeft index.js

sterile lantern
#

i just want a custom cooldown msg

#

because

#

its in there

#

but im saying that wont work

hollow sedge
#

Oh

sterile lantern
#

so i dont know how else

#

to define timeLeft

#

without adding the cooldown function into my cmd file

terse berry
sterile lantern
#

wait so if a file is in a command folder

#

how would i require index.js

#

..index.js wont work

#

./index.js doesnt work either

hollow sedge
sterile lantern
#

../index.js

#

hm

terse berry
#

oh god im dum

sterile lantern
#

yea i dont know how this is going to work ;-;

terse berry
#

I'm not able to find a bot where it is animated wtf

sterile lantern
#

well i did this

#

and i got this

#

Please wait undefinedh undefinedm undefineds before reusing the rob command

#

it comes out as undefined

#
cooldownMsg: `Please wait ${timeLeft.hours}h ${timeLeft.minutes}m ${timeLeft.seconds}s before reusing the rob command, `,```
cinder sandal
#

timeLeft doesn't hve a hours and munites and seconds property

sterile lantern
#

o

#

well

cinder sandal
#

instead, use

sterile lantern
#

if i just did

#

{timeLeft}

#

it comes out

#

as

#

object object

cinder sandal
#
${timeLeft.toFixed(1)}```
sterile lantern
#

but timeLeft is defined in index.js

#

what does that do/

#

?

cinder sandal
#

it would show only seconds, i don't know how to show hours etc.

sterile lantern
#

oooof

cinder sandal
#

it shows the seconds remaining

sterile lantern
#

yea that sucks

#

i need 2 hours

#

or should i just do

cinder sandal
#

like 10.0s

sterile lantern
#

ik

#

i want 2 hours 0 minutes 0 seconds

#

like that

#

๐Ÿ˜”

#

let time = ms(timeout - (Date.now() -cooldown));

#

this will work

#

buttt

#

the only problem is that time wont be defined in the command

#

since its in index.js

#

ugh

#

wait

#

maybe i should do

#

then

#

message.channel.send(this msg)

#

would that work

terse berry
copper cradle
#

css

terse berry
#

hmm

copper cradle
#

oh wait

#

no

#

that's an iframe

#

and if you're talking about the background image then yes

#

it's css

terse berry
#

like

#

just how

#

lol

sterile lantern
#

AYYY OMG I DID IT

#
if (`${command.name}` === 'add-xp') return message.reply("this will work")```
terse berry
#

@copper cradle do you know how to do it in css

sterile lantern
#

it replied with this will work

#

:DDDD ok perfect

#

ty all sm

earnest phoenix
#

Hey! I literally have no idea what I'm doing, and now I own a Moderation bot, and a Music bot, if someone could help me please do, because I spent 11 hours yesterday making them, and I probably messed up so hard, because now they are offline :D

sterile lantern
#

check ur logs

#

also, my cooldowns reset if my bot restarts

#

anyone know how 2 change that

#

or maybe i should save it with a db

#

idk

knotty obsidian
#
if (ReplacePrefix.startsWith("unban")) {
  if (event.getMember().hasPermission(Permission.BAN_MEMBERS)) {
    event.getGuild().unban(event.getMessage().getMentionedUsers().get(0)).queue();
    event.getChannel().sendMessage("Successfully unbanned " + event.getMessage().getMentionedUsers().get(0).getName()).queue();
  } else {
    event.getChannel().sendMessage("You must have the `Ban Members` permission to use this command!").queue();
  }
}

When I do S!unban <@{userid}> it sends a index out of bounds exception, how can i fix this?

sterile lantern
#

what are you coding in??

knotty obsidian
#

java

sterile lantern
#

oh makes sense

#

uh

#

try doing S!unban

#

if it sends "Sucessfully unbanned" something wrong wth ur error msgs

#

with*

knotty obsidian
#

also send index out of bounds

sterile lantern
#

o

#

rip

#

not too sure abt this one

knotty obsidian
#

people say .unban(user) should work

#

is ther somthing wrong with .get(0)

earnest phoenix
#

hi

#

does node.js have support for Web Audio API?

#

I'm making a music botum

sterile lantern
#

so currently my db

#

has money stored as

#

money_${message.author.id}

#

so i want to make a leaderboard

#

how would i fetch ALL the values of money

#

i dont think this would work

#
let money = db.fetch(`money_`, { sort: '.data'})```
earnest phoenix
#

@sterile lantern make an index

crimson vapor
#

im still waiting

restive furnace
#

@earnest phoenix ffmpeg

sterile lantern
#

for what

earnest phoenix
sterile lantern
#

also why is it saying it cant read property of length for this

#
for (let i = 0; i < money.length; i++) {```
restive furnace
#

@earnest phoenix yes dont ask i odnt know anything abtnit

earnest phoenix
#

@sterile lantern just keep an index of people's money with their ids there and then just sort it

#

the stuff you already store in database should be fine

sterile lantern
#

in my db

#

its just

#

money_userid

#

so how would i sort the top money

#

like that

#
let money = db.fetch(`money_`, { sort: '.data'})```
#

this doesnt work unfortunately

solemn latch
#

what lib is this?

sterile lantern
#

for me?

#

im using d.js

solemn latch
#

for your database

crimson vapor
#

quickdb?

#

Woo congrats on bot reviewer

sterile lantern
#

quickdb

#

yes

solemn latch
#

ty pogey

#

does quickdb even have a sort parameter?

coarse galleon
#

So this is where you pay for advertising

sterile lantern
#

uh

#

yes

#

i think so

earnest phoenix
#

@sterile lantern try adding a money_index property to every Guild object in your code which is a Discord.Collection

#

then just set stuff in that when people run economy commands

umbral zealot
coarse galleon
#

Ah so sorry

earnest phoenix
#

and when somebody requests the leaderboard, sort the Map and send it in the channel

sterile lantern
#

uh

#

well

#

its just one server

#

so i dont wanna add a guild object

#

is it not possible

#

to sort

#

from the users

#

its just

#

money_id

#

so i just sort the integer

#

from money_id

#

see if i were to fetch a users bal

#

so how would i just fetch everyones bal?

sand condor
#

can you stop typing like that

solemn latch
#

db.all()

sterile lantern
#

well that would fetch everything in the db

#

i just want all money

#

not the cooldown stuff

solemn latch
#

One of the major issues with quickdb is it has hardly any features.

terse berry
#

@solemn latch oh wow you're a bot reviewer now

solemn latch
#

yeah pogey

ionic ermine
#

Why is this code not working on the site?

    border-radius: 50% !important;
    border: 3px solid purple;
    animation: float 5s ease-in-out infinite;
}```
sterile lantern
#
 let user = bot.users.cache.get(money[i].ID.split('_')[1]).username```
#

username is undefined

#

well it says it cant read the property rather

terse berry
#

Does anyone know how to add dropshadow to the comment text on your bot page?

sterile lantern
#

well i guess this is good news, kinda?

#

except for the fact it doesnt have the user which ill fix in a sec

#

how would i make it so it only prints the numbers 660, 597, 3, 0

#

aka the four balances

#

and this doesnt work for some odd reason

#
    let user = bot.users.cache.get(money[i].ID.split('_')[1]).username```
knotty obsidian
#

anyone know how to make a uban command

sudden geyser
#

IndexOutOfBoundsException is coming from event.getMessage().getMentionedUsers().get(0), so for some reason, no users were mentioned in the message.

#

or no users are being recorded as mentioned when it should

terse berry
#

Can someone tell me how to add text shadow to a text on the bot's page?

compact nexus
#

How can I define the private library in my robot

terse berry
#

robot

sudden geyser
terse berry
#

but where do I put it

tired panther
#

which coding language?

molten yarrow
terse berry
#

uh

compact nexus
#

How can I add the library in my bot

sudden geyser
#

You need to be specific.

#

What library.

compact nexus
terse berry
sudden geyser
#

Do you want to install a library?

molten yarrow
umbral zealot
tired panther
terse berry
#

I can't find anything

compact nexus
#

thx

tired panther
#

loading no problem

upper elm
#

Is there any way to make a global variable through files? I'm learning about using a command handler and I understand now but other than module.exports is there any way to make a global variable that can be acessed through all my files

wind vault
#

Hello, how are you? I need to know how to do a say command that the bot can say anything with more than 1 arg, how is it done? in discord.py

compact nexus
#

๐Ÿ™‚

molten yarrow
terse berry
#

hmm

molten yarrow
terse berry
#

uuh

#

just a sec

upper elm
molten yarrow
upper elm
#

alr

sudden geyser
# upper elm Is there any way to make a global variable through files? I'm learning about usi...

You could set a global variable under the global scope, but people tend not to do that since it stems from memory leaks: js global.x = "y"
You could also do what Alina said and export and import from another file. I'd only use the global approach if you want something to live through the entire lifespan of the program and don't want to go through the hassel of exporting and importing

upper elm
#

ok thank you

sterile lantern
#

how would you make it so a user can specify a user ID and it returns that user id's profile

#

i forgot

upper elm
#

discord.js?

sterile lantern
#

yes

#

const user = message.mentions.users.first() || message.author

#

thats what i have rn

#

but thats checking for mentions

#

i want user ids to be a valid 'user' too

molten yarrow
sterile lantern
#

uh

#
message.guild.members.cache.get(args[0])```
#

would this work

molten yarrow
#

if that id is cached yes

sterile lantern
#

oof it doesnt work

molten yarrow
#

where did you put it?

sterile lantern
#

after const user

#

const user = message.mentions (that function) || msg.author || then that

terse berry
#

@molten yarrow Ok, it worked, thanks a lot

molten yarrow
#

you should check before message.author

sterile lantern
#

o

#

ok

molten yarrow
#

message.author is always true

molten yarrow
sterile lantern
#

and still deosnt work

#

doesnt*

#

i dont think message.guild.members.cache.get(args[0])

upper elm
sterile lantern
#

looks for ID

earnest phoenix
#

Nobody pings users like this: hey 503948134439976972 how's your day going?

sterile lantern
#

mhm i dont want them to ping

tired panther
sterile lantern
#

i just want their user ID

#

to work

earnest phoenix
#

why can't you just let them ping users

sterile lantern
#

its just a different way

#

so ppl dont get annoyed if someone spams

tired panther
#
client.guilds.cache.get(message.guild.id).members.cache.get(message.author.id)
``` @sterile lantern
sterile lantern
#

the ;profile cmd

#

o

#

ty

earnest phoenix
#

I designed a single line of code a few months ago that had every single way to find a user from the message so you can ping them or send the id or even just send the username

#

ONE SINGLE LINE

wind vault
#

ยฐayuda

earnest phoenix
#

i thought it's in my backup repl somewhere in my profile command too

#

what a coincidence

sterile lantern
#

ok turns out that doesnt work

#

uhh

crimson vapor
#

why would you want a line of code so long

sterile lantern
#

how would i make it so

#

the nickname of the user

#

is a valid option

#

so ;profile samm

sterile lantern
#

that doent

#

doesnt*

#

returns as undefined for message.author

restive furnace
#

maybe bcs not cached

#

pls use fetch instd

tired panther
#

give ur parameters @sterile lantern , which u overgive the command

sterile lantern
#

the ones that i use

#

like message.author

#

?

#
  const user = message.mentions.users.first() || client.guilds.cache.get(message.guild.id).members.cache.get(message.author.id) || message.author ```
#

thats terribly formatted but ignore

crimson vapor
#

thats redundant

tired panther
#

it woeks by me

crimson vapor
#

it works but no point

#

you are doing

sterile lantern
#

all i want is

#

;profile samm

#

to display my profile

#

say my nickname is

#

james

#

;profile james

obsidian meadow
sterile lantern
#

would display my profile

crimson vapor
#

user = first mention || cache.get guild .get author || author

sterile lantern
#

o

#

hm

#

actually doing ;profile james would result in conflict

#

so uh

#

just user ID

#

ig

pale vessel
#

what

earnest phoenix
#

Can't find it

#

What?

tired panther
crimson vapor
pale vessel
#

Bismillah

tired panther
#

bruh

earnest phoenix
#

@pale vessel for what lol?

#

But i remember it thoroughly tho (you never know it might come handy)

crimson vapor
#

marco best mod

earnest phoenix
#

LOL

pale vessel
#

Marco uses his macros

earnest phoenix
#

why u shitposting here

modern sable
tired panther
#

xD

crimson vapor
#

@modern sable you best mod

earnest phoenix
#

@modern sable itโ€™s just a small Code itโ€™s secret

sterile lantern
#

author id

tired panther
#

yes and u want the name

#

or nickname?

sterile lantern
#

well either of those

#

can result in conflict

#

so i think id

#

will be better

#

since if two ppl have same nickname bot chooses random one

#

so yea

wind vault
#

How is it done for when a person puts an invalid or incorrect command that the bot tells him which command is not available?

sterile lantern
#

just do !command

#

if(!command) return msg.reply("That is not a valid command");

tired panther
sterile lantern
#

aight then ill just use id

#

since its simpler

#

ty for da help

tired panther
#

xD. good conclusion

crimson vapor
#

if (command == undefined)

wind vault
#

What would the entire script look like as such?

earnest phoenix
wind vault
#

Python

#

How is it done for when a person puts an invalid or incorrect command that the bot tells him which command is not available?

earnest phoenix
pale vessel
#

bro why filter when you can just use find()

earnest phoenix
crimson vapor
#

why .first when you can use [0]

pale vessel
#

also you are mixing users and members

#

since you don't use indexes on collections

#

it should be message.member

earnest phoenix
#

two edits later it's now perfect

pale vessel
#

also, nice, x gang

restive furnace
pale vessel
#

redundancy we_smart

crimson vapor
#

wait

#

undefined[0] undefined?.[0]

pale vessel
#

Yes

lusty quest
#

only in node 14+

sudden geyser
#

the future is now

crimson vapor
#

who isnt using node 14+

lusty quest
#

probably 70% of the JS user here who have no plan on how to update

pale vessel
#

nodejs

crimson vapor
#

I always just install the newest version so I don't have to ever update

sudden geyser
#

Node.js has a lot of updates frequently

lusty quest
#

what about a running server? a vps usually dont does it by itself

restive furnace
#

i have nodejs 15 alr

#

nabs

#

idc abt the major bugs there

earnest phoenix
crimson vapor
#

oof

cinder patio
#

buy a vps

#

you pleb

sand condor
#

then don't use repl

earnest phoenix
#

vps for private bot why

lusty quest
#

buy a Raspberri pi

crimson vapor
#

I have a rpi2

#

it is currently using 100% cpu and I can't restart it because something broke

#

im also too lazy to unplug it

lusty quest
#

have a RPI 3 running pihole and a unify controller.

astral yoke
#
await data.save()
}``` why does this return with ```(node:15228) UnhandledPromiseRejectionWarning: TypeError: data.save is not a function```
willow mirage
#

how much is rpi3 ?

lusty quest
#

you need to save to your Schema not a random value

lusty quest
astral yoke
#

mongoose

lusty quest
#

thats mongodb syntax

tired panther
#

I use it to

astral yoke
#

i might know the reason

lusty quest
#

try await warns.save()

tired panther
#

one sec , have a code

#
 static async fetchGuild(gldid) {
  
    if (!gldid) throw new TypeError("A guild id was not provided.");

    const isguild = await set.findOne({gldid: gldid });
    if (isguild) return false;

    const newguild = new set({
      gldid: gldid,
      
    });

    await newguild.save().catch(e => console.log(`Failed to create guild: ${e}`));
    console.log("Guild fetched");
    return newguild;
  }
#

here

#

@astral yoke

#

NOw he is afk sob

ember crystal
royal herald
#

is that dbd or somthing

onyx wind
#

anyone using gcloud to hosting bots?

#

gcloud firewall probably blocking requests from top.gg apis and i cant use that..

quartz kindle
#

just unblock it

onyx wind
#

how can i do that?

quartz kindle
#

in your google cloud admin panel thingy

onyx wind
#

but i need to know top.gg api server and port for unblock that

quartz kindle
#

no you dont

#

you need to unblock your own port

#

for example if you host the webhook server in port 5000, you unblock port 5000 in the firewall for all IPs

onyx wind
#

i cant select all IPs

quartz kindle
#

you can

earnest phoenix
#

did you create a static address

quartz kindle
#

type that in the IP

onyx wind
#

priority 1000

#

?

quartz kindle
#

ye thats the default

#

leave it as that

onyx wind
#

thats good?

quartz kindle
#

you want to use webhooks?

onyx wind
#

yeah

quartz kindle
#

what port did you put your webhooks on?

onyx wind
#

80

quartz kindle
#

really?

onyx wind
#

yeah

quartz kindle
#

then yes

onyx wind
#

i need to reboot vps or something ?

quartz kindle
#

nope

#

should work right away

#

or in a couple minutes

tepid gazelle
#

._.

onyx wind
#
{
    "error": "Unauthorized"
}
#

but when i put header with authorizaton

#

it showing timeout

#

it works but
when i try to autorize
the site times out

quartz kindle
#

what does your webserver run on?

pale vessel
#

Potatoes

onyx wind
#

but, without authorization header it works fine

#

debian 10

#

It something wrong with my vps im sure, on other hosting it works fine

pure lion
#

whats that cool font everyone is using

#

the reactive one

#

@onyx wind whats happening?

onyx wind
#

yeah

#

i trying to get vote updates on channel with webhooks

#

whole day

#

on mine main hosting it didint works properly

#

i think its something blocking requests from top.gg apis

#

actually im hosting bot on gcloud, i tried unblock it but it didint works, i still have error : unauthorized

#

im checking that on req bin

opal plank
#

webhook on port 80

#

@quartz kindle why didnt you lash out on them for doing that?

onyx wind
quartz kindle
#

which webserver are you using?

onyx wind
#

express

quartz kindle
#

are you running node.js as root?

onyx wind
#

yeah

quartz kindle
#

ports 1-1024 are privileged ports, only the root user can use them, and therefore they are not recommended

#

show your express code

onyx wind
#

yeah

autumn vapor
onyx wind
#

When I try to send a request without authorizing i get a response all good but when i try to authorize it times out

crimson vapor
#

If I need to use a db for storing data, how should I reduce the amount of requests I make to it, if I need to save data every few messages or inputs

pure lion
#

caching

void minnow
#

cheapest is like $5 for 4gb ram

crimson vapor
#

maybe

autumn vapor
void minnow
#

np

onyx hare
#

so ive tried many endings for this.... and it doesnt loop its starting to frustrate me all i need is, it to loop but every way ive tried returns no error ~ no attempt to loop it or repeat it ive been ffrom docs to doc sbut nothing shows ive tried yt nothing returns what im after anyone able to help

const opus = require('opusscript');
exports.run = async (client, message, args) => {
    const connection = await message.member.voice.channel.join();
    message.member.voice.channel.join()
    const dispatcher = connection.play('Aronchupa-Little-Sis-Nora-The-Woodchuck-Song-[Bass Boosted].mp3', { volume: 0.7 });
    dispatcher.on('start', () => {
        message.channel.send('Radio is Now Playing!');
        console.log('playing audio!');
    });    
    dispatcher.on('finish', () => { 
        play(connection);
    });
}```
fair pasture
#

hm

#

How can I make it so that when someone sends an image/file and they delete it, it returns nothing?

dark axle
#

@fair pasture Check is the message is deleted.

fair pasture
#

yes but basically

#

Im doing a logger

#

and When someone sends a image/file and they delete it

#

it sends a no value error

dark axle
#

Use try catch

#

To catch the error before it get's logged and choose what to do maybe send back a response that The image could not be found.

#

Etc

fair pasture
#

Wait can you give me a exemple of try

dark axle
#

try{
//Your code
}catch(err){
//Send back a message to them
}
@fair pasture

fair pasture
#

I actually forgot how to do try

#

oh ok i was right lol

#

just had to confirm

dark axle
fair pasture
#

Alright thank yoU!

dark axle
stark abyss
quartz kindle
trim saddle
#

@quartz kindle i want to write a discord lib but idk where to start

quartz kindle
#

start with the gateway

onyx wind
#

it fixed probably

trim saddle
#

how to gateway

dark axle
#

Start with thinking on how your lib will be productive and in what ways that would benefit others and features you will provide that other libs do not already @trim saddle

quartz kindle
#
  1. pick your http lib, ie: node-fecth
  2. pick your websocket lib, ie: ws
#

install both

trim saddle
#

hmm.

earnest phoenix
#

the gateway is a literal pain

quartz kindle
#

make a request to the discord api, discord sends you ws url, make a request to ws url with ws

#

once connected, send an identify packet, in json format, with your token and login options

#

listen to responses, once you receive a ready packet, you will start receiving a shit load of event packets

earnest phoenix
trim saddle
#

gateway is dumb

dark axle
quartz kindle
#

jesus that flowchart makes me wanna puke

#

its much easier to understand without looking at it

earnest phoenix
#

xD

dark axle
#

no gateway no lib big boi @trim saddle

earnest phoenix
#

well

dark axle
quartz kindle
#

i have a small gateway code ready if you wanna look at

#

on my abandoned discord lib project

trim saddle
#

please

earnest phoenix
#

discord wants you to move away from the gateway and go all-REST

quartz kindle
#

how are you supposed to receive events through rest tho

#

webhooks?

earnest phoenix
#

๐Ÿคทโ€โ™‚๏ธ

#

for commands they're planing on using slash commands

quartz kindle
#

telegram uses webhooks

earnest phoenix
#

discord hits up your server with data you need

quartz kindle
#

but it makes everything more expensive because you cant reuse the same connection

earnest phoenix
#

i don't even question their decisions anymore

#

i bet they don't either

dark axle
#

@trim saddle I took my time to serach this for you :)
https://www.youtube.com/watch?v=B9IRkwP5lcc&ab_channel=AnsontheDeveloper

Want to support me and the channel? Donations are not required but greatly appreciated!

Become a Patreon: https://patreon.com/stuyy
Buy me a Coffee: http://ko-fi.com/anson
Streamlabs: https://streamlabs.com/ansondevacademy/tip

Want to learn Programming?

Learn JavaScript - https://www.youtube.com/playlist?list=PL_cUvD4qzbkzrpH8det0pvoT_Oxu1JV3...

โ–ถ Play video
earnest phoenix
#

in the meantime im reverse engineering voice v5

#

to see how video works under the hood

dark axle
#

Lmfao

#

Meanwhile I inspect discord and think of how facinating it is

#

It's a web app but an APP

earnest phoenix
#

there's new encryption in voice v5 that's completely undocumented

#

aead_aes256_gcm

dark axle
earnest phoenix
#

#1 reason why it eats so much memory lol

dark axle
#

Electron elections my brain still crazy

earnest phoenix
#

it's not even funny anymore like over half of apps i use run on chromium and hog my memory

#

32gigs really is going to become a minimum

dark axle
#

Ye

#

It's crazy

quartz kindle
dark axle
#

@quartz kindle lol

trim saddle
#

i'll learn some how

quartz kindle
#

actually fuck it, here

dark axle
#

@trim saddle I sent you a video

quartz kindle
#

use at your own risk

dark axle
#

ooo rar file

trim saddle
#

watching it

dark axle
#

I think you should use Deno SInce the brainstormer who made Node.js Made Deno @trim saddle

#

He is a big brainer so Deno is stable

earnest phoenix
#

ok thank god ietf has an rfc for aead_aes256_gcm

#

this is going to be my life saviour

#

video streaming genuinely isn't that different from normal voice connections

#

there's a few extra payloads that need to be sent to webRTC

quartz kindle
#

you're going to manually decrypt/encrypt video packets?

#

without a cryptography lib?

earnest phoenix
#

im going to try to

quartz kindle
#

dayum

#

good luck xD

earnest phoenix
#

thank you im going to need it

queen needle
#

might need a bit more then luck

long marsh
#

Unless it's to learn ๐Ÿคทโ€โ™‚๏ธ

quartz kindle
#

you could also just use libsodium

earnest phoenix
#

true

#

interoping sodium

#

easy

#

i just want to play around with this for now

long marsh
#

Just seems like you're making more work for yourself, unless you're doing it purposefully to learn ๐Ÿคทโ€โ™‚๏ธ

#

And/or have better control

earnest phoenix
#

unless you're doing it purposefully to learn
just this, taking a crack at it

quartz kindle
#

i mean, exploring these things yourself can be really fun

dark axle
#

I mean either way they still learn

long marsh
#

Ah, gotcha. Carry on, then!

earnest phoenix
#

my main goal is to make an easy tool that you can chuck a user token in and provide experience similar to rabb.it

quartz kindle
#

awesome

long marsh
#

Unfortunately, I don't find fulfilment with learning the in's and out's of a particular service's API / methodology. More on that, if there's a library that handles encryption for me ... they'll 100% do it more sufficiently than I will ever need. More on that, I'll probably never ever use those tools I learned inside of a production sense.

#

But at the ending of the day, if you enjoy it ... you enjoy it!

quartz kindle
#

so basically a full streaming platform backed by discord xD

earnest phoenix
#

โ„ข๏ธ

long marsh
#

Good luck, cry!

earnest phoenix
#

thank youu

long marsh
#

Maybe more of a support question, but is top.gg affiliated with discordbotlist?

#

Perhaps the same company?

earnest phoenix
#

it is the same company

#

just rebranded itself from discordbotlist to top.gg

long marsh
#

Gotcha. What's the purpose for keeping the dbl around?

earnest phoenix
#

no idea ๐Ÿคทโ€โ™‚๏ธ

quartz kindle
#

lazyness

long marsh
#

Possibly still making income

quartz kindle
#

this server was still named "Discord Bot List" for many months after the website was moved to top.gg

#

only recently it was changed to match the website

long marsh
#

I just submitted my bot on there; however, the general tone is completely different. I came here to ask if their node.js dbl sdk/api thing actually worked for both websites.

crimson vapor
#

Tim

#

what should I do to efficiently and easily not spam my db but still keep all changes

#

like if I were to cache and the vps crashes I would lose data

quartz kindle
#

the original author of dblapi left the company, so the lib was moved to a different repo and re-launched on npm recently under top-gg/node-sdk

long marsh
#

Oh, wow. Dang. I'm still using the old one haha

#

Thanks for letting me know!

crimson vapor
#

wait

#

Tonkku made dblapi?

quartz kindle
#

ye

long marsh
#

Is the old one technically deprecated?

quartz kindle
#

its marked as deprecated yes, but the code is pretty much unchanged

long marsh
#

Right

quartz kindle
#

except that the new one was made into a ts lib

long marsh
#

That is pretty nice

quartz kindle
#

for some

#

lmao

long marsh
#

๐Ÿ˜„

quartz kindle
#

i dont like ts

long marsh
#

I enjoy TS - it matches my background of Java / C++ better ๐Ÿ˜„

crimson vapor
#

so do you know how I should retain information without losing any data on crashes?

quartz kindle
#

ah nice

quartz kindle
long marsh
#

What kind of data are you referring too?

quartz kindle
#

if you want to cache data in memory to take load off your database in the safest way possible, the easiest way is probably redis

long marsh
#

Or memcache

crimson vapor
#

ok ill look into redis

quartz kindle
#

you will still lose data if your vps crashes tho

#

but not if your bot crashes

long marsh
#

Unless your Redis is hosted somewhere else ๐Ÿ˜„

crimson vapor
#

mostly the bot crashing

quartz kindle
#

ye lul

crimson vapor
#

which is the issue

#

memory caching would be good for things that just need to be read but I would rather not cache writes in memory

long marsh
#

Personally, I have a docker image that containerizes both my bot/redis. It works great

#

There's different types of caching strategies

quartz kindle
#

my bots never crash, only if i restart them

long marsh
#

Same

crimson vapor
#

is there a way to 100% prevent crashes?

quartz kindle
#

code it right

#

xD

long marsh
#

LOL

#

#owned

#

That's the system I have personally chosen

crimson vapor
#

well I mean say there is an issue with discordjs and some obsure thing causes it to throw an error

long marsh
#

You catch it

crimson vapor
#

ok

long marsh
#

You can catch an unhandlederror in your client.js

crimson vapor
#

o

gilded olive
#

Caches are very good implementations

long marsh
#

They're not just good, they're a must.

#

Well, take that back. They are for me

gilded olive
#

True

#

Well depends on what you are building, for me caching is an must

crimson vapor
#

I use try catch blocks for when I read and write from the db but nothing else tbh

quartz kindle
#

i dont have a cache for my db, but i have a cache for api responses

long marsh
#

I'm using DynamoDB as my primary storage. It basically charges per mb returned .. unless I stay under a certain threshold.

gilded olive
#

Calling my db 8 times for every message supriseeyes

long marsh
#

So, I cache basically everything.

long marsh
#

Woah - 8 times lmao

crimson vapor
#

tbh im sure I had a time where I was doing more

long marsh
#

The most I'll ever do is 2

quartz kindle
#

i call my db only once, and only when the command needs it

long marsh
#

Get inventory, add to inventory

quartz kindle
#

at most two, if the user hasnt used a command for a long time

gilded olive
#

So its a must

long marsh
#

8 times, though?

quartz kindle
#

x doubt

long marsh
#

8 different queries?