#development

1 messages ยท Page 402 of 1

floral stone
#

I tol him to encode

#

He just needs to encode it for storage

slim heart
#

im pretty sure inviting the bot in the first place is pretty consent enough no?

inner jewel
#

and he needs to encrypt unless the users give him permission to store the guild name

earnest phoenix
#

just put a disclaimer on the bot page

floral stone
#

Do you want to see it through the database?

inner jewel
#

add a join message saying it saves might be enough

#

don't quote me on that

slim heart
#

LMAO
"Warning: this bot stores the name of your server if you invite it, sorry"

inner jewel
#

yes

floral stone
#

Do you want to see it through the database?

#

@slim heart

inner jewel
#

either that or you encrypt the db

slim heart
#

the db is local only

uncut slate
#

As far as I know, inviting a bot gives it permission to store EUD

floral stone
#

Encrypting it will make it show random characters in database

inner jewel
#

tbh i'd ask in DAPI

uncut slate
#

Yeah, you can't be too sure

floral stone
#

You want to see the name?

inner jewel
#

or play safe and encrypt it

slim heart
#

how do i set it to utf8?

#

or whatever

inner jewel
#

encryption's fairly cheap nowadays

floral stone
#

You have to encrypt data right?

#

encrypt ids*

inner jewel
#

disk encryption is supported by most CPUs and has little to no overhead

#

ids no

#

if it's generated by discord it's not EUD

floral stone
#

Good, I don't need encryption.

inner jewel
#

so no encryption is needed

floral stone
#

I only store ids

slim heart
#

Holdup you sayin i can add encryption, but I would know how to decrypt the info anyways what does it matter ๐Ÿ˜ฎ

floral stone
#

Exactly

#

Just generate the name by id

#

if you need it

#

you don't

inner jewel
#

encryption will make it harder to have data breaches and safer for you as well

slim heart
#

Like i said before I'm not here to explain to you just that it's easier

floral stone
#

make a command to get the server id for support reasons

slim heart
#

I'm asking how to, not looking for an argument

inner jewel
#

since just the db file will have nothing useful

#

without the key

floral stone
#

I have been coding bots for a long time now so I got tons of experience and is just offering advice. I understand that you want to have a server name to best handle support but you can't save names with unicode in them via sql. It's best to just use a command that returns the id. Telling them the command if they are unsure how is not a back breaking test.

knotty steeple
#

how would i prevent my bot from responding to other bots

floral stone
#

@slim heart

#

@knotty steeple make a if statement seeing if you user is a bot. Language?

knotty steeple
#

javascript

slim heart
#

if(message.author.bot) return;

floral stone
#

^

knotty steeple
#

ok ty

slim heart
#

I'm not having this argument with u fuzzy, if you can't help then dont try to oof

uncut slate
#

I think you're misunderstanding his intent, Berry

floral stone
#

There is no argument.

#

I'm just trying to help but you don't like my answe.

slim heart
#

I have my reasons, and I've experienced situations where it just makes it a lot easier

floral stone
#

If you can't listen to that, the only thing I can tell you is to encode it (which would make everything look weird as well like encryption but more noticeable). Google it, stack overflow probably has to answer ready.

earnest phoenix
#

uh

#

Cant you just set collation

inner jewel
#

base64 encode any non ascii character kappa

slim heart
#

Is there a way to just continue with my .forEach, and if there's an error it just says null

floral stone
#

was it base64

slim heart
#

ik there's the way but im not ver gud with js

floral stone
#

I swear it was utf8

inner jewel
#

encode with utf8 ^

slim heart
#

yeah mysql uses utf8 default im pretty sure

inner jewel
#

you need utf8-mb4 iirc

floral stone
#

encode the variable

inner jewel
#

base64 would technically work but it'd be more work and use more space

slim heart
#

How would i just return a null if it makes an error

inner jewel
#

you don't

#

you need to configure the database to encode properly

slim heart
#

I'm talking about the normal code oof

#

if the text is normal then just dont set the var

inner jewel
#

you'd need to check for code points outside the database's encoding supported range

slim heart
#

I'm not doing the db encoding im talkin about the actual js that would send that data to the db

inner jewel
#

you'd need to check for code points outside the database's encoding supported rangeยฒ

floral stone
#

square

#

d

inner jewel
#

which is considerably harder than just setting the proper encoding in the DB

floral stone
#

^

#

Or you could get it by id

#

or make a comma for the id

slim heart
#

๐Ÿ˜

floral stone
#

Or do the hard work yourself. We already explained easier methods.

slim heart
floral stone
#

ยฏ_(ใƒ„)_/ยฏ

slim heart
#

@inner jewel

knotty steeple
#

so uh my ping command is done, but how do i have the ms

inner jewel
#

i don't use mysql ยฏ_(ใƒ„)_/ยฏ

floral stone
#

Why ping trixter? We already gave you our answers. If you want a better answer then try Google.

knotty steeple
#

so uh my ping command is done, but how do i have the response time

solemn obsidian
#

natan stole my name

quiet bobcat
#

what does that have to do with development? @solemn obsidian

solemn obsidian
uncut slate
#

@knotty steeple depends on your library

quiet bobcat
#

again, what does that have to do with development?

solemn obsidian
#

๐Ÿคฆ

uncut slate
#

Jonas, he's answering that question

quiet bobcat
#

How?

#

Ooooh

#

I'm sorry

#

It didn't seem to do anything with development out of context

#

my bad

uncut slate
#

someone pings natan
they ask "why ping trixter"
trixter answers "natan stole my name"

knotty steeple
#

i have discord.js

uncut slate
#

client.ping or client.pings[0]

knotty steeple
#

ok

prisma mist
#

How could i message all discords my bot is in that downtime is going to take place?

#

im using discord.js btw

topaz fjord
#

So like mass message the servers?

prisma mist
#

that sounds bad but yes

inner jewel
#
  1. don't do that
  2. don't do that
  3. don't do that
  4. don't do that
  5. you'll get an API ban
topaz fjord
#

^

#

Just have downtime

prisma mist
#

wait really?

topaz fjord
#

Or ping @ everyone in your support server

prisma mist
#

๐Ÿค” im the only person in my support server ๐Ÿ˜‚

#

its not fully setup yet

topaz fjord
#

Well

#

That sucks

prisma mist
#

actually ima add a support command now

#

thanks for reminding me โค

knotty steeple
#

@uncut slate using bot.pings[0] returned the same ping for a while

uncut slate
#

What's "a while"? The value gets updated once in a while, automatically

inner jewel
#

websocket ping is calculated once in a while

knotty steeple
#

idk few mins

inner jewel
#

REST ping is usually calculated on demand

shell blade
#

Alright, so what I'm wanting to do is have my bot send a message, grab that ID and after a promise is completed edit that message.

#

I checked the docs but I'm still a bit lost. Could anyone help?

slim heart
#

Alright I found the four culprates for the MySQL errors... Any idea how to get mysql to recognize these?

topaz fjord
#

What lib

#

@shell blade

shell blade
#

Discord.js

topaz fjord
#

Um

knotty steeple
#

isnt there just a message.edit()

#

in discord.js

topaz fjord
#

The message should have the field .createdAt

glossy mason
#

What do you mean by culprits @slim heart?

topaz fjord
#

Oh wait

slim heart
#

The 4 servernames that can't be inserted

topaz fjord
#

Im stupid

#

I can't read

shell blade
#

:P

knotty steeple
#

lol

shell blade
#

I wouldn't need an ID, wouldn't I?

topaz fjord
#

@slim heart did you enable multipleStatements

slim heart
#

without crashing*

knotty steeple
#

no i dont think so

slim heart
#

I don't think that, makes a, difference oof

glossy mason
#

What's the data type of the column you are putting them in, and are you using a prepared statement?

slim heart
#

all i can say is this is the error

Executing:
UPDATE `bot`.`censorbot` SET `servername`='โ„‚๐•™๐•ฃ๐•š๐•ค๐•ฅ๐•š๐•’๐•Ÿ ๐•Š๐•–๐•ฃ๐•ง๐•–๐•ฃ' WHERE `idcensorbot`='32';

ERROR 1366: 1366: Incorrect string value: '\xF0\x9D\x95\x99\xF0\x9D...' for column 'servername' at row 1
SQL Statement:
UPDATE `bot`.`censorbot` SET `servername`='โ„‚๐•™๐•ฃ๐•š๐•ค๐•ฅ๐•š๐•’๐•Ÿ ๐•Š๐•–๐•ฃ๐•ง๐•–๐•ฃ' WHERE `idcensorbot`='32'
heady anvil
#

that doesn't seem like a prepared statement

#

it looks like your table doesn't support unicode

slim heart
#

cough

glossy mason
#

Quick search turns up that MySQL is not a fan of the encoding for those characters, but there's ways around it. This can explain better than I can: https://stackoverflow.com/questions/1168036/how-to-fix-incorrect-string-value-errors
Also, any particular reason you are using MySQL over something like Postgres? And, why store the server name, since you can just retrieve that with the server ID, and if the server changes its name...
And yeah, as @heady anvil said, that doesn't look like a prepared statement.

heady anvil
#

someone can literally make a server called

#

'; DROP TABLE `bot`; #

#

"oops"

slim heart
#

hehe

#

shhh

glossy mason
#

No, not shhh. It's easy to use prepared statements, and you have no excuse not to these days,

slim heart
#

I mean idek how to do these "prepared statments" witchery

heady anvil
#

it's not witchery

#

it's security

glossy mason
#

What language and library are you using for interacting with your database?

slim heart
#

js

#

also Okx i dont think that would work

heady anvil
#

want to test it

slim heart
#
            guildList.forEach(guild => {
                
                
                

                
                var servername = guild.name



                
             let on = {

    "serverid": guild.id,

    "censor": true,
    
    "servername": servername

}
            connection.query("INSERT INTO censorbot SET ?", on)
            console.log(`inserted ${guild.name}`)
            
            
                
            });```
#

I dont think it would i might be wrong though

glossy mason
#

IIRC, that is a proper way to prepare a statement wiht mysqljs. So that's good.

slim heart
#

<o/

#

it's the db, idk how to get it to understand dat

heady anvil
#

check your logs

#

also, you should probably use guild ids anyway

slim heart
#

nothing happened

#

also i do

topaz fjord
slim heart
#

Thats the guide i followed before

topaz fjord
#

It's a pain in the ass but it works

slim heart
topaz fjord
heady anvil
#

why are you even storing the server name

glossy mason
#

Still, why store the server name?

slim heart
#

Honestly, if not possible is there a way to see if it's any special characters and then just set it to null?

topaz fjord
#

If u did it right then if you run that command it will come out like that

slim heart
#

what do i set variable_name

topaz fjord
#

Wdym

slim heart
#

SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%';

heady anvil
#

you can just use your lib to get the guild name from the id

topaz fjord
#

Keep it

#

Like that

slim heart
#

Okx ive had this argument twice by now, i just want it in mysql for reason so jus shush lmaooo

topaz fjord
#

Let him do what he pleases

slim heart
#

thank

#

it keeps saying Unexpected identifier :/

topaz fjord
#

SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';

#

You ran that?

slim heart
topaz fjord
#

Heck

slim heart
#

hold on w8 i think im being stupid

topaz fjord
#

Can u go into the mysql command line

#

And run it

#

Instead of through that app thingy

slim heart
#

ye

#

okay so i think i was bein dum cuz i was setting it through db commands instead of shell command line

#

okay well every returns correctly but it still doesnt work

topaz fjord
#

doesnt seem like u set the collation_server

slim heart
#

i followed everything

slim heart
#

i just did it and everything matches up gooood, but, still no work oooof

floral stone
#

This is what happens when you encode with utf8

#
text = "Table Flip โ˜บ (โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป โ”ปโ”โ”ป "
print(text.encode("utf8"))
 >>> b'Table Flip \xe2\x98\xba (\xe2\x95\xaf\xc2\xb0\xe2\x96\xa1\xc2\xb0\xef\xbc\x89\xe2\x95\xaf\xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb ```
#

That is how it is via python, but encoding with js should do the same thing.

#

Converting UTF8 should convert all special character like above.

#

This best works if there are none or little special character in the name itself. Server names with all unicodes will be hard to understand when looking through database. I still recommend just the server id command but encoding it then saving it probably will work when saving it via sql.

#

@slim heart

slim heart
#

so lik, js will do it by itself?

floral stone
#

Use the package

#

I provided

#

It looks plausible

floral stone
#

I need a good dark theme for atom

#

Very customizeable

#

but like dark dark

misty river
inner jewel
#

because discord doesn't send that info to bots

elder rapids
#

premium is not available to bots

misty river
#

Ah

#

Wait, joined guild should workj

#

I've seen it done on other bots

inner jewel
#

you can check avatar hash

#

for animated avatars it starts with "a_"

elder rapids
#

Joined at has a chance of being null

misty river
#

Ah, alright

inner jewel
elder rapids
#

I've run into that problem several times and have to throw "Unknown" for it

inner jewel
#

that field's never been null to me

elder rapids
#

Could just be a cache issue too

misty river
#

Hm, npm?

#

Or something else

elder rapids
#

But that field is almost always null for me if they joined recently

#

Or the user isn't properly fetched and cached

misty river
#

Ah that could be it

#

This is a new account

elder rapids
#

I've been looking into just manually REST fetching the user since it always seems to be null

misty river
#

Yeah

#

Nvm it's not because of new accounts

#

Just tried with a 2016 account and still, undefined

elder rapids
#

Joining a guild has nothing to do with joining Discord

misty river
#

Ee

#

I'm pretty new to this stuff

#

So far I've been pretty good at getting things to work eventually

#

But this is a tricky one

elder rapids
#

Oh don't worry this one is just weird because some libraries seem to always have that field null

#

Discord.Net (C# lib) for example has that field as a nullable type because it can be null .. ?

#

Which makes no sense because I don't think Discord indicates that field as nullable and should always have it sent

misty river
#

Quick question

#

You mentioned avatar hashes, what exactly are they

#

And is it in the docs how to get them

elder rapids
#

Hashes to their avatar

slate basin
#

9

misty river
#

huh

elder rapids
#

If two people upload the same png to discord as their avatar they'll get the same hash

#

Basically it's an identifier for the image itself

#

Think of it like a signature for someone

#

It's just a signature to a specific image

elder rapids
#

yup

misty river
#

ah it posted a pic

#

Alright, thanks

elder rapids
#

The hash would be 20e8a1fde72e29af8c59ff6018742724

misty river
#

mm, that other thing is my ID right

elder rapids
#

Yes

misty river
#

Alright, thanks

knotty steeple
#

is it a good practice to have a more "stable" version of a bot and have a dev version which is frequently updated

elder rapids
#

You should always be doing that

#

Modifying a public branch everyone uses is a terrible idea

#

So yes it's a very good practice

knotty steeple
#

ah okay

low owl
#

I'm a bit split about that. I'd rather not pre-release unstable features and just work on it locally till I think it's done. I could not be motivated to care about two bots rather than just one.

elder rapids
#

I have two bots

#

The dev one is only in my server and not public

#

It's used because I login and relaunch the bot several times and it doesn't interfere with the public database, bot, or anything

low owl
#

Yea same. But I was assuming he meant two public ones.

#

One "alpha" like and one stable.

elder rapids
#

Two public ones I'm not sure about

#

I mean Discord does it

#

But I'm not sure that'd be ideal for a bot

#

It would incentivize people to use a more unstable version of the bot for the features and just doesn't really work out right

hidden veldt
#

hey

#

I got a problem

#

again...

misty river
#

?

hidden veldt
#

How do u make a bot respond to reactions?

misty river
#

No idea about .py

hidden veldt
#

ok

misty river
#

Hey I should make a voting feature

hidden veldt
#

hmm...

#

good idea...

#

ok

#

so anyone else know?

frozen path
#

Can I have some help

keen anvil
#

he wants his user count in d.js to be in his playing status, for whoever knows d.js ^^

frozen path
#

^

misty river
#

Ah, gimme a sec @frozen path

frozen path
#

okay

misty river
#

Use bot.guilds.size

frozen path
#

ok

misty river
#

Also, its in the docs

#

So before asking you should really look in there

#

Incredibly helpful

frozen path
#

ok

low rivet
#

@hidden veldt create an on reaction add event

frozen path
#

thank you very much

low rivet
#

it's in the docs so go check that out

hidden veldt
#

wat

#

i did

#

it dont work

#

ik no spoonfeeding

low rivet
#

what did u try

hidden veldt
#

but can u send me examplar

#

lemme show

#

wait..

#

somethings lagging

#

discord.on_reaction_add("\u0031\u20E3", message.author)

#

that

#

and it gives me this

low rivet
#

no...

#

its an event

hidden veldt
#

Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Python\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:\Users\edwar\Desktop\Bot-Lib\TB\v1.py", line 28, in on_message
client.on_reaction_add("\u0031\u20E3", message.author)
File "C:\Python\lib\site-packages\discord\client.py", line 296, in getattr
raise AttributeError(msg.format(self.class, name))
AttributeError: '<class 'discord.ext.commands.bot.Bot'>' object has no attribute 'on_reaction_add'

#

oh

#

can u show me

#

i never really understood "events"

#

ik no spoonfeed

low rivet
#

an event just like on_ready

hidden veldt
#

hmm?

low rivet
#

or on_connect

hidden veldt
#

show?

#

pls

#

oh and i added @async thing too

#

at the start

#

that was just my line

low rivet
#

are you doing this in a cog or main file?

hidden veldt
#

main file

#

idk

#

wats that

#

im using the python shell

#

not pycharm or that stuff

low rivet
#

is this your first python project?

hidden veldt
#

no

#

third

#

well depends on what u call a python project

#

if u mean bot

#

then third

#

if u mean just python like fiftieth?

#

idk

low rivet
#

learn python first honestly ๐Ÿ˜ณ

#

main file as in the file u call to start your bot

hidden veldt
#

yeah

#

thats it

#

i keep it on one file though

#

not that big

low rivet
#

what why

#

uh ok..

hidden veldt
#

like 100 lines?

#

pretty manageable

low rivet
#
@bot.event
async def on_reaction_add(reaction, user):
    #do stuff ```
hidden veldt
#

ok

#

will it react if I react to a specific message or any message

low rivet
#

you can add if statements..

hidden veldt
#

oh

#

ok

#

is there a way to put that under one unified function?

#

Traceback (most recent call last):
File "C:\Python\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:\Users\edwar\Desktop\Bot-Lib\TB\v1.py", line 33, in on_reaction_add
await client.send_message(message.channel, "yay this works!")
NameError: name 'message' is not defined
Ignoring exception in on_reaction_add
Traceback (most recent call last):
File "C:\Python\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:\Users\edwar\Desktop\Bot-Lib\TB\v1.py", line 33, in on_reaction_add
await client.send_message(message.channel, "yay this works!")
NameError: name 'message' is not defined
Ignoring exception in on_reaction_add
Traceback (most recent call last):
File "C:\Python\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:\Users\edwar\Desktop\Bot-Lib\TB\v1.py", line 33, in on_reaction_add
await client.send_message(message.channel, "yay this works!")
NameError: name 'message' is not defined
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Python\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:\Users\edwar\Desktop\Bot-Lib\TB\v1.py", line 29, in on_message
if reaction.emoji.id == "\u0031\u20E3":
NameError: name 'reaction' is not defined
Ignoring exception in on_reaction_add
Traceback (most recent call last):
File "C:\Python\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:\Users\edwar\Desktop\Bot-Lib\TB\v1.py", line 33, in on_reaction_add
await client.send_message(message.channel, "yay this works!")
NameError: name 'message' is not defined

#

bam thats what I got

low rivet
#

read your error

#

and learn codeblocks

hidden veldt
#

wat

#

ok

#

um...

#

thats a programmin language...

frail harness
#

๐Ÿคฆ

hidden veldt
#

yeet

#

it... is...

#

๐Ÿ˜ข

low rivet
#

NameError: name 'message' is not defined

hidden veldt
#

yeah

#

thats what I got

#

what

#

did i make a dumb mistake

#

lemme check...

#

OH

low rivet
#

yeah can't you understand the error?

hidden veldt
#

I gotta add a message parameter

#

right...

#

heh heh heh

low rivet
#

id advice you to read and understand the documentation

hidden veldt
#

ok

#

ill try again

#

wth is the client.messages cache

low rivet
#

the currently cached messages in client...? basically only some recent messages

hidden veldt
#

ok...

#

wait

#

this is what the api says

#

Called when a message has a reaction added to it. Similar to on_message_edit, if the message is not found in the Client.messages cache, then this event will not be called.

#

look

#

wat...

#

tf does that mean

low rivet
#

what do you not understand

hidden veldt
#

so...

#

what do i do...

#

HELP

#

SCREE

#

@low rivet ?

#

H

#

E

#

L

#

O

#

P

topaz fjord
#

stop spamming

hidden veldt
#

...

#

that was like 8 messages

#

but ok

#

sure

#

sorry

#

โ˜น

low rivet
ashen quail
hidden veldt
#

ok

#

cool

#

seriously?

#

ik python

#

like i dont need the tutorial

#

JUST DISCORD

#

dude...

#

i have a working discord bot

#

it just wont react to reactions

elder rapids
#

@ashen quail best advice is to just breakpoint and walkthrough the program (console logs work too). I don't really know the API but that's really all I could tell you if you are 100% the API you have is correct. e.g. your on message event

ashen quail
#

ok

floral stone
#

client.on_reaction_add("\u0031\u20E3", message.author)

#

Sorry..

hidden veldt
#

ok

#

wat

#

wait

#

wat

floral stone
#

on_reaction_add and all other events are functions.

hidden veldt
#

ok

#

wait...

#

can u give me code?
like the whole function

#

IK NO SPOONFEED

floral stone
#
@bot.event
async def on_reaction_add(reaction, user):
    #do stuff ```
#

on_reaction_add

#

all events

#

on_command

hidden veldt
#

wat

floral stone
#

on_error

hidden veldt
#

ok

floral stone
#

are functions

hidden veldt
#

@client.event
async def on_reaction_add(reaction, user):
await client.send_message(message.channel, "yay this works!")

#

thats what im doing

#

good?

#

i use client instead of bot

floral stone
#

You need to define message

hidden veldt
#

wat

#

show?

#

yeah

#

thats me probs

floral stone
#
@client.event
async def on_reaction_add(reaction, user):
    await client.send_message(reaction.message.channel, "yay this works!")
hidden veldt
#

ok

#

thx

#

wait

#

uh

#

do I specify what emoji

#

or leave it as reaction

floral stone
#

reaction.emoji should return the emoji

hidden veldt
#

ok

#

like this

floral stone
#

emojis = reaction.emoji

hidden veldt
#

@client.event
async def on_reaction_add("\u0031\u20E3", user):
await client.send_message(reaction.message.channel, "yay this works!"

floral stone
#

No

hidden veldt
#

...

floral stone
#

keep it as reaction

hidden veldt
#

ok

#

cool

#

anythin else

floral stone
hidden veldt
#

ok

#

it works

#

but

#

for every reaction i add, it returns yay this works

#

how do I specify which one

#

like where would I put that

floral stone
#
if str(reaction.emoji) == ":thumbsdown":
    #do stuff```
hidden veldt
#

...

#

ok

#

mmm

#

hmm

#

ima add await?

#

@client.event
async def on_reaction_add(reaction, user):
if str(reaction.emoji) == "๐Ÿช":
await client.send_message(reaction.message.channel, "yay this works!")

#

yep

#

it says this

#

RuntimeWarning: coroutine 'on_reaction_add' was never awaited
client.on_reaction_add("\u0031\u20E3", message.author)

#

why is it... a warning?

floral stone
#

need to wait it

hidden veldt
#

that sounds intimidating

#

wat

#

i did

#

await client.send_message bla yay

#

oh

floral stone
#

on_reaction_add is not a function in client

hidden veldt
#

do i say

floral stone
#

it's an event

hidden veldt
#

?

#

show

#

help?

floral stone
#

do you want to add a reaction

#

?

hidden veldt
#

yeah

#

hold up

#

i want the bot to say something when I add a reaction

#

thats what...

floral stone
#

the event

hidden veldt
#

@floral stone

#

wat

#

show?

floral stone
#

use the example above

hidden veldt
#

pls

floral stone
#

client.on_reaction_add("\u0031\u20E3", message.author)

#

not thing

#

It needs to be a function, an event.

hidden veldt
#

@client.event
async def on_reaction_add(reaction, user):
await client.send_message(reaction.message.channel, "yay this works!")

#

?

#

but...

floral stone
#

yes

hidden veldt
#

how...

#

yeah

#

this is me code

floral stone
#

how what?

hidden veldt
#

@client.event
async def on_reaction_add(reaction, user):
if str(reaction.emoji) == "๐Ÿช":
await client.send_message(reaction.message.channel, "yay this works!")

#

so...

#

whats wrong///

#

...

#

i mean

floral stone
#

It should return a message when anyone adds a cookie emoji to a message.

hidden veldt
#

hmm?

#

ok

#

lemme see...

#

RuntimeWarning: coroutine 'on_reaction_add' was never awaited
client.on_reaction_add("\u0031\u20E3", message.author)

#

thats what I got

floral stone
#

client.on_reaction_add("\u0031\u20E3", message.author) remove that

hidden veldt
#

ok...

#

cool

#

now lemme try

floral stone
#

I have to go man, will help you out tommorow. :D

hidden veldt
#

ok

#

cool

#

ill figure it out

#

bye

mental solstice
#

Copy the actual emote.. not the keycode

hidden veldt
#

heyyo

#

uncle

#

can u help meh?

#

i got it to work

#

@mental solstice

#

but it keeps responding to its own reactions

#

can u help?

#

hi

#

im not a dev

#

but hi

mental solstice
#

Add a conditional statment.. id user.isbot return

hidden veldt
#

wat

#

uh...

#

i don't know how to do that

#

wat

#

coins...

#

uh...

mental solstice
#

Idk JS very well.. but if (senderOdMessage.IsBot) return

hidden veldt
#

im using python

#

not js

#

async

#

python 3

#

in case that matters

mental solstice
#

Well whatever the arg for reactionadded event

hidden veldt
#

yee

#

i dont know what that is

#

brb

mental solstice
#

Message.author.isbot

#

Perhaps

hidden veldt
#

wat

#

oi

#

im back

solid cliff
#

if user.bot: return

topaz fjord
#

ban

#

@austere meadow

grizzled isle
#

Dammit turtle

topaz fjord
#

no u

grizzled isle
#

no u

prime cliff
#

He bypassed anti-ads basically

topaz fjord
#

u

grizzled isle
#

You

topaz fjord
#

or not

#

hes ded

grizzled isle
#

buhbye

earnest phoenix
#

so

night imp
#

Are you constructing it or editing it after construction?

earnest phoenix
#

editing it after construction

#

for a _reason command

night imp
#

Are you using an object rich or norm?

earnest phoenix
#

richembed

night imp
earnest phoenix
#

oh i know how to do that

night imp
#

Yeah try that out and see if it works

earnest phoenix
#

i just didn't know rich embeds were objects

#

i just used the methods

night imp
#

Yeah I assume they are

#

If not someone smarter than me will probably get on ๐Ÿ˜›

earnest phoenix
#

Yeah they are, i see the props right here

#

Thanks ๐Ÿ˜„

earnest phoenix
#

are bots still allowed to upload emojis to the guild

wise bridge
#

Let's say they can

earnest phoenix
#

yeah

#

Ratelimit though, about 30 mins cd after you upload like 50 emojis i think

#

the add emoji endpoint was useronly at one point

earnest phoenix
#

obj.key3 = "value3"

#

oh that was yesterday lol

gusty topaz
#

In ejs, does anyone know how can I access a parameter passed into the module from an included module?

#

In index.ejs, I have <% include ../partials/navbar.ejs %>

#

in express, res.render("pages/index.ejs", { opts: { active: "/" }});

#

but the navbar.ejs

#

cannot see opts

languid dragon
#

yeah cant you just include('', {})

gusty topaz
#

oh, you can do that?

languid dragon
#

IIRC

#

dont quote me on it EYES

gusty topaz
#

now index.ejs also tells me that opts dont exist

languid dragon
gusty topaz
#

this is extremely weird

#

I did this now

    app.get('/', async (req, res, next) => {
        res.render("pages/index.ejs", { active: "/" });
    });

And added

<%= active %>

in my index.ejs

#

and it still throws an error

#

Ah nevermind

#

im a bit of an idiot

#

I didnt restart the node process when I made changes to index.js

#

too used to webpack and auto-restart

#

ยฏ_(ใƒ„)_/ยฏ

languid dragon
#

relatable

gusty topaz
#

so yeah, sorry for wasting your time

languid dragon
#

YEAH U SHOULD BE SORRY >:(

#

pls no time wasted

#

xox

glacial sentinel
#

How do I make my bot show the amount of servers it's in on the website?

solid cliff
glacial sentinel
#

Thanks! @solid cliff

gusty topaz
#

I fixed my restart issue by creating a script with fs-events-linux which automatically restarts the server on file change

unkempt dew
#

or you could use something like nodemon?

gusty topaz
#

nah

#

custom solution best solution

unkempt dew
spring ember
glossy sand
#

consider manually making an auth request with curl to check if your credentials are valid

toxic grove
#

I just pushed out >dbl on my bot if anyone want to try it out

#

>dbl <bot ID or mention>

uncut slate
#

@spring ember btoa isn't a native thing in node, how are you defining it

glossy sand
#

oh

#

it occurs to me you aren't even sending the bearer token lol

#

cred is unused it would seem

uncut slate
#

oh nah, he doesn't need the bearer token, he's just getting an auth token which all you need for is client ID and secret

spring ember
#

I required it and downloaded it via npm @uncut slate

uncut slate
#

he's not using BASIC auth, just passing the params instead

earnest phoenix
#

its

hidden veldt
#

how would u make a bot ignore its own reactions? Im using python and async. I know sorta how to do it, but it seems like nobody online knows the exact code.

earnest phoenix
#
Basic Buffer.from(`${clientId}:${clientSecret}`, "binary").toString("base64");``` for authorization
uncut slate
#

not necessarily

earnest phoenix
#

Yes it is

glossy sand
#

if and only if you're using basic auth though

earnest phoenix
#

literally how the dAPI works

uncut slate
#

nope, you don't need to use basic auth

#

you can pass it as a param

#

either is supported

earnest phoenix
#

What can you pass?

#

Im so lost rn

uncut slate
#
const options = {

ย ย ย ย ย ย ย ย client_id: _this.bot.user.id,

ย ย ย ย ย ย ย ย client_secret: _this.config.bot.secret,

ย ย ย ย ย ย ย ย grant_type: 'authorization_code',

ย ย ย ย ย ย ย ย code,

ย ย ย ย ย ย ย ย redirect_uri: `${_this.config.web.domain}/discord/cb`

ย ย ย ย ย ย };
#

blame GitHub for indent

earnest phoenix
#

and?

uncut slate
#

that's all you need to pass

earnest phoenix
#

Can you explain what you mean instead of giving code that means nothing?

uncut slate
#

@spring ember I'm not sure if snekfetch auto converts objects to urlencoded, that might be your issue

#

@earnest phoenix you don't need to use your method for auth, you can pass the client id and secret as parameters aswell

hidden veldt
#

um...

#

hi

uncut slate
#

Hi

earnest phoenix
#

It doesnt show that here

uncut slate
#

you can and I do

#

and that's what dondish seems to be sending

earnest phoenix
#

Anyway i sent him how i do it considering he dmed me theshrug

#

my way is the shown way

#

I've never seen your way done

spring ember
#

Yukine told me to reach out for you GWnekomakiAngeryBOYE

glossy sand
#

it's known that the dapi docs are of questionable quality

spring ember
#

because he said you did a web dashboard

earnest phoenix
#

Well i am working on it rn

spring ember
#

lol gonna use vue with express

uncut slate
#

And you're sure your ID and secret are valid?

earnest phoenix
#

That code is very incorrect in that screenshot above tho

spring ember
#

yes

#

it is correct for client but it is not what I am looking for

earnest phoenix
#

Hard to tell what part bc its a screenshot

spring ember
#

somehow the problem is that the authorize site doesn't authorize the bot because it is not on my authorized apps

#

and idk why

austere meadow
#

@spring ember whats the issue exactly? i remember dealing with this

spring ember
#

look above

#

I sent a snip

uncut slate
#

you did add your localhost to a valid URI redirect, right

earnest phoenix
#

Use the code that i sent you, lol

spring ember
#

yes

austere meadow
#

^^

#

was about to say

#

damn aeth

earnest phoenix
#

you cant use encodeURI like that first of all, snekfetch does it for you

#

you dont need to set Content-type

#

snekfetch does it for u

spring ember
#

oh

uncut slate
#

oh yeah, encoding it twice would make it invalid

earnest phoenix
#

if the oauth authorize page says something is wrong, open dev tools go to the red link, click on it and find the preview it will say why

spring ember
#

umm now I am getting unsupported grant_type

earnest phoenix
#

grant_type is code

spring ember
#

are you sure snekfetch sends it correctly?

#

like in form encoded?

earnest phoenix
#

Yes

spring ember
#

do I need to end it?

#

the request?

earnest phoenix
#
            if (!req.body.code) return res.status(400).json({ message: "No code provided" });
            const creds = Buffer.from(`${clientId}:${clientSecret}`, "binary").toString("base64");
            const response = await snekfetch.post(`https://discordapp.com/api/oauth2/token`)
                .set({ Authorization: `Basic ${creds}` })
                .query({
                    grant_type: "authorization_code",
                    redirect_uri: req.body.redirectUri,
                    code: req.body.code
                });
            if (!response) return res.status(500).json({ message: "Error fetching token" });
            return res.status(200).json(response.body);
``` this isnt express (btw, its for vue-auth not ur normal discord oauth implementation)
uncut slate
#

.query vs .send?

knotty steeple
#

Im trying to make my bot send and image in an embed but he image doesnt come up

hidden veldt
#

hi

earnest phoenix
#

Really aeth?

hidden veldt
#

wat up

earnest phoenix
#

take a guess

hidden veldt
#

i

#

am

earnest phoenix
#

dont say it blake

hidden veldt
#

BACK

spring ember
#

lol

knotty steeple
#

@hidden veldt if you want to chat #general

hidden veldt
#

nu

uncut slate
#

@earnest phoenix Dondish is using send, you're using query. Calm your ass down.

hidden veldt
#

i got a problem

spring ember
#

the mods are here

uncut slate
#

I'm not asking a question.

spring ember
#

you'll get muted

hidden veldt
#

wait me

austere meadow
#

@hidden veldt whats the issue

earnest phoenix
#

because, you're meant to query it not send the data

spring ember
#

@uncut slate send is object type query is for setting parameters one by one

earnest phoenix
#

I was getting into that

hidden veldt
#

how do u make a python async bot not react to itself?

spring ember
#

check if the author's id is you

hidden veldt
#

how would I do that

spring ember
#

you use on_message()?

austere meadow
#

@hidden veldt return if the message author is equal to the bot ID

hidden veldt
#

it says message is not defined

uncut slate
#

I'm fully aware, I'm pointing out that you're using query and he's using send for the same purpose

hidden veldt
#

oh

#

but it says message is not defined

#

still

#

heres my code

spring ember
#

@uncut slate opposite lul

hidden veldt
#

@client.event
async def on_reaction_add(reaction, user):
if reaction.emoji == "\u0031\u20E3":
await client.send_message(reaction.message.channel, "yay this works!")

#

heh...

#

that works fine

spring ember
#

on_reaction is not on_message and you can get the message from the reaction

ruby dust
#
@bot.event
async def on_message(message):
    if message.author.bot:
        return

    bot.process_commands(message)
```@hidden veldt put this in the main file and it will completelly ignore all bot messages
hidden veldt
#

ok

#

cool

#

thx

uncut slate
#

@spring ember I was talking to Jacz

hidden veldt
#

...

earnest phoenix
#

@uncut slate I was editing my code for Dondish's use as its not express

#

in dms

hidden veldt
#

no wait

#

that doesnt work

#

its for reactions

#

not messages

uncut slate
#

I doubt there's any point in me repeating myself again bloblul

spring ember
#

reaction.message.author.bot

uncut slate
#

he's using py, Dondish

spring ember
#

it is in py

hidden veldt
#

Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Python\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:\Users\edwar\Desktop\Bot-Lib\TB\v1.py", line 36, in on_message
if message.bot:
AttributeError: 'Message' object has no attribute 'bot'

uncut slate
#

oh, deng

hidden veldt
#

wat

#

ok

spring ember
#

message.author

#

returns a Member

hidden veldt
#

wat

#

u mean

#

if message.author == bot

spring ember
#

no

#

if message.author.bot

hidden veldt
#

ok

spring ember
#

this will check if it's a bot user

hidden veldt
#

how bout reactions

#

reaction.author.bot?

knotty steeple
#

How would i send an image in a embed

#

discord.js

hidden veldt
#

i wanted to know the same thing

spring ember
#

reaction.message.author.bot @hidden veldt

hidden veldt
#

how do u even embed

#

ok

#

thx

spring ember
#

oof

knotty steeple
#

hello?

hidden veldt
#

idk

#

i dont do js

uncut slate
#

hi @knotty steeple

spring ember
hidden veldt
#

do u know how to embed just on discord?

#

just a random question

uncut slate
#

Send embeds you mean?

hidden veldt
#

yee

spring ember
inner jewel
#

@spring ember try setting redirect_uri to /callback instead

hidden veldt
#

i sorta hate it when people tell me to look at the docs

#

but ok

#

maybe it works for other ppls

spring ember
#

it will be an infinite loop natan lul

inner jewel
#

no

uncut slate
#

nah

inner jewel
#

it won't

hidden veldt
#

wat

uncut slate
#

the redirect URI is the callback page

hidden veldt
#

oh

#

ok

uncut slate
#

the page Discord redirects you to

spring ember
#

still unsupported_grant_type

austere meadow
#

@spring ember can i see the redirect URI's you've set on your application page?

#

have you set them up properly

spring ember
#

yes

austere meadow
#

if it's even off by a bit it won't work

spring ember
#

it isn't

austere meadow
#

i had the same issue

inner jewel
#

http/https matters in that

spring ember
#

I didn't type https

#

anywhere

earnest phoenix
#

the grant_type is 100% authorization_code

#

Can we see full code

#

you're just posting screenshots, its quite annoying

knotty steeple
#

Im not using RichEmbed in just doing msg.channel.send({embed: {})

#

btw

spring ember
#

so use richembed maybe

earnest phoenix
#

Donkku

hidden veldt
#

@client.event
async def on_reaction_add(reaction, user):
if reaction.emoji == "\u0031\u20E3":
await client.send_message(reaction.message.channel, "yay this works!")
if reaction.message.author.bot:
return

spring ember
#

I have a lot of code which is basically not relevant

uncut slate
#

@knotty steeple refer to the Discord API docs if you want to send raw embeds

hidden veldt
#

thats the thing

#

but it still reacts to its own

earnest phoenix
#

@spring ember Just that endpoint...

hidden veldt
#

reactions

spring ember
#

the /me?

#

ok

earnest phoenix
#

no

inner jewel
#

/callback

earnest phoenix
#

^

hidden veldt
#

?

uncut slate
#

@hidden veldt you want to return before you react

hidden veldt
#

hmm

#

so first return

earnest phoenix
#

Did you save the file and restart the app?

hidden veldt
#

OH

uncut slate
#

yeah

hidden veldt
#

ok

#

lemme try

uncut slate
#

do the check first

hidden veldt
#

yeah

#

i did

earnest phoenix
austere meadow
#

never

spring ember
hidden veldt
#

@client.event
async def on_reaction_add(reaction, user):
if reaction.emoji == "\u0031\u20E3":
if reaction.message.author.bot:
return
else:
await client.send_message(reaction.message.channel, "yay this works!")

#

?

earnest phoenix
#

@spring ember dude

#

use the code i sent you

#

you need to use.query

#

yet you're still using .send

spring ember
#

ok

earnest phoenix
#

also

uncut slate
#

oh my

hidden veldt
#

ok now it wont respond to my reactions

earnest phoenix
#

.then((result)=>{req.session.token=result}) this isnt gonna work

hidden veldt
#

...

earnest phoenix
#

.then((result)=>{req.session.token=result.body.access_token}) will

hidden veldt
#

hmm?

#

wait u mean me?

earnest phoenix
#

im not talking to you, tristan

hidden veldt
#

oh

uncut slate
#

@hidden veldt put the return at the very very top

hidden veldt
#

ok

#

sry

earnest phoenix
#

all g

hidden veldt
#

like htis?

spring ember
#

I think it is stuck on infinite loop

uncut slate
#
if bot:
  return
# the rest of your code
hidden veldt
#

return
@client.event
async def on_reaction_add(reaction, user):
if reaction.message.author.bot:
return
if reaction.emoji == "\u0031\u20E3":
await client.send_message(reaction.message.channel, "yay this works!")

#

like that...

#

no return at the top

#

that was an accident

#

copy pasta accident

spring ember
#

nvm query fixed it

uncut slate
#

yeah, the rest looks fine

hidden veldt
#

ok

spring ember
#

thanks to everyone

hidden veldt
#

cool

uncut slate
#

np @spring ember

earnest phoenix
#

@spring ember yw

hidden veldt
#

oh...

earnest phoenix
#

if you used my code at first it would've work :p but its okay i forgive

hidden veldt
#

um it still wont respond to my reactions

earnest phoenix
hidden veldt
#

ok yay

#

sorrry

#

heh

austere meadow
#

@earnest phoenix i never used snekfetch for my authorization code, i stored the URL in a variable and i posted using http

hidden veldt
#

๐Ÿคฃ

#

whoah

#

there are these bot devs just goin online

#

im just watching the numbers go up

#

...

earnest phoenix
uncut slate
#

@austere meadow same, I use https

austere meadow
hidden veldt
earnest phoenix
#

Why use https when snekfetch has no deps, make no sense

hidden veldt
#

*โƒฃ

#

u know wat

#

ima just ask again l8r

#

cya

uncut slate
#

why use a dep if https is a built-in, makes no sense

hidden veldt
uncut slate
#

Tristan, what do you need right now

hidden veldt
#

wat

#

ok

#

uh...

#

it wont react to my reactions ๐Ÿ˜

uncut slate
#

show code

hidden veldt
#

kk

uncut slate
#

in a codeblock this time ๐Ÿ’™

hidden veldt
#

@client.event
async def on_reaction_add(reaction, user):
if reaction.message.author.bot:
return
if reaction.emoji == "\u0031\u20E3":
await client.send_message(reaction.message.channel, "yay this works!")

#

wat

#

how u do that

#

๐Ÿ˜ฆ

uncut slate
#

```py
code
```

mental solstice
#

isnt that 2 reactions.. and does JS read it like that?

earnest phoenix
#

Yes but, snekfetch has no deps, uses https/2 which is faster then http/https :^) and provides a simple to use interface for doing requests with no deps and its made by a nodejs module team member so its good :)

mental solstice
#

er py

hidden veldt
#

hmm...

#

two reactions...

uncut slate
#

then use https/2 in your own code

mental solstice
#

"\u0031\u20E3":

hidden veldt
#

me...

mental solstice
#

are those 2 different reactions?

hidden veldt
#

no

#

thats one

uncut slate
#

someone not using a lib you like isn't a bad thing

hidden veldt
#

1โƒฃ

#

huh...

#

wat?

uncut slate
#

I was responding to Jacz

#

try logging reaction.emoji

hidden veldt
#

oh

#

hmm

#

this?

mental solstice
#

1โƒฃ

uncut slate
#

find out where it gets stuck

mental solstice
#

\1โƒฃ

#

grr

hidden veldt
#

wait what does "logging" mean

#

1โƒฃ

mental solstice
#

u have to get the unicode character im pretty sure

hidden veldt
#

yay

austere meadow
#

logging to the console

hidden veldt
#

im usin it

#

the python src

#

for ios 5

austere meadow
#

\1โƒฃ

hidden veldt
#

1โƒฃ

austere meadow
#

wait wtf

hidden veldt
#

???

#

DISCORD!

#

WE GOT AN ISSUE HERE!