#development

1 messages · Page 685 of 1

onyx summit
#

What are the best nodejs logger?

inner jewel
#

is that an array?

#

if it is, includes() checks whether or not a value is in the array

earnest phoenix
#

hmm

#

there are def some weird things going on

#

yes it's an array

#

when i check the array is gone

cinder patio
#

why is it like that tho? [ id: [id] ]

earnest phoenix
#

it's a nested array ( i think it's called)

cinder patio
#

but why

earnest phoenix
#

a channel contain its own gameroom

#

which contain its own list of users

cinder patio
#

I recommend using classes for this kind of stuff, and maybe attaching an object containing everything about the game to message.channel instead of storing everything in an array.

earnest phoenix
#

don't have much ( any) experience using classes

#

what would the structure look like ?

#

like how do you do something similar to a nested array in a class

valid frigate
#

do you understand what js classes are

earnest phoenix
#

something about like nested objects ?

valid frigate
#

no

cinder patio
#

have a Game class which stores information about the game like players, states, etc. and attach an instance of it to message.channel

valid frigate
#

oh yeah

cinder patio
#

Google javascript classess tutorial

earnest phoenix
#

so i would have a game room and variables tied to a channel

#

and then i can store a simple list of the users inside that class

#

?

cinder patio
#

yeah sure

#

are you using discord.js btw

earnest phoenix
#

yes

hushed berry
#

how do i send a message to every user??

earnest phoenix
#

could i do something like

cinder patio
#

For example:

 constructor() {
  this.players = {}
}
}```

message.channel.game = new Game()


For example.
earnest phoenix
#

gameRoomClass.users.push(user) ?

devout chasm
#

how do i host a bot at discord?

cinder patio
#

sure! But I recommend using a discord collection or a map for storing discord objects

earnest phoenix
#

userID

#

okay, i'll try rewriting it

#

and hope that fixes that weird bug i had

#

wait, how do i differentiate the classes ?

cinder patio
#

make sure to read on classes before you do that tho

#

wdym

earnest phoenix
#

like right now

#

if i want to get a userlist from a game room in a channel

#

i do userList =gameRoom.channelID

cinder patio
#

mmm if you are going to do it the way I told you to, you should attach an instance of the game class to a channel object like so:

message.channel.game = new Game()

and you would get all users with: message.channel.game.users

earnest phoenix
#

ah okay, so that's how you " name " the class ?

cinder patio
#

yeah

earnest phoenix
#

ah okay very similar syntax then

#

instead of a .

cinder patio
#

I guess

earnest phoenix
#

Okay, I'll get working on it

#

Thanks for the help

frigid juniper
#

Hey, can someone from mods add my bot again, I've changed the prefix to .q now. 🙂

cinder patio
#

np EmeraldOkHand

slender thistle
#

@frigid juniper bot ID

frigid juniper
#

347405743235792908

earnest phoenix
#

How to text mute user&

#

Role name Muted

wheat jolt
#

@earnest phoenix can you please be more specific? No one can guess what you are trying to ask/say and no one will spoon feed you

earnest phoenix
#

When Write !mute [cat], Cat must got a Muted role

unique nimbus
#

make the bot add the muted role

onyx summit
#

You assign them the role

wheat jolt
#

^ blushy

earnest phoenix
abstract crow
#

If I were to make a Dashboard with a login, in order to store information about that user after the signed in, I need to use cookies that expire whenever the token expires right?

mossy vine
#

in mongoose is the mongoose.conncetion thing constant or do i have to pass it as function arguments?

earnest phoenix
#

im trying to do aliases cmd

#

with args

#

if(args[0] === options) {```
#

that wont work :/

copper cradle
#

ofc that doesn't work

#

you're checking if args[0] is equal to the options array

#

why are u expecting that to work

earnest phoenix
#

then how would i do this ?

mossy vine
#

options.includes(args[0])

earnest phoenix
#

I'm getting this traceback when I try to start my bot :

Traceback (most recent call last):
  File "/home/pi/Red/bin/redbot", line 6, in <module>
    from redbot.__main__ import main
  File "/home/pi/Red/lib/python3.7/site-packages/redbot/__main__.py", line 34, in <module>
    from redbot.core.core_commands import Core
  File "/home/pi/Red/lib/python3.7/site-packages/redbot/core/core_commands.py", line 453
    author = ctx.message.author
    ^
IndentationError: unexpected indent```
unique nimbus
#

its indented

#

there is a space

#

before author

earnest phoenix
#

erf

#

I'm sorry, I need to perfect my english level

unique nimbus
#

Its fine

earnest phoenix
#

Thank

unique nimbus
#

np

pine jacinth
#

HI, so I wanted to play a youtube video via a command and this is what I got:

 with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([<URL>])
    download = discord.FFmpegPCMAudio("<NAME>")
    voice_client.play(source, after=None)

This code seems to be working so far as the bot will have a green circle arround him. Sadly there is no audio being played (I don't hear any):
So I have to questions I'd kindly ask:

  • What is the error here
  • How can I get the filename in advance (So far I hardcoded it with an example, downloaded via YTDL)
unique nimbus
#

are you in python as it looks like it

#

and ar you in rewrite?

#

@pine jacinth

pine jacinth
#

Sorry, I had to go afk. I am using python the default discord[voice].py

onyx summit
#

I just mapped a Map

unique nimbus
pine jacinth
#

I know this sounds dumb but what exactly is meant by rewrite?

copper cradle
#

they re wrote the whole source code

unique nimbus
#

its the version after 1.0.0

#

yes

#

its a lot different

pine jacinth
#

Still stuck with the above error 😦

earnest phoenix
#

message.channel.game.players.push is not a function

twilit rapids
#

did you define players

earnest phoenix
#

i thought that was the first part in the class ?

#

sorry, literally first time i'm using classes

twilit rapids
#

this.players = {}
let/var/const players = this.players

earnest phoenix
#

outside the constructor bracket ?

#

or inside

twilit rapids
#

Depends where you're using it

#

Use let/var/const players = this.players wherever you are using the third code snippet you send

copper cradle
#

you can push to arrays, not objects iirc

earnest phoenix
#

ah okay

#

wanted to ask to do bot, hmeh...

copper cradle
#

what

#

learn to code

earnest phoenix
#

where

tawdry briar
#

isn't this server a turkish server

copper cradle
#

then you can "do bot" @earnest phoenix

#

@tawdry briar no

earnest phoenix
#

so should i declare an array inside an object inside the class ?

#

@copper cradle where can i learn coding

copper cradle
#
#

@earnest phoenix just do this.players =[];

tawdry briar
#

shouldn't discord servers list be gulu?

copper cradle
#

this channel isn't for conversations

earnest phoenix
#

then i can push to

#

msg.ch.game.game ?

copper cradle
#

ig

earnest phoenix
copper cradle
#

y e s

tawdry briar
#

so can you throw gulu's server

copper cradle
#

I don't know what gulu is, and I already told you to move to #memes-and-media you can ask there, this channel is only for development purposes if you don't cooperate a mod may mute you, so if I was you I would move to #memes-and-media

#

omfg...

tawdry briar
#

@copper cradle I'm sorry if I disturbed you

copper cradle
#

nono

#

don't worry

tawdry briar
#

can I ask something

onyx summit
#

did the formatting for codeblocks beak?

earnest phoenix
#

hmm how would i check if an instance of "msg.channel.game" already is the name of a class

abstract crow
#

yeet ask2ask

covert turtleBOT
#

Dont ask to ask
Just ask your question
it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.

copper cradle
#

@onyx summit discord broke their regex for md

onyx summit
#

and released it in prod

copper cradle
#

that's why they look a bit fucked up

earnest phoenix
#

there's no regex lol

#

it's an md parser

tawdry briar
#

Why are you British so calm?

#

??

earnest phoenix
copper cradle
#

@tawdry briar wdym?

earnest phoenix
#

what @earnest phoenix

unique nimbus
#

I am British and I would like to say thanks and wrong area

tawdry briar
#

What does wdym mean

twilit rapids
#

This is development lmao

earnest phoenix
#

uh, i dont really know the terms

onyx summit
#

"wdym" = "what do you mean"

unique nimbus
#

idk

#

wat

copper cradle
#

@tawdry briar what do you mean

earnest phoenix
#

i have a class called "game"

onyx summit
#

fell for the trap

hushed berry
#

hello i have problem can anyone help

onyx summit
#

no

#

we don't offer support for clustering a bot angryGlitch

earnest phoenix
#

for a certain price we do

hushed berry
#

i try to turn on bot but i get error

#

??

onyx summit
#

start more shards

devout chasm
#

is it a 786?

onyx summit
#

buy more servers

hushed berry
#

hahahahahha

#

i literally was gonna joke that i got a 4011 error

#

how did you read my mind

twilit rapids
#

Have you tried turning it on and off again

earnest phoenix
#

sudo rm -rf / usually fixes it

onyx summit
#

have you tried restarting the master thonkhappy

devout chasm
#

how do i host my bot at discord

earnest phoenix
#

email the t&s team saying you'll offer them a new fursuit if they host it

onyx summit
#

Someone on d.js asked if they can compile their bot and thus won't need a host

devout chasm
#

lmfao

onyx summit
#

anyway, how 2 make good help command

#

my current one is over a reaction menu, but thats garbage cuzz you need like 20 secs to see all commands

earnest phoenix
#

help alone lists all categories and their commands

#

help <command> provides more info about the command

onyx summit
#

I got the second one working

#

so just print them all out

#

oke

#

gonna make help <category> too

inner jewel
#

@earnest phoenix discord's markdown parser uses regex

earnest phoenix
#

ah

onyx summit
#

how can that go into prod

latent oasis
#

@twilit rapids happy bday timo!!!!

twilit rapids
#

My birthday will end in 20 minutes, so your in time :)

latent oasis
#

I think I'm the last one who said u "happy bday"

twilit rapids
limber swan
#

how do I send three different embeds with one command

inner jewel
#

you send 3 messages

earnest phoenix
#

webhooks are able to contain up to 3 embeds per message, if you decide on that

limber swan
#

It doesnt work for me,
I put
let serverembed1 = new Discord.RichEmbed()
then at the end
return member.send(serverembed1);
then for the second
let serverembed2 = new Discord.RichEmbed()
then at the end
return member.send(serverembed2);
but not working

mossy vine
#

you return

#

thats why

twilit rapids
#

You have return in the the first... damnit you fast boi

limber swan
#

oh, off

#

then bye

mossy vine
#

bye

earnest phoenix
#

anyone know a good way to mention a user by their id ?

mossy vine
#

<@id>

earnest phoenix
#

that automatically converts to like

#

@earnest phoenix

mossy vine
#

that does it

#

`@mossy vine

earnest phoenix
#

@165937223554826241

mossy vine
#

send the <> too

earnest phoenix
#

@earnest phoenix

#

ah neat

#

so "<@"+id+">"

mossy vine
#

yes

earnest phoenix
#

ok ty

#

you could use string interpolation to make it less ugly

topaz fjord
#

yes

#

<@${id}> thats how i would do it

earnest phoenix
#

like "<@$id>" ?

topaz fjord
#

no

earnest phoenix
#

oh, close

topaz fjord
#

replace the "" with ``

west spoke
#

its js strings

lusty dew
#

Why not do ``

#

Lol

brave anvil
#

How would I eval the server names of the servers that my bot is in

#

?

onyx summit
#

depends on the language and library

#

in d.js its client.guilds.map(x=> x.name) that gives you an array of names

lusty dew
#

Sup

#

Hey CHY4E can you help me with something?

onyx summit
#

maybe

#

lul

lusty dew
#

Kek still trying to get oauth2 to work

onyx summit
#

I still havent use oauth eyes_shake

#

but I would just copy most of the code from guidebot dashboard and modify it to my needs

lusty dew
#

Lol

#

I can do it in implicit grant

#

But I wanna do it in authorization code grant

#

And for some reason it is being da rude

onyx summit
#

do you use passport-discord?

lusty dew
#

No didn’t know it was a thing tf

onyx summit
#

No plan, as said, never created a dashboard with Discord oauth, but I'm looking into the guidebot dashboard

lusty dew
#

Ah mk.

#

I’m looking at it now and holy hell it looks so simple

onyx summit
#

well it uses mongo sessions thats shit

#

but I have some rethinkdb session storage so thats okay

lusty dew
#

Wait what?

#

Oh nvm

onyx summit
#

they store sessions in a db (mongo), so you don't have to login everything you use it

lusty dew
#

Read that wrong

#

Ye makes sense

onyx summit
lusty dew
#

So basically everything is handled for you?

onyx summit
#

not everything, but I think most

lusty dew
#

Ye

#

Wow

#

That looks complex

#

Kek

#

Don’t even know what half the stuff in there is

onyx summit
#

I wouldnt build the bot and the dashboard in one node app tho

lusty dew
#

I knew about passport not passport-discord

#

Nah I’m doing it separately

#

You did say it was okay to host the site on your server right?

onyx summit
#

ye

#

just tell me so I can put that into nginx

lusty dew
#

Okay

#

I gotta get a domain as well

#

If only I could change the name of an existing domain I have that I don’t use anymore

onyx summit
#

can't shrug

lusty dew
#

Ik

#

Sad

onyx summit
#

yeah, passport-discord gives you the user if the authenticated

lusty dew
#

Okay.

onyx summit
#

imo that code isnt good, all in one file and not really moduled

lusty dew
#

Yea

onyx summit
#

its enough to learn from it tho xD

lusty dew
#

Ima try and organize my code as much as possible

#

I forgot how to use express though 😬

#

Gotta look at the docs again

onyx summit
#

before I create a dashboard I have more important stuff to do

lusty dew
#

Like?

onyx summit
#

Building a server that streams to voice channels without my bot running in it
Finishing my rewrite
A localized server that saves and handles mp3 files (basically a cdn with one server lol)

swift harbor
#

could some one help me create a bot?

jolly ridge
#

:I

swift harbor
#

Idk how, i try to but it never accepts

#

and I'm new to bot creating

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

swift harbor
#

The bot that I try creating

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

swift harbor
#

English

sage bobcat
#

One message removed from a suspended account.

swift harbor
#

Yes

sage bobcat
#

One message removed from a suspended account.

swift harbor
#

16

sage bobcat
#

One message removed from a suspended account.

shrewd tangle
#

im also new to creating bots...

sage bobcat
#

One message removed from a suspended account.

shrewd tangle
#

for discord

#

delete my bot

sage bobcat
#

One message removed from a suspended account.

shrewd tangle
#

no i am saying i did

#

so are we not aloud to make offensive or rude bots?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

shrewd tangle
#

points for what? i just want to spread a bot that sounds like an idiot ...

#

but im intrigued what are points?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

shrewd tangle
#

im fine with that its an offensive bot i expect people to be offended or laugh its a choice

sage bobcat
#

One message removed from a suspended account.

shrewd tangle
#

Why would that be?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

shrewd tangle
#

I know to be nice but its like an offensive meme

sage bobcat
#

One message removed from a suspended account.

shrewd tangle
#

and yes i do

sage bobcat
#

One message removed from a suspended account.

shrewd tangle
#

just kidding

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

shrewd tangle
#

its not thats just the user

#

I name everything after my name also i deleted it cause people might take offense to it and the slave part and making it say they are playing with their self at the playing thing

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

shrewd tangle
#

search My Little pepe in bots it has "retard" in the description

sage bobcat
#

One message removed from a suspended account.

shrewd tangle
#

That is how ever offensive and used to refer to people with autism

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

shrewd tangle
#

i already delete it but for some proof of the My Little Pepe thing people compare autism and retardation and much more "
Autistic children with an IQ below 70 and with an IQ above 70 were systematically compared. The two groups differed somewhat in the pattern of symptoms, but were closely similar in terms of the main phenomena specifically associated with "

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

shrewd tangle
#

im not argueing i accept my bot will not be accepted i am aware of that im going to change the bot im just saying about the pepe thing i am in no way trying to come off as agressive nor trying to harass

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

polar sentinel
#

I want to make a bot that gets data off from some webpage every N minutes and then draws a graph
and i want that to be like in a picture that i can post on discord
any APIs or frameworks you suggest?
just that

tall osprey
#

i wanna make a bot but i have no idea how to code

unique wagon
#

OOF

#

rip

sinful lotus
#

@polar sentinel maybe canvas-constructor on npm

polar sentinel
#

thnx!

opaque eagle
#

And cheerio for getting data from a webpage

earnest phoenix
#

how do you create text channels on master build of djs

hushed berry
#

discord.pleaseCreateATextChannelInThisServer(serverId)

earnest phoenix
#

gunna slap u

#

guild.createChannel isnt in master :(

#

<guild>.channels.create @earnest phoenix

#

thanks boo

#

does it have same args

#

as the old one?

#

check the docs

#

smh making me work for knowledge

#

😤

lusty dew
#

Does anyone know what a placeholder is in JavaScript? I saw someone talking about it.

steel cloak
#

how do you get the number of total members in a guild that are offline in discord.js
let offline = message.guild.presences.filter(offline=>offline.status==='offline').size;
I tried this and it keeps returning 0 when there's multiple people/bots offline

lusty dew
#

Is that stable or master

#

Wait

#

It works for me

#

Maybe no one is actually offline?

steel cloak
#

hmmm thats weird. cause there a lot of members offline

potent cobalt
#

Shouldn't it be 'message.guild.members.filter'?

lusty dew
#

No

#

You can do presences

potent cobalt
#

Oh.

lusty dew
#

Yea

#

Any errors? @steel cloak

steel cloak
#

no

lusty dew
#

Hm

steel cloak
#

console is clear

lusty dew
#

You’re using master right?

steel cloak
#

i mean i believe so,, how do i check?

lusty dew
#

Uhm do you have an eval cmd

steel cloak
#

nah,, i just started making the bot and havent got to that yet

lusty dew
#

Or you could probably check package.json depending on how you installed it

#

If you installed it like npm install discordjs/discord.js

#

Then you have master installed

#

Could also install it from the GitHub

steel cloak
#

i installed it like npm install discord.js --save should i uninstall and try that?

lusty dew
#

Then you have stable

steel cloak
#

ahh okay,, ill try the other way

lusty dew
#

Ye

steel cloak
#

hmm still returns 0,, ill just mess around with it and hopefully it works eventually

lusty dew
#

Docs are offline for me tf

amber fractal
#

<GuildMember>.status doesnt exist

wheat jolt
#

Me 2

amber fractal
#

<Presence>.status does

#

y'all broken then

lusty dew
#

Ffs

wheat jolt
#

Url?

amber fractal
#

it also isnt embedding, which leads me to believe that there is a server error

#

of some sort

lusty dew
#

Yea

amber fractal
#

It's most likely because it's all cached for me

#

as it doesnt work in incognito

steel cloak
#

yeah i just cleared cached and the docs are offline,, sad

#

also let online = message.guild.presences.filter(online=>online.status==='online').size; works. so im very confussed

earnest phoenix
#

gawd (a dev) is updating the website i believe

#

well what you are calling online is a Presence object

steel cloak
#

wait what?

earnest phoenix
#

in the callback function, you call the presence object online

#

@amber fractal can you join something so i can test it on you

steel cloak
#

is that not okay to name the callback that?

earnest phoenix
#

well i mean you can name it whatever you want, it's just misleading

#

i wouldn't do it that way though, I would fetchMembers() then filter by the .presence.status, then access .size

steel cloak
#

hmm didnt think about that. thanks ill try that

amber fractal
#

sure

#

@earnest phoenix

earnest phoenix
#

so it appears guild.members.get(id).then seems to not be a thing on master

#

am i just retarded?

amber fractal
#

it's not a promise

earnest phoenix
#

really?

#

TIL

amber fractal
#

nope

#

.fetch() is

#

you dont need to do any of that

#

it's presence.status not just .status

earnest phoenix
#

that's gonna be inconsistent

#

since .members is only cached members

#

which is why i suggested fetchMembers()

amber fractal
#

That's bad for ram, but if it really matters then yeah

#

fetchMembers().then(...)

#

@earnest phoenix what did you want m8

earnest phoenix
#

@amber fractal ill invite in sec

devout chasm
#

How do I turn off bot

earnest phoenix
#

Does somebody knows how to fix the column cant have a default value on mysql?

devout chasm
#

Who pinged

lusty dew
#

I’m trying to make a command called promocc where I can create promo codes for the bot like -promocc premium true 2 2m format being -promocc [options] [value] [uses] [duration] how can I make the options optional?

lusty dew
#
let options = args[0]
let promoCode = args[4]
db.write(`${{id: promoCode, options: value}}`)```
#

Could I do something like that?

#

I’m using better-sqlite3

#

If that would work I gotta figure out how to write the uses, and duration to the db cause I’d have to do "uses": uses and "duration": duration, unless I’m able to use strings inside the template literal

pine jacinth
#

HI, so I wanted to play a youtube video via a command and this is what I got:

 with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([<URL>])
    download = discord.FFmpegPCMAudio("<NAME>")
    voice_client.play(source, after=None)

This code seems to be working so far as the bot will have a green circle arround him. Sadly there is no audio being played (I don't hear any):
So I have to questions I'd kindly ask:

  • What is the error here
  • How can I get the filename in advance (So far I hardcoded it with an example, downloaded via YTDL)
proper inlet
#

guild.channels.forEach(channel => {
//...
})
How to understand that you have access to the channel? The bot goes through channels that even he cannot see. Disocrd.js

wheat jolt
#

No, the bot doesn't gets channels that he cannot see

#

It gets only the channels where it has read messages permissions

#

Which is the permission to see the channel

#

@proper inlet

proper inlet
#

Gets. I launched the bot under the user account for the test. He showed # admin-chat channels on some servers, although I didn’t see them

#

Bot can't read messages, but bot can see channel

wheat jolt
#

User account?

proper inlet
#

For test

#

Yes

wheat jolt
#

You mean a selfbot?

slender thistle
#

I don't recommend using selfbots

wheat jolt
#

Selfbots are against discord tos

proper inlet
#

Well, I make the code and check through the selfbot, but then I use it on the bot account

wheat jolt
#

Why

slender thistle
#

check in channel permissions if the bot's permission to read message and read message history are revoked

proper inlet
#

It's more comfortable for me

slender thistle
#

Selfbots are against Discord ToS

sinful lotus
#

@proper inlet the bot caches all channels

wheat jolt
#

It's more "comfortable" for you to create an new discord account, use a browser to get a token?

sinful lotus
#

but on perms your bot that cant view, makes you unable to view for example it contents

proper inlet
#

The problem is how to check for permissions? I can not find anything on the Internet

lusty dew
#

Am I allowed to do ${variable + "string"}

slender thistle
#

R e a d t h e d o c s

#

why not panda

wheat jolt
pine jacinth
lusty dew
#

Idk I’m not sure why I thought you couldn’t

wheat jolt
#

@pine jacinth py?

pine jacinth
wheat jolt
#

I use d.js :(

slender thistle
#

It's essentially the same as

let variable = someString + "string"
lusty dew
#

Yea

wheat jolt
#

Or

lusty dew
#

I’m trying to write stuff to a db

#

Kek

slender thistle
#

@pine jacinth Better to ask in the d.py server :^)

lusty dew
#
let options = args[0]
let value = args[1]
let uses = args[2]
let duration = args[3]
let promoCode = args[4]
db.write(`${{id: promoCode, options: value, "uses": uses, "duration": duration}}`)```
wheat jolt
#

Use ${somestring}string

lusty dew
#

This is my thought process

pine jacinth
#

thanks @slender thistle xD didn't think about that

slender thistle
proper inlet
#

If it is outdated, then how can I check the permission to read messages?

wheat jolt
#

You have a permission above

#

Tho

lusty dew
#

Read messages is deprecated?

wheat jolt
#

@lusty dew ```js
let someString = 'string1'
db.write(${someString}string2)

#

This will write string1string2 in the db

lusty dew
#

I don’t see the point of that

wheat jolt
lusty dew
#

I’d have to make another ${}

#

Unless I concatenate the variable which is pointless

#

So I’d think it’d be better to just use one ${}

wheat jolt
#

What is db @lusty dew

lusty dew
#

better-sqlite3

wheat jolt
#

Ah

#

bots 479603748382179329

#

bots @lusty dew

#

Wtf

weary lark
#

not herre

wheat jolt
#

Ah

#

Sorry for annoying

weary lark
#

and also ping @gilded plank when you do it at the start, its fine! dont worry about it!

proper inlet
#

How to check if an object has a parameter? discord.js

lusty dew
#
this.write2 = (table, sK, aK, ids = ["id"]) => {
       const id = ids.join`, `
       const all = ids.concat(aK, sK)
       const str =(`
         INSERT INTO ${table}
         (${all.join`, `})
         VALUES(${aTA(all)})
         ON CONFLICT(${id}) DO UPDATE SET 
           ${aK.map(k => `${k} = ${k} + excluded.${k}`).concat(sK.map(k => `${k} = excluded.${k}`)).join`,\n`}
       `);
       console.log(str)
       const q = db.prepare(str)
       return (...a) => q.run(...a)
    }```
#

Can someone explain what this is for

#

Like I already have a write function

#

Idk what my old dev was doing

devout chasm
#

That really looks gross

weary lark
#

it does

lusty dew
#

I don’t understand the point of it

#

I have this already:

write(table, obj, id = "id") {
    let p = Object.keys(obj)
    let ins = db.prepare(`
      INSERT INTO ${table}
      (${p.join`, `})
      VALUES (${aTA(p)})
      ON CONFLICT(${id}) DO UPDATE SET
        ${p.map(k => k+" = excluded."+k).join`, `}
    `)
    //return obj => ins.run(obj)
    return ins.run(obj)
  }```
devout chasm
#

Oy prepared statements

lusty dew
#

?

#

If anyone can tell me what the difference between the two is I’d love to know

#

Cause if they both do the same thing I’d like to remove one of em

onyx summit
#
  1. Stop using callbacks
  2. Prepared statements basically prevent SQL injections (so some users gets you to insert user given code, which will do bad stuff with your SQL query)
earnest phoenix
mossy vine
#

no

earnest phoenix
#

t.t

#

do you know any alternatives that would achieve something similar ?

opaque eagle
#

No

earnest phoenix
#

t.t

lusty dew
#

@onyx summit Wait what

earnest phoenix
#

i have a list with n elements, for each element i'd like to react with a number emoji correspondent to the index of the element, is there someway to do this without hardcoding a lot of values ?

#

like if my list contains 3 elements i'd want to react to a msg like this

mossy vine
earnest phoenix
#

aight, thank you

onyx summit
#

@lusty dew just Google what are SQL injections
Its a very old security issue that. Somehow still exists(because people like you insert user stuff into SQL queries)

earnest phoenix
#

Can someone tell me how do I get contents from db.collection.find() in MongoDB? Because I tried to use db.collection(“something”).find({_id: message.author.id}).items[equipped] and it returned “Cannot find “undefined” from undefined.”. Items is an array and equipped is an int.

lusty dew
#

I know what sql injections are

onyx summit
#

Good

#

Then stop allowing it to be done

lusty dew
#

I just don’t get what you mean by prepared statements.

#

I thought that was a prepared statement?

earnest phoenix
#

DiscordAPIError: Unknown Emoji

#

im confused, when i hover over the emote

#

it says it "0⃣"

#

\0⃣

grim aspen
#

you need to react with the id of the emoji not the emoji itself

earnest phoenix
#

oh

grim aspen
#

\0⃣

#

damnit

proper inlet
#

var member = g.members.me;
if(!member.hasPermissions('VIEW_CHANNEL')) return;

TypeError: Cannot read property 'hasPermissions' of undefined

Why? I tired to use hasPermissions and has but it doesnt work

earnest phoenix
#

0⃣

#

<0⃣>

indigo geyser
#

0⃣

#

That

earnest phoenix
#

but that actually makes it much simpler

indigo geyser
#

Use that

grim aspen
#

\0⃣

#

it doesn't have an id on computer

earnest phoenix
#

the unicode is is just u30+<the number>

#

right ?

grim aspen
#

use \ before tthe emoji

indigo geyser
#

0⃣

#

oof

earnest phoenix
#

\0⃣

grim aspen
#

like thatt

weary lark
#

\0⃣

#

apparently thats the id of the emoji

earnest phoenix
#

?

indigo geyser
#

0⃣

#

Yes

#

0⃣

earnest phoenix
#

wait \0⃣ is the actual id ?

indigo geyser
#

Copy this: 0⃣

earnest phoenix
#

0⃣

grim aspen
#

it is not

earnest phoenix
#

o.o

grim aspen
#

i don't think it has an id

indigo geyser
#

#

#

Ok

#

It's for all emojis

#

(standards)

earnest phoenix
#

U+30

indigo geyser
#

No @weary lark

weary lark
#

sorry

indigo geyser
#

message.react('0⃣')

earnest phoenix
#

is 0⃣ not the same as U+30 ?

weary lark
earnest phoenix
#

0⃣

#

how do i even type that @indigo geyser

#

and get all the id's from 0 to 9

mossy vine
#

\0⃣

#

huh

earnest phoenix
#

im trying to find the ids for 0⃣ to 🔟

#

and it was apparently not \0⃣ to :keycap_ten

#

message.react('0️⃣');

#

'0⃣'

#

wait the heck

#

where do i find the codes ??

#

like this one

weary lark
#

0️⃣

#

i think you just found the id

earnest phoenix
#

it returns unknown emoji

weary lark
#

\0⃣

#

weird

earnest phoenix
#

and \0⃣ doesnt work either

slender thistle
#

0⃣1⃣2⃣3⃣4⃣5⃣6⃣7⃣8⃣9⃣🔟

#

Try these

earnest phoenix
#

oh shit

#

i just tried deleting it

#

it's like the number

#

and a weird box

#

0[]

slender thistle
#

Can't you do \0⃣

earnest phoenix
#

i tried

indigo geyser
weary lark
#

:zero:

earnest phoenix
#

:zero

#

the heck

#

@slender thistle it returns unknown Emoji

slender thistle
#

What about the unicode characters

earnest phoenix
#

like U+30 ?

#

i tried that too

#

the only thing that works i 0⃣

earnest phoenix
#

where did you find em ?

#

and is there anyway to type em ?

#

like msg.react(n+"weird ass box symbol")

#

so weird, it's like number with a [] on top of it

#

when i try deleting the

#

your number + keycap

#

no spaces

#

it's how numbers are actually sent

#

it's just that they're rendered differently

unique wagon
#

0️⃣

#

Oh owo..

#

\0⃣

earnest phoenix
#

1⃣

#

there we go

#

any number from 1-10 +

#

ah okay

#

thought it was some kind of weird thing you had to do to type the kecap "on top" of the number

brave elm
#

Can someone help me if they have time, I can go into screen share if you want as that will help a lot.

earnest phoenix
#

just ask your question

brave elm
#

I have the code for a bot, I believe I have changed everything and linked it with my bot, but it still doesn't work.

#

The setup cmd doesn't do anything when I load it up.

earnest phoenix
#

yes, the keycap has to be a string but yes

#

ah okay

#

that keycap char is really finicky

stray garnet
#

Wtf why my Bot has my Bot Missing Permissons to talk?

#

According to the console

brave elm
#

Can anyone help me? My setup isn't working.

stray garnet
#

Show the Code

#

@brave elm @brave elm

earnest phoenix
#

is this async loop incorrect ?

#

it should wait for the msg

#

then start a loop that waits for each reaction

#

but no reactions are made when i run it

quartz kindle
#

looks correct. double check if the loop is running (ie: console.log(i)), try to react once outside of the loop, try to react with a different emoji, catch the react(), etc..

earnest phoenix
#

hey if someone could help me its really important i got a ovh vps so i tried to login via ssh and done ssh root@vps ip. then its asking for me the password and im writing the correct password and its not working. i tried to copy the password too and its till dont working.. i just cant access my vps.. someone knows why and what i should do?

#

should i try reinstalling my server?

stray garnet
#

exports.run = async (bot,message,args,ops) => {
	
	if(!message.member.voiceChannel) return message.reply("Please join an Voice Channel First!")
	
	if(message.guild.me.voiceChannel) return message.reply("Im already Connected to an Voice Channel in this Server.")
	
	if(!args[0]) return message.reply("Input an URL")
	
	let validate = await ytdl.validateURL(args[0])
	
	if (!validate) return message.reply("Please input an **valid** URL!")
	
	let info = await ytdl.getInfo(args[0]);
	
	let connection = await message.member.voiceChannel.join()
	
	let dispatcher = await connection.play(ytdl(args[0], {
		 filter: "audioonly" }))
	
	message.channel.send(`Now playing: ${info.title}`)
}
module.exports.help = {
	name: "play",
	aliases: []
}```
#

nani?

earnest phoenix
#

which d.js version

stray garnet
#

uh wait

#

11.5.1 @earnest phoenix

earnest phoenix
#

play is a thing in v12

#

fml, forgot to add the "="

#

in i>=0

shy turret
#
  if (cmd.startsWith("!create")) {
    prefix = "!create"
    const args = message.content.slice(prefix.length).split();
    if (args[1]) {
      makeChannel(message, "c-" + args)
      message.channel.send("Collaberation channel created!")
      return
    } else {
      message.channel.send("Incorrect usage. Use `!create <collab name>`!")
      return
    }
  }

I'm trying to make a Discord bot for my friends... about some geometry dash stuff, which i want to make a command !create <collab name> work, except it keeps saying Incorrect usage.. ||(and don't red this like I'm a little kid lol)||

earnest phoenix
#

your logical solution to your problem is to update discord.js and rewrite half of your code instead of use a different method?

shy turret
#

me?

earnest phoenix
#

no, Clickbxit

stray garnet
#

@earnest phoenix yea just got it lel

shy turret
#

lol

inner jewel
#

@shy turret arrays start at zero

shy turret
#

oh

#

thx

pine jacinth
#
audio = discord.FFmpegPCMAudio("<FileName>.mp3")
voice_client.play(audio)

Result: The bot gets a green circle but no sound starts playing.
Why is there no sound?

barren crest
#

didnt load it right

#

¯_(ツ)_/¯

prime zenith
#

Hello, im working on leveling system and im almost done. But i need help about rewards system. Im using js. Is there anyone can help me?

barren crest
#

what are u using for a db @prime zenith ?

prime zenith
#

sqlite

barren crest
#

rip 😄 cant help sry

prime zenith
#

.d np

earnest phoenix
#

when i set the timeout to like 6 seconds it runs as intended

#

but when i set the timeout to 10 mins

#

10 mins goes by, and then it starts repeating the block of code inside the timeout brackets

barren crest
#

no shit 😄

#

ur code runs after the timeout and its in it 😄

earnest phoenix
#

yes that's intended

#

but i don't understand why the code is being repeated

barren crest
#

oh

earnest phoenix
#

i check if an id is included in a list at the beginning

#

after the timeout, i execute the code + remove the id from the list

#

that works when the timeout is 6 secs

#

but if i set it to 10 min, for some reason the code inside the timeout starts looping

#

after the timeout

pine jacinth
#

@barren crest Would you like to elaborate? didnt load it right

earnest phoenix
#

but you never add the message's channel id to inProgress

#

so the if check always goes through

#

wait no

#

im blind

#

ignore what i said

barren crest
#

@pine jacinth yea sorry wait for the file to load await it it prob didnt load fully

earnest phoenix
#

oh wait

#

if list.length = 1

#

and i do

#

list.length-1

#

it doesn't return int 0

#

but NaN

#

i think, is that normal behavior ?

pine jacinth
#

I am sorry but how do I wait for the file to load @barren crest ?

earnest phoenix
#

maybe return(null); at the end will fix it

#

even though it shouldn't be a problem in the first place

mossy vine
#

thats not how return works

#

its not a function

earnest phoenix
#

i'm kinda just treating it as loop, because it loops for some reason

pine jacinth
#

Wait returning is working 😮

#

Thanks so much

earnest phoenix
#

np

pine jacinth
#

You made my day

earnest phoenix
#

lmao this is hilarious

#

you know i didn't even write that to you

pine jacinth
#

yeah xD so basic and I am asking and looking into it since yesterday

#

wait

#

xD

#

oof but still thank you

earnest phoenix
#

i was talking about my own problem

#

but i don't mind it helped you xD

pine jacinth
#

omg that's so lucky xD

earnest phoenix
#

imma see if it works in my code tooMegaThonk

pine jacinth
#

xD

#

I hope so

inner jewel
#

@mossy vine you can use return like that

#

it'll parse as return and (whatever)

mossy vine
#

wait really?

inner jewel
#
> function identity(x) { return(x); }
undefined
> identity(123)
123```
barren crest
#

@pine jacinth use a await in a async func

earnest phoenix
pine jacinth
#

yeah, I recognized this one wasn't async

barren crest
#
audio = await discord.FFmpegPCMAudio("<FileName>.mp3")
voice_client.play(audio)```
quartz kindle
#

@earnest phoenix you defined del as a global variable, idk if thats intended

earnest phoenix
#

oh

#

it only needs to be used within that block of code

#

but not sure how that can explain

#

why that code block works when timeout is 6 seconds vs 10 min

#

rn im just waiting 10 min < < to see the logs

#

it's dumb to think there is an upper limit on the timeout thing, right `?

#

especially 10 min.

quartz kindle
#

a global variable can be replaced by other instances of the same code, ie: when multiple people run the command, and can cause other unexpected side effects as well

#

not sure if thats the source of the problem, but worth a try

earnest phoenix
#

lemme check for other instances of del real quick

quartz kindle
#

just define it as a local variable

earnest phoenix
#

it's the only instance

quartz kindle
#

let del =

earnest phoenix
#

sure

#

ok, it didn't repeat this time ( version with local "del" var)

#

but every time it did repeat was also with several players in in the list

#

is it possible the async loop can affect the the timeout ?

#

ok testing with local var for "del" with 2 players now

#

still happens

quartz kindle
#

whats your full command?

earnest phoenix
#

command ?

quartz kindle
#

thats your problem

#

you dont handle the command

#

that code will execute on EVERY SINGLE MESSAGE FROM EVERYONE

#

including the bot's own replies

earnest phoenix
#

but it has to pass the "if list.includes(id)"

#

which i remove out of the list

quartz kindle
#

the id is only removed from the list after the bot replies, which by that point, your code will already respond to it

fallen gulch
#

Which is the best programming language in which one can be made an music bot

earnest phoenix
#

Oh shit

quartz kindle
#

there is no best, go with whatever you are good with

earnest phoenix
#

any which there's already a library built for

#

so move it above the reply ?

#

that's still in the scope of the timeout

quartz kindle
#

@earnest phoenix you need to add other checks

inner jewel
#

any language that can use lavaplayer mmLol

quartz kindle
#

checking if something is in a list or not is no where near enough to stop all kinds of messages trying to execute that code

earnest phoenix
#

really ?

quartz kindle
#

a common bot command usually includes checks for it sender is a bot, if sender used prefix, if sender wrote a command, etc... at least

earnest phoenix
#

yes, i do have that

#

under this part

quartz kindle
#

you need to think of all possible scenarios

earnest phoenix
#

but i want that code to execute as close to the 10 min mark as possible

quartz kindle
#

its not a timing problem, is a conditions problem

earnest phoenix
#

hmm

quartz kindle
#

you just need to eliminate what your bot should not respond to

#

for instance, dont respond if the user is a bot

earnest phoenix
#

but if i put those check above that if statemnt

quartz kindle
#

this will stop it from responding to itself

earnest phoenix
#

it will only check the time when someone uses a bot cmd, right ?

#

wait, that's wrong

#

or maybe not

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

you are working with the message event, which includes all messages, without any filtering

#

@sage bobcat the only ruby experience i have is RPGMaker lul

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

they have a "ruby scripting system"

#

or whatever they call it

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

im not sure, i used it like 10 years ago

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

doesn't that mean the "time's up" msg only will happen after 10 min + the time it takes someone to write a bot cmd ?

#

or will the code in the timeout brackets be executed as soon as the 10 min are done

#

even if no messages are written

quartz kindle
#

@earnest phoenix the code in the timeout will be executed 10mins later

#

but every message you receive will create a new timeout

#

so the bot will keep creating timeouts

earnest phoenix
#

ah okay

quartz kindle
#

and respond multiple times when they are done

earnest phoenix
#

aight i guess i'll test again

#

with the cmd below the checks

barren crest
#

@earnest phoenix why dont u use a command handler?

earnest phoenix
#

i could argue that it's better to be more "hands on" and it's more intuitive etc. etc.

#

but not really any reason

#

just how i started out

barren crest
#

😄

earnest phoenix
#

so the code isn't executing at all now ._.

#

10+ mins has gone by¨

#

oh right

#

i have to move the codeblock even lower

#

because the id was pushed into the list below

#

how do add currency every x time

#

so 1min = 2 credits

#

how are ppl suppose to help if you don't show any code

loud salmon
#

@barren crest be a little more positive please

barren crest
#

¯_(ツ)_/¯

sinful lotus
#

@earnest phoenix basically those guilds are unavailable, you need to handle those accordingly

#

if a guild is unavailable only the guild id is available

earnest phoenix
#

Do you know how I could do so?

inner jewel
#

your library should handle that

#

which is basically just waiting for discord to send the guild data once it's available

sinful lotus
#

I use kurasuta myself with a forked ver and I dont have problems like that

#

if you do stuff with guild, make sure to check if the guild is available

#

.available on master

#

although from what Im seeing, probably you failed your eval code

#

nvm not eval

#

wait it is from eval I think so

earnest phoenix
#

😄

sinful lotus
#

since a simple message dont use _eval() method

#

so yeah check your eval

#

as for what eval code

#

/shrug

earnest phoenix
#

i'll delete eval cmd for now and check, thanks

#

.. didn't work

#

so for client.guilds.get, where would .available fit @sinful lotus

wanton nova
#

can you remove a vote in dbl?

#

not by force, but if the user votes, can they remove that vote?

slender thistle
#

No

wanton nova
#

okay thanks

slender thistle
#

I'm pretty sure we've had no cases of removing someone's vote so far

sinful lotus
#

@earnest phoenix guild has available property

earnest phoenix
#

how would i store a users uptime in a database?

sinful lotus
#

Use Date.now() to compare difference of date

earnest phoenix
#

how would i get username of peoples that precence is online

amber fractal
#

filter a member collection to only have online people

#

then you can map to their name and join

#

in js anyways

earnest phoenix
#

im trying to create a Coins per minue command im having troubles adding coins to users every minute
this wont work

client.users.forEach(u => {
db.add(`currecny_${u.id}`, 100) 
});
#

using quick.db ^

barren crest
#

@amber fractal @earnest phoenix no filter people that arent offline so you get idle and DND to

earnest phoenix
#

i filtered already

#

but stuck on

barren crest
#

stuck on what?

earnest phoenix
#

client.users.forEach(u => {
db.add(currecny_${u.id}, 100)
});

#

adding

#

coins to everyone every minute

barren crest
#

.guild

#

client.guild.users 🙂

earnest phoenix
#

em

remote cosmos
#

is there a way to get your user as id in the discord desktop client?

earnest phoenix
#

ill try

barren crest
#

or however u want to get it just do .id after

#

oh

#

u mean for u to get in discord?

remote cosmos
#

yes 😄

#

i know there is a way but i forgot it

barren crest
remote cosmos
#

ah okay thank you

earnest phoenix
#

TypeError: Cannot read property 'users' of undefined

barren crest
#

are we getting 1 guilds users or all of them in every guild?

#

1 right?

earnest phoenix
#

everyone the bot recongines

barren crest
#

🙄 so 1 guild

earnest phoenix
#

em

#

my bot has 3 guilds

barren crest
#

bot.users should work

#

u use client

earnest phoenix
#

yes

barren crest
#
client.guild.users.forEach(u => {
db.add(`currecny_${u.id}`, 100) 
});```
#

i see it doesnt thow

earnest phoenix
#

?

barren crest
#

i tested with a log for each it works fine

#
    bot.guild.users.forEach(u => {
        console.log(`${u.id}`)
    });```
#

worked fine

#

¯_(ツ)_/¯

earnest phoenix
#

not for me.

slender thistle
#

client.guild???

earnest phoenix
#

idk

#
db.add(`currecny_${u.id}`, 100) 
});``` that wont work sad times
earnest phoenix
#

i have a question

#

if i put in message event

#

i have to send message to get the coins

#

where would i put it so it will automactially add?

valid frigate
#

inside the message event?

earnest phoenix
#

but it wont add automactially

#

i have to type something

late hill
#

First off

earnest phoenix
#

in order for it to add

valid frigate
#

you mean like

#

coins per second?

earnest phoenix
#

yes

valid frigate
#

ah

late hill
#

Are you sure you want to add to everyones balance in a constant loop

earnest phoenix
#

i have stucture

valid frigate
#

don't use setinterval/etc

late hill
#

As that could be a lot

#

When your bot grows

valid frigate
#

every time the user is called from the db update their coin count

#

based on when it was last updated

earnest phoenix
#

my bot is priviate server

#

for friends

late hill
#

ok

valid frigate
#

using the last updated time, calculate the difference between the time of querying/last updated

earnest phoenix
#

hm

#

i dont understand :/

valid frigate
#

then based on their CPS add that number to their coin count

late hill
#

😑

valid frigate
#

uh

#

bascially

wanton nova
#

on the dbl api, how do you set the authorization on the site for the webhook?

earnest phoenix
#
client.users.forEach(user => {
setTimeout(function(){                                      
      db.add(`currency_${user.id}` , 100)
      console.log('GIVEN 100 COINS')
   }, 10000)


});
valid frigate
#

every time you need to query a user, update a field called "lastUpdated" to the current time

#

I mean

#

setTimeout is okay but what if your bot goes down

late hill
#

Timestamp 0: player interacts with bot, save timestamp
Timestamp 1: player interacts with bot again, compare current time with previously saved timestamp, add coins depending on time, save new timestamp
..

valid frigate
#

basically this

wanton nova
#

couldnt you just put that in the ready event?

late hill
#

And yes

valid frigate
#

the idea is to not use set timeout

late hill
#

If you want to go the other way

#

Do not put it in the message event

wanton nova
#

it would make a million set timeouts lol

valid frigate
#

wait

late hill
#

Put it outside of any other events if possible

earnest phoenix
#

so put in ready event?

late hill
#

ready event can fire multiple times

valid frigate
#

if your bot dies but the node process is alive you will create another settimeout

#

when the ready event is fired

earnest phoenix
#

im confused

#

what about index.js?

valid frigate
#

just read the thing about timestamps

earnest phoenix
#

could i put it in there

late hill
#

Yes but preferably follow our advice and use a different method

valid frigate
#

if you are using mongo you don't have to use forEach