#development

1 messages ยท Page 580 of 1

sinful lotus
#

for instance, you can "clean up" some members in a specific threshold but keep in mind that this would break some functionality like message.mentions.members

you can also try to clean up the user cache but you need to make your own recacher or else you would run into serious issues.

nuke message cache or reduce it to 100 may help a little

clear presence cache "if you dont use it" or else you may not want to nuke it

#

other than that put more ram

#

I also forgot to mention you can also make the garbage collector more agressive in node but that would make your program horribly slow if set too low since mark-sweep gc would stop the program for a bit of time

lilac geyser
#

I see... thanks so much :p

#
    messageCacheLifetime: 10,
    messageCacheMaxSize: 3,
    messageSweepInterval: 30,``` im already doing this for messages
#

๐Ÿ˜‚

sinful lotus
#

your choice thats fine although as I said, d.js love to cache

lilac geyser
#

As well as this js disabledEvents: [ 'TYPING_START', 'PRESENCE_UPDATE' ],

#

:|

#

there's barely anything else I can do for clean up

sinful lotus
#

just try to do what I said on earlier, that might help but theres nothing more you can do

#

since first, d.js uses traditional sharding

#

means usercaches are different for each shard

#

means user could be duplicated

#

as well its process based sharding

lilac geyser
#

Hmm...

sinful lotus
#

you can reduce your shard count to at least 2k per guild

#

but as I said other than what I specified

#

no matter what you do since it is process based sharding it eats more ram

#

normally

#

there is a sharder in d.js master right now which is called Kurasata I think? which is available on d.js master that is based on eris sharder

#

which lets you have more guilds in single process but you may need to rewrite a lot of stuff and if you arent into a rewrite then

#

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

lilac geyser
#

I'll take a look, thanks again

steel heath
#

rewriting is ok i'll do anything if it's going to help me with my ram usage stuff could u explain mr smart n awesome qt

sinful lotus
lilac geyser
#

Changing a library is not so ok

#

Youve got to study every thing again

#

Alright great

sinful lotus
#

although Im not updating in latest master yet due to some issues lying in internal sharding

#

I would be waiting until that branch gets more stable

summer vector
#

Hello there also seems to be offline bot bot disocrd my list but also domestic discord boots cycles please help this problem is what is the problem here.

amber fractal
dusky marsh
#

English

amber fractal
#

If you're talking about the ???

#

It means it's not in this server

restive silo
#

@sinful lotus pong

#

@sinful lotus IS is quite stable, atleast my bot runs 10 Clusters with 40 Shards and 80k Guilds fine and it resumes/reconnects fine atm

sinful lotus
#

Well Im just waiting for it to become more stable, I'll look onto refactoring once the issues on github repo of d.js get resolved in is

restive silo
#

which one, most issues got closed recently

#

๐Ÿ‘€

sinful lotus
#
restive silo
#

i see

#

well the second one is really weird tho, idk how JSON parse errors are related to d.js Thenky

sinful lotus
#

not sure as well lmao, I'll just disturb you once I migrate heheheh

restive silo
#

sure, i have some nice plans to Kurasuta aswell

#

sad that i move away from it but kinda nice at the same time

sinful lotus
#

Its just different based on what you are used to do in traditional sharding thats why Im sure I'll have a lot of questions there

restive silo
#

sure, only really difference i saw was waaaay less memory

sinful lotus
#

how much it eats right now?

restive silo
#

since i have less processes i assume, but i probaly need to manually increase my Cluster count soon since i dont want to run more then 4 shards in 1 process

#

my bot with 80k guilds takes like 7.4GB

#
  • 2GB LL
sinful lotus
#

thats really efficient than process based sharding ๐Ÿ‘€

restive silo
#

ye

reef valley
#

how to add Reaction to message send webhook??

amber fractal
#

What was that delete

stuck prism
#

I moved it to api

nvm seemed thatโ€™s defiantly not the correct are, Iโ€™m on mobile so canโ€™t view channel descriptions easily. Iโ€™ll add it here once again in this message.

If somebody would be kind enough to help me. Iโ€™ve got a little problem regarding the shop Iโ€™m setting on a website.

I can't add or remove points via the Discordhub API

If I do it in their test interface, it works with the precise URL https://discordhub.com/api/points/remove?user_id=86222355826765824&server_id=337395364489330688&amount=1

I'm using the correct URL, but instead it's returning just a message
{"message": "The method is not allowed for the requested URL."}

neat falcon
#

you're not using the right method

#

it should say if it is a GET, POST etc

queen violet
#

@reef valley You want to use webhooks to add reactions or add reactions to messages sent with webhooks

earnest phoenix
#

Can anyone here help me with discordpy on_socket_raw_receive ?

slender thistle
#

What's up

earnest phoenix
#

I'm trying to basically do the "reaction roles" feature. I had it at first, but it only worked when the message was sent AFTER the bot was turned online.

slender thistle
#

Rewrite branch?

earnest phoenix
#

So I was then advised to use the "on_socket_raw_receive" and I'm having trouble understanding it.

#

No, I'm using async.

slender thistle
#
    async def on_socket_raw_receive(self, raw_msg):
        if not isinstance(raw_msg, str):
            return
        msg = json.loads(raw_msg)
        type = msg.get("t")
        data = msg.get("d")
        if not data:
            return
        emoji = data.get("emoji")
        user_id = data.get("user_id")
        message_id = data.get("message_id")
        if type == "MESSAGE_REACTION_ADD":
            # do something
        elif type == "MESSAGE_REACTION_REMOVE":
            # do something else
earnest phoenix
#

yes

#

that is exactly what I have lol

slender thistle
#

And what do you not understand there?

earnest phoenix
#

I suppose how to use it.

#

I plugged in that code, and...
TypeError: on_socket_raw_receive() missing 1 required positional argument: 'raw_msg'

slender thistle
#

Is it in cog or no?

earnest phoenix
#

No, I haven't started doing cogs yet :p

slender thistle
#

Yeah, remove self

#

(Basic Python classes stuff)

earnest phoenix
#

I did

#

(to be fair, I just started self-teaching python like last week)

#

and I'm assuming I don't need the json then

slender thistle
#

How is json to related to that

earnest phoenix
#

I removed self, and
NameError: name 'json' is not defined

slender thistle
#

import it

earnest phoenix
#

do u know how to create an array with thousands of phrases'
with a google api

#

now i feel stupid

slender thistle
#

Self-teaching Python while creating a Discord bot, eh? :^)

earnest phoenix
#

Making the discord bot is my version of self-teaching lmao.

slender thistle
earnest phoenix
#

same

slender thistle
#

Well, not much of a good idea, I should say

brisk sparrow
earnest phoenix
#

Everyone has to start somewhere ;p

slender thistle
#

Basic Python stuff RenShrugGif

earnest phoenix
#

do u know how to create an array with thousands of phrases'
with a google api

#

hhhh

slender thistle
#

d.py isn't kinda beginner-friendly

earnest phoenix
#

I've been taught some C++, Java, and C from classes so far, I think next semester is python lmao

slender thistle
#

@earnest phoenix thousands of phrases with Google API? thonk_think

earnest phoenix
#

yeah

slender thistle
#

What phrases though? Thonk

earnest phoenix
#

everyone

amber fractal
earnest phoenix
#

searching phrases from google

#

To maintain some credibility, I have a buy/sell feature that connects to a MySQL db to create a user input-defined list advertising what they're selling.

slender thistle
#

Is that even possible, I wonder

earnest phoenix
#

i hope

#

@slender thistle do u know google apis'

slender thistle
#

Unfortunately, nope

earnest phoenix
#

my shift doesnt work

#

fuck

amber fractal
#

That's nice

earnest phoenix
#

ik

#

Lookin to help a lil more @slender thistle ? ๐Ÿ˜‰

slender thistle
#

If I can help, sure

earnest phoenix
#

What's complicated to me is most likely simple to you.

slender thistle
#

Who knows

earnest phoenix
#

So for everything else, I've been using message.author and member
since those are in the parameters of the def's

#

but the only param passed in on_socket_raw_receive is the raw_msg.
I'm trying to add user roles and message the user upon reacting with an emoji, but can't seem to find the correct wording to use to get the user

#

I obviously can't do the user_id since that's defined as the str...

slender thistle
#

You have user_id variable there

#

So, get_member if it even exists in async or utils.get

earnest phoenix
#

Well yea

#

I did: await client.add_roles(user_id, discord.utils.get(user_id.server.roles, name="Buyer&Seller"))

slender thistle
#

Yeah, did a wrong there

earnest phoenix
#

lmao did 2 wrongs there.

slender thistle
#

Yep

earnest phoenix
#

How'd I go about correcting such a mistake?

slender thistle
#

Make another variable with utils.get where the iterable is bot.servers

#

Call it member or user or whatever you wanna name it

white rampart
earnest phoenix
#

assuming i know how to define bot Thonk

#

just use @bot.event I'm assuming
oh syke

slender thistle
#

DBL one

earnest phoenix
#

haha well thanks for the help
guess im just too ignorant for this stuff atm
i'll go hire a dev

slender thistle
#

@earnest phoenix assuming i know how to define bot , what?

gloomy anchor
#

Lol

slender thistle
#

If it's not in a cog or class, use whatever you name it in when declaring commands.Bot or discord.Client (whichever you are using)

gloomy anchor
#

bloblul hit or miss

#

Lol

slender thistle
#

If you're not gonna help or ask questions about development, please move away from this channel

earnest phoenix
#

ok yea, that's what i thought @slender thistle

#

except that's what i did lol and i still managed to screw something up ๐Ÿคฃ

slender thistle
#

Happens

earnest phoenix
#

user = discord.utils.get(client.servers)

slender thistle
#

Almost

#

Have you looked up the docs for d.py async?

earnest phoenix
#

lmao. I appreciate ur friendliness

#

that stuff is so vague imo

marble needle
#

Gotta know how to use it

earnest phoenix
#

but yea, i have. for hours actually lol all the commands i've been using come from there

slender thistle
#

A helper that returns the first element in the iterable that meets all the traits passed in attrs.
Example:

#

member = discord.utils.get(message.server.members, name='Foo')

#

Let's imagine that we have a user on some server whose username is Foo and their user ID is 250

#

How would you use utils.get if you wanted to find a member with id equal to 250?

earnest phoenix
#

discord.utils.get(message.server.members, name='Foo', id = 250)

slender thistle
#

That's correct, but in your case you don't need name attribute, correct?

earnest phoenix
#

yea

#

so just be id=250

slender thistle
#

Yep

earnest phoenix
#

so what do i need to put for the other parameter? server name? ;-;

slender thistle
#

I just confused myself, give me a minute HYPERMEGAULTRAOMEGAGODLUL

clear moth
slender thistle
#

await instead?

dusky marsh
#

If he is on a older version of Python, he can't yield in a coroutine

gloomy anchor
#

;-;

upbeat solstice
#

Can someone tell me how to make my bot send random things instead of just saying the same thing everytime the command is used?

amber fractal
#

have an array

#

pick a random entry from that array

upbeat solstice
#

What's an array

amber fractal
#

What lang is this in?

upbeat solstice
#

Umm I'm confused..

amber fractal
#

Do you know what language this bot is coded in

upbeat solstice
#

I use python

amber fractal
#

Ah

#

idk if they're still called arrays in python

#

I use js

upbeat solstice
#

Oh um

#

Well I need someone to help me.

fiery quest
#

hey guys, do you know how can i put the servers counter on the bot page? sry for the english btw

quartz kindle
#

Arrays are lists in python, if im not mistaken

#

@fiery quest have you checked dbl's api?

fiery quest
cunning wasp
quartz kindle
#

Yes

fiery quest
#

I checked, but i still dont understand, sorry

#

i'm stupid, maybe i find it ๐Ÿ˜…

tawny minnow
#

so i am encountering that peoples usernames have emoji code in them. and my database doesnt like that and it keeps crashing my bot. is there any way that i can store those usernames in a useable fashion and stop the bot from crashing when it tries to store it

#

perhaps change the datatype from varchar to something else? but if thats the solution, im not sure which datatype to use that can accept the emoji code

#

Error: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect string value: '\xF0\x9D\x95\xAF\xF0\x9D...' for column 'Username' at row 1

quartz kindle
#

You should sanitize the string or encode it

#

Althougj if your database is in utf8, it should accept unicode emojis

#

Also check if you're not accidentally parsing those backslashes as escapes instead of text

tawny minnow
#

it is indeed utf8 and if i sanitize it, would it still store the username in a useable manner?

quartz kindle
#

Sanifization often involves removal of bad characters, so it might happen that your username will return broken

tawny minnow
#

thats what im worried about

quartz kindle
#

Encoding on the other hand, such as base64, should be safe, but it will probably increase string size

tawny minnow
#

that would require all usernames to be encoded and decoded as used correct?

quartz kindle
#

Yup

tawny minnow
#

thats a bit frustrating just to deal with a few rare people that chose to have emoji...

quartz kindle
#

You can use html encoding or some other encoding that targets only insafe characters

amber fractal
#

bcrypt :+1: or ๐Ÿ‘Ž

quartz kindle
#

Bcrypt is fine for passwords

amber fractal
#

Is there any other ones that I should be aware of tho?

tawny minnow
#

i might just sanitize it the usernames and see if it breaks them. but there is such a small amount of people with emoji in the usernames, i sort of dont think it will even be an issue on my bot since i dont expect it to become a huge thing

quartz kindle
#

Scrypt, argon2, pbkdf2

amber fractal
#

Compared to bcrypt are they better?

quartz kindle
#

Argon2 is the newest one i believe

#

As for better, idk, check some articles on them

amber fractal
#

Makes sense it's async mmLol

#

Argon2 seems to be better

scarlet quest
#

Hey someone knows the event name for adding a role to a guild member ? (i'm using JDA).

earnest phoenix
#

member.addRole(role).then(() => {

}

#

srry if its wrong..

quartz kindle
#

Its completely wrong lmao

#

It has nothing to do with the question

grim aspen
#

yeah that's wrong

scarlet quest
#

don't kill the guy xd

#

thanks for trying @earnest phoenix ๐Ÿ˜ƒ

harsh nova
#
delete Neptune
//jk lol 
scarlet quest
#

anyone knows? the event name for adding a role to a guild member ? (i'm using JDA).

#

plz tag me if someone answers.

scarlet quest
#

someone told me i'm not clear so: "What is the name of the event that fires when a user's role is updated?"

earnest phoenix
#

@scarlet quest lol, on my code worked.

#

you need to define "role"

#

anyone know discordpy here?

amber fractal
#

NaP, read ๐Ÿ‘ the ๐Ÿ‘ docs

slender thistle
#

@earnest phoenix when you're free, DM me the problem

#

Or ask the question here and mention me

earnest phoenix
#

@scarlet quest Sorry for the late reply but I believe it is guildMemberUpdate

scarlet quest
#

@earnest phoenix it was GuildMemberRoleAddEvent , my issue was the method name was incorrect

#

the method name has to be onGuildMemberRoleAdd for some reason you can't make slight change to it..

earnest phoenix
#

Oh ok cool

cold pebble
#

*help

empty owl
#

Dont ask to ask

earnest phoenix
#

can someone here help me with the fortnite shop API

#

im not sure how to use it and the docs arnt helping me

whole hamlet
#

You can console log the output of the request then use that to do what you want with the data

#

I use and use snekfetch,js let {body} = await new fetch("GET", `https://fortnite-public-api.theapinetwork.com/prod09/store/get?language=en`);

You can then

console.log(body)``` then go from there.
amber fractal
#

snekfetch is deprecated

#

highly suggest against it

whole hamlet
#

Is it, didn't know that, thanks

amber fractal
#

:+1:

whole hamlet
#

Thanks man ๐Ÿ‘

amber fractal
#

If someone signs in with Oauth2 does it give you the same code/token every time they log in?

#

I'm not actually doing anything with it

#

just curious

earnest phoenix
#

what should i define items as?

languid dragon
#

what

last lava
amber fractal
#

It does that, just add .5 and cut off the decimal to round

#

Wait

#

I read that wrong

languid dragon
#

just round it

last lava
#

it rounds to integer

languid dragon
#

]]ev Math.floor(1.99999999998)

covert turtleBOT
#
1
languid dragon
#

sec

#

isnt that what you want?

last lava
#

No

languid dragon
#

what are you asking exactly lmao

last lava
#

Itโ€™s adding .2

#

So local += .2 would not work if it was rounded

languid dragon
#

0.1999999999 doesn't round to 2

#

it rounds to 0.2

#

im still not catching on to what you're trying to achieve

last lava
#

0.2 is a double

#

1 is an integer

languid dragon
#

i see

#

the solution in theory to get a double from rounding would be to times the number by 10 to get it to a integer, round that to the nearest whole number and divide it by 10

last lava
#

Yeah

languid dragon
#

that's the only solution i'd be able to think of

last lava
#

I tried that also

viral spade
#

When implementing custom bot prefixes you need to query the database everytime a user sends a message? is that too much work for a relational database (mysql)?

languid dragon
#

]]ev Math.round(0.199 * 10) / 10

covert turtleBOT
#
0.2
last lava
#

Iโ€™ll try that

languid dragon
#

@viral spade cache database entries in your bot and only re-cache when a change is made to the user's guild etc

last lava
#

But my point is why is it returning 0.199999999 when I add 0.2

#

Iโ€™m just curious

viral spade
#

like in a global array?

languid dragon
#

@last lava what you should do is work in whole numbers instead of decimals

#

they're easier to work with and you can convert them to decimal later

#

so if you want to save it as 6.8 in the database, work with 68 and =+ 2 instead of 6.8 =+ 0.2, then once you get a number like 98 you can divide that by 10 to get 9.8 and drop that in the database

#

in theory that would be the best way to do things since it keeps it simple and you're not adding decimals to decimals

#

there's a reason it does that im sure, but i wouldn't know

last lava
#

Okay

languid dragon
#

@viral spade like a map

Map {
    "SERVER_ID_HERE": {
        // the server details etc
    }
}

Map.get("server") // contains all the data
Map.set("server", {
    // the server data from the database
});
viral spade
#

oh nice. thx

#

sorry the ping was mistake

#

@ lizard is there some in memory way of storing/caching data, but still use sql-like queries (join, order, ..) in an easy and efficient way?

tawny lava
#

typing @ NotWeeb would be better yes

#

or not even pinging at all

viral spade
#

i dont want to ping but address him

languid dragon
#

[].length

#

@viral spade uh, there might be but the best way would just cache it and make helper functions or something idk

earnest phoenix
#

Can someone tell me how to cancel the membership of buying a role

#

@languid dragon

languid dragon
#

?????????

earnest phoenix
#

^

languid dragon
#

i can read im not an idiot

earnest phoenix
#

Yeah

languid dragon
earnest phoenix
#

Can you help me

#

Oh I joined this discord from discord donate bot website

#

?

languid dragon
scarlet bane
#

@last lava i looked through your convo and didnt really see an answer to your question idk. Basically, javascript decimal numbers (and most computer numbers actually) aren't perfectly accurate and get as close as possible to the value you want. so in this case adding .2 adds .19999999999 because .1999999999999 is basically .2, and it's most likely as close as the computer can get (because of how computers store decimal numbers in binary). It won't really affect your code in any way though because as you can see, eventually it adds .2.

Tldr: floating point numbers are dumb and thats why .2 == .19999999999

last lava
#

k thx

scarlet bane
#

specifically in javascript though, inaccuracies in numbers occur in other places as well (such as really big numbers)

#

causing the last few digits of really big numbers to be wrong

last lava
#

its just interesting to me

scarlet bane
#

yeah its cool to see how this stuff works

#

i'll see if i can find an article that explains it better than i did

last lava
#

if u do find one, can u dm that to me

scarlet bane
#

its at a bit of a higher level, you need to understand a bit of binary and how computers handle things for you to be able to fully grasp it, but its' a good description of the problem nonetheless.

last lava
#

well ill look into it, thx

scarlet bane
#

๐Ÿ‘

ruby dust
#

does embed.title parse emoji unicodes?

inner jewel
#

a bit late but sums up the floating point thing

amber fractal
mossy vine
#

I think thats because of no ssl cert

dusky marsh
#

^^

#

I think it does that when you're served something on http instead of https

#

As well

amber fractal
#

I have a ssl cert

#

Thats what the options are for

#

That's literally all it is, just a hello, trying to get some stuff to run.

dusky marsh
#

Hm

amber fractal
#

My actual website has ssl, I'm just trying to get this node to run on it, and it's working, just not with ssl :/

earnest phoenix
#

how can i use superagent to use this api? http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true ```const Discord = require("discord.js");
const superagent = require("superagent");

module.exports.run = async (bot,message,args) => {

let {body} = await superagent
.get(http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true);

let dogembed = new Discord.RichEmbed()
.setColor("RANDOM")
.setTitle("Shibe!")
.setTimestamp()
.setImage(body.url)

message.channel.send(dogembed);

}

module.exports.help = {
name: "shibe"
}

#

i'm trying to make superagent to send the generated image

#

but since it doesn't have a name value,only a url, what do i need to put at the .setImage

#

the response returns a json array

#

parse the json

#

i don't have the json

#

yes but the response returns a json

#

yeah but what do i put at the body.url

#

since the json is like [ "image url 1", "image url 2", ... ]

#

yes, you need to parse the response and then you can extract the data from the json object

proud pivot
#

is there a bot preset fore Python

earnest phoenix
#

how could i parse the response? json.parse()?

#

try it and see

#

doesn't work

#

json.parse() and body.parse() doesnt work

#

show your code

#

also, in javascript json is usually all capital if you want to access the class

#
const Discord = require("discord.js");
const superagent = require("superagent");

module.exports.run = async (bot,message,args) => {

 let {body} = await superagent 
  .get(`http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=false`);


  let dogembed = new Discord.RichEmbed()
 .setColor("RANDOM")
 .setTitle("Shibe!")
 .setTimestamp()
 .setImage(body)


   message.channel.send(dogembed);      

}

module.exports.help = {
    name: "shibe"
}
#

jesus christ

#

you use JSON.parse which takes a string, it'll then return a json object you can interact with

#

error

#

descriptive

#

what's your code

#

JSON.parse(body)

#
    const Discord = require("discord.js");
    const superagent = require("superagent");

    module.exports.run = async (bot,message,args) => {

     let {body} = await superagent 
      .get(`http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=false`);

        JSON.parse(body)
      let dogembed = new Discord.RichEmbed()
     .setColor("RANDOM")
     .setTitle("Shibe!")
     .setTimestamp()
     .setImage(body.h)


       message.channel.send(dogembed);      

    }

    module.exports.help = {
        name: "shibe"
    }
#

what does body look like when you console.log it

#

if it's an object, then yeah, JSON.parse takes a json string not an object

#

from what i'm reading on the docs, it returns a response object which then has a body property

#

it returns the josn

#

json

#

the url

amber fractal
slim heart
#

Get a valid cert

amber fractal
#

It's copy paste from the cloudflare dashboard

slim heart
#

Wym? Thatโ€™s showing on ur dash?

grim aspen
#

website certificate is invalid is my best guess

slim heart
#

@earnest phoenix is it a string?

#

Or the actual object

earnest phoenix
#

the url

slim heart
#

Oh wait @earnest phoenix JSON.parse isnโ€™t gonna set the variable you give again, it returns the parsed JSON, you canโ€™t just do .parse(body) and body is now parsed you have to do etc=.parse

amber fractal
#

Yes, it's on my dashboard, it's the certificate I created

earnest phoenix
#

i removed it

slim heart
#

Ok and is it working?

earnest phoenix
#

do i put .setImage(body)

slim heart
#

@amber fractal are you doing it on the right port?

earnest phoenix
#

we told you multiple times

#

body returns the json

#

yes

#

you JSON.parse it which gives you a new object

#

look what he did tell above

#

yes, it returns a new object

slim heart
#

Then you set the return parsed to a variable THEN you use that

#

JSON.parse(var) doesnโ€™t redefine var

amber fractal
#

Yes, I have it on the right poty, I cant connect to it otherwise

#

It even says that it has the certificate

slim heart
#

Hmm

#

Is this an origin server?

amber fractal
slim heart
#

Ok and then did you put said origin certificate on your origin server?

amber fractal
#

I think I know the issue mmLol

#

I need to set up he reverse proxy first

slim heart
#

Oh if youโ€™re using nginx just add the ssl_certificate options and whatnot

amber fractal
#

Im not

#

Its apache2, getting node stuff on it

slim heart
#

O then just make the node use the ssl or sumn

amber fractal
#

That is in node

slim heart
#

Yea isnโ€™t hat what u want?

amber fractal
#

The problem is, it doesnt like it

slim heart
#

Wait one second let me look at what I do

amber fractal
#

I cant have them on the same port

slim heart
#

Hmmm

#

Actually itโ€™d need both of them

amber fractal
#

It has both

slim heart
#

That error would mean that cert is invalid

amber fractal
earnest phoenix
#

try using a different cert like from letsencrypt

slim heart
#

The actual cert cert

#

So like make sure you copied them properly and make sure the site you used is available in the scope of the origin cert you used

#

I think the key is something wrong because it has proper info for your cert

amber fractal
#

Ill try to recopy it

slim heart
#

You need to copy the thing it gives you only once when you first make it

#

The private key

amber fractal
#

I did

slim heart
#

Maybe do the โ€˜utf8โ€™ param just in case? Iโ€™m pretty sure thatโ€™s the default but I mean worth a shot

amber fractal
#

Same

mossy vine
#

is it normal for a div to have a height of 0px but shit inside it still aligns

#
.hood {
    width: 100%;
    height: 5%
}```
#

okay so adding a second href in the div just doesnt work

#

im just gonna dump the entire code here, someone please help

#
body {
    background-color: #282828
}

a {
    color: white;
    text-align: center;
    font-size: 1.4em;
    font-family: 'Montserrat', sans-serif
}

textarea {
    resize: none;
    width: 100%; 
    height: 95%;
    background-color: #303030; 
    color: white;
    font-size: 200%
}

.hood {
    width: 100%;
    height: 5%
}

#about {
    float: right
}

#download {
    float: left
}```
#
<html>
<head>
    <link href="index.css" type="text/css" rel="stylesheet">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
</head>
<body>
    <textarea id="texta" spellcheck="false" autofocus>Welcome to KTaNEPad, an open-source notepad designed specifically for the game Keep Talking and Nobody Explodes.&#10;&#10;Source code available at https://github.com/Cyber28/ktanepad</textarea>
    
    <div class="hood">
        <a id="about" href="https://github.com/Cyber28/ktanepad#documentation" target="_new">About</a>
        <a id="download" href="#">Download</a>
    </div>

</body>
</html>```
#

the div and its contents are broken pls help

#

okay so i decided to use a table instead of the div

#

and width=100% style="table-layout: fixed" work in html

#

but

table {
    table-layout: fixed;
    width: 100%
}```
#

doesnt work

#

and im just confused

#

because if it works properly in html why not in css

#

when its the same thing

#

wait width is not included in the code i posted

slim heart
#

Are you loading the html ๐Ÿ‘€

mossy vine
#

yes

slim heart
#

Also add a ; at the end of width it just big trigger

mossy vine
#

but that doesnt fix anything xd

slim heart
#

I meant loading the style *

mossy vine
#

yes im loading the style, otherwise the background color and textarea wouldnt work

#

but they do

slim heart
#

Check google dev tools and click on the div does it show the resource from the css

mossy vine
#

it doesnt Thonk

slim heart
#

Hmmm

mossy vine
#

well whatever, i guess it can be solved by adding the shit to the table in html

fiery quest
#

Do you guys advise me to import images from local or to use url?
I'm doing an Overwatch bot, and I'd like to print images of Overwatch's heroes, according to a random command

mossy vine
#

i am just confused

#

everything works in html

#

but not css

#

well whatever

dusky marsh
#

@fiery quest it would save you bandwidth to send urls

slim heart
#

@mossy vine just give it a class maybe css doesnโ€™t like tables

dusky marsh
#

Instead of uploading images

mossy vine
#

i was doing class

#

wait

#

oh

#

i think i realized my mistake

#

wait no i dont get it

#

is . for class and # for id?

slim heart
#

Yea. Use urls because if itโ€™s just a constant specific images then yea thereโ€™s no point in making it slower etc.

dusky marsh
#

. For class # for id

mossy vine
#

then it should work

slim heart
#

Coulda just said yes lol

mossy vine
#

but it doesnt

slim heart
#

You did
table {}

#

Not .table

fiery quest
#

@slim heart oh, thank you, that makes sense, didnt think about it

mossy vine
#

that doesnt work

slim heart
#

Wym

#

Did you do class=โ€œtableโ€

mossy vine
#

<table style="table-layout: fixed" id="hood">

#

#hood {
width: 100%
}

slim heart
#

Use class=โ€œhoodโ€ then do .hood because itโ€™s just meant to be like that

mossy vine
#

same thing

#

aka doesnt work

slim heart
#

Does the dev tools still show no css changes?

mossy vine
#

nope

slim heart
#

It literally is-

mossy vine
#

what

slim heart
#

Oh wait hmmmmmmph

#

Send a screenshot of the table block in the css?

mossy vine
#

dis?

slim heart
#

No the css file

mossy vine
slim heart
#

You need ; at the end of all the values in css

#

Ur missing it in all 3

mossy vine
#

no change, and the floats worked without the semicolons

slim heart
#

Yes it does

#

Put the semicolons

mossy vine
#

i did

#

no change

#

no difference anywhere

#

plus im pretty sure vsc would scream at me if i missed a semicolon anywasy

slim heart
#

I gtg but somethings just wrong

mossy vine
#

i know bloblul

mossy vine
#

okay so i dont get this

#

its not being applied

#

why

amber fractal
ruby dust
#

I'm for some reason getting a syntax error on line 174, more specifically on the else thonkku

mossy vine
#

can you show the line bfore it?

inner jewel
#

@amber fractal where did you get the certificate?

ruby dust
#
await ctx.send(embed = discord.Embed(description = discord.Embed(description = get_lang(ctx.message, 'ADMINISTRATION_selfassign_add_fail').format(role.mention), color = 0xFF0000))
proud pivot
#
what Python version do i need 
ruby dust
#

oh wait

#

discord.Embed is apparently a good embed description

mossy vine
#

okay im just even more confused

#

this is fucking annoying

#

it works when writing the css in a <style> tag

#

but not when importing it

#

:angery:

queen sentinel
#

um

#

missing a semi-colon after font-size: 200%?

mossy vine
#

tested, no need for semicolons if its on the last line

#

and everything works

#

except the class

queen sentinel
#

then I am of no help

dusky marsh
#

I've ran into a similiar problem before

mossy vine
#

well how did you fix it?

dusky marsh
#

I literally just deleted everything and started in a different directory, I never got to the underlying issue

mossy vine
#

this is some sick joke

#

i restarted the localhosted webserver (python -m http.server) and its working

#

this is a fucking joke

#

welp okay then

dusky marsh
#

Weird

#

Good that it's going now

mossy vine
#

yeah

amber fractal
#

I finally got it working.

#

@mossy vine its because css does that, reload cache with it

#

Ctrl shift r the page

mossy vine
#

i did and it did not work

#

anyways its all good now

amber fractal
mossy vine
#

i dont use php

amber fractal
#

It's p good

mossy vine
#

eh, i didnt find a use for it so ยฏ_(ใƒ„)_/ยฏ

earnest phoenix
#

php is insecure and a mess

#

it can be secure if used properly, which 99% of times it isnt

icy sorrel
#

I use webpack with versioning enabled when transpiling the assets, so all URLs for JS and CSS files gets some unique ID added to the end of it until it is used again, works quite well for forcing the browser to re-download the assets when there are changes.

earnest phoenix
#

i never used php tbh

#
SenitherToday at 8:40 PM
I use webpack with versioning enabled when transpiling the assets, so all URLs for JS and CSS files gets some unique ID added to the end of it until it is used again, works quite well for forcing the browser to re-download the assets when there are changes.

this ^

#

webpack also supports hot module replacement

#

that's pretty neat

icy sorrel
amber fractal
#

My php is literally only for the css

amber fractal
#

Alright, I have a question. I have an Oauth thing for people to log into a website, I'm at the point where I get the token to make the request to authorize them. How should I go about storing users so they dont have to log in every time and how should I check if they logged in?

restive mantle
#

I might be wrong, but that requires a php/MySQL database. If you want one free use phpMyAdmin, however phpmyadmin is really bad at securing your data. So if you decide to use it dont be shocked if someone gets access to it. Or just buy one ๐Ÿ˜„ hope that helped!@amber fractal

amber fractal
#

That's an example obviously

#

reading up on it

inner jewel
#

no

#

php is rendered server side

#

the php code will be gone

#

unless you fuck up and send the php file without processing it

#

but you can just close the db port

#

so outside connections can't access it

restive mantle
#

there you go xD^

viral spade
#

Hello, i have a question:
Is it too much work for a relational database to make an update query (increment a value) on every (non-bot) message event from any user of any guild? How many guilds can i support approx with an average vps?

restive mantle
#

What would you call the average vps?

inner jewel
#

"is it too much work" depends on what database you're using

restive mantle
#

yasmin can you plz change my nick...

inner jewel
#

but any real database can easily handle tens of thousands of queries per second

viral spade
#

@ yasmin mysql
@ hoister a 5$ digitalocean vps

restive mantle
#

a ok gotcha ๐Ÿ˜‰

inner jewel
#

it should handle that

#

even with thousands of guilds you won't be getting enough messages to bottleneck the db

viral spade
#

ok perfect. i just wanna support at least 20k before i would have to reimplement

restive mantle
#

If you using a free open source software like glitch on the other hand, it will fill up very quickly

inner jewel
#

and even if the db becomes a bottleneck, if the data doesn't have to be extremely accurate, you could keep a counter on the bot, and periodically write to the db

viral spade
#

sure that was always an option but ofc i would like to avoid caching as it adds extra complexity. my more preferred option was to use redis or some other in memory db.

amber fractal
#

So is a MySQL database the way to go with authorizing discord users to the site then?

viral spade
#

but no eyxperience with redis and i need compound keys and complex queries for this and it seems difficult to achieve in redis ..eghh..

inner jewel
#

there's no "the way to go" database

amber fractal
#

Well

inner jewel
#

you use the database that's more appropriate for what you have

viral spade
#

i think mysql is the way to go when youre starting as it is very established and has lots of resources

inner jewel
#

oracle tho

amber fractal
#

How would I be able to tell if they logged in, cookies or something? I should really take a more advanced web development class mmLol

viral spade
#

sessions

inner jewel
#

yes you should learn webdev

#

you can use cookies, you can use localstorage + js, <insert dozens of other alternatives>

amber fractal
#

I use local storage for themes

#

Do the codes that it gives you on redirect expire?

#

Well I expect they do

#

just how long

inner jewel
#

just instantly exchange them

candid oak
#

how do spoiler images work

#

is there a field in the API?

amber fractal
#

SPOILER_imgname.png

#

I think that turns an image into a spoiler

earnest phoenix
#

hey

#

when i put the.. database firebase on my bot index

#

Its say on log a error "Duplicated File"

cold pebble
#

!help

amber fractal
#

Ez mute tho

cold pebble
#

.help

amber fractal
#

@surreal peak

#

And that will either get you muted or banned

cold pebble
#

??

#

Why

amber fractal
#

Did you read rules?

cold pebble
#

OOPS

#

nooo... ๐Ÿ˜ญ

amber fractal
#

You know how much you just spammed the api?

cold pebble
#

๐Ÿ˜ฆ

#

I am not english and I am not really good for reading english RIP

earnest phoenix
#

@amber fractal do you know?

amber fractal
#

Oops

#

Didnt mean to delete that

#

Anyways, I said from what the error says, the file is duplicated

cold pebble
#

How to do in a server we can do an command to set the welcome channel for my bot Someone can help me pls? (Language: JavaScript)

kind roost
#

hi

#

some node expert that tellme how to acces to the data of the follwing object pls

#
Promise {
  [ { 
    name: 'Shinoa',
    atk: 8400,
    def: 5400,
    class: 'Beast7',
    userbg: '2',
    rate: '5',
    lg: '1',
    quartz: 10050,
    quartzdate: '2019-02-25T01:21:39.000Z',
    hash: 'b379867bd1cd486be086ee32969466b7.png',
    discriminator: '3948' } ] }
smoky spire
#

Resolve the promise

kind roost
#

hmmm}

amber fractal
#

I got a 401, idk why it'd be unauthorized tho

earnest phoenix
#

you need to exchange your code for an access token

amber fractal
#

So I need to make another request I'm guessing

amber fractal
#

Now I'm getting a 301 error

opaque eagle
#
import * as Discord from "discord.js";
import { CommandStore } from "./structures";

import { readdirSync, lstatSync } from "fs";
import * as path from "path";

class Rubicon extends Discord.Client {}``````sh
MacBook-Pro:Rubicon sinistercyborg$ token="xxx" yarn start
yarn run v1.13.0
$ node --experimental-modules main.mjs
(node:45854) ExperimentalWarning: The ESM module loader is experimental.
file:///Users/sinistercyborg/Projects/Rubicon/main.mjs:1
import {Client} from "discord.js";
        ^^^^^^
SyntaxError: The requested module 'discord.js' does not provide an export named 'Client'
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:88:21)```
amber fractal
#

Well now it says bad request mmLol

#

And now it says access denied

#

I seriously dont know what I'm doing wrong

hushed berry
#

@amber fractal 301 isnt an error Thonk

knotty steeple
#

huh

#

it is Thonk

amber fractal
#

idk wym

#

That's not what I'm getting now tho. I keep getting access denied when trying to exchange a code for the token for oauth

topaz fjord
#

@kind roost ```
const thing = await <your promise emitting thing>;
console.log(thing[0])

#

301 isn't an error

#

it's a redirection

#

heck

amber fractal
#

If it doesnt work I call it an error

#

and it didnt work

#

and it's code was 301

#

therefore it was an error with the code 301

topaz fjord
#

but that's not the correct terminology

amber fractal
#

Imma be honest

#

I dont really care

topaz fjord
#

You should

amber fractal
#

Why?

topaz fjord
#

because

amber fractal
#

There is no good reason

topaz fjord
#

understanding http response codes is the first step to success mmLol

amber fractal
#

All I need to do is put http 301

#

not that hard

earnest phoenix
#

if you want to explain what your process of doing oauth is i can help you

amber fractal
#

I mean it shouldnt matter should it? It's just giving me access denied with and without authorization on the post request

#

I get the code then make the request

#

I don't actually know any other way to explain it

earnest phoenix
#

it should

#

the oauth process is very sensitive on order of operations

amber fractal
#

Redirect to authorize > get code > fail post request

earnest phoenix
#

what do you pass to the POST

amber fractal
topaz fjord
#

can you show the whole thing

#

it's hard to work with pieces when trying to help

#

just take out any sensitive stuff when posting

earnest phoenix
#

basically you can show everything but the client secret

topaz fjord
#

^

amber fractal
#
let { CLIENT_ID,
      CLIENT_SECRET,
      TOKEN,
    } = JSON.parse(fs.readFileSync('./privates.json', 'utf8'))
var authapp = express()
authapp.get('/', (req, res) => {
  let code = req.originalUrl.split("=")[1]
  console.log(code)
  let postData = querystring.stringify({
   'grant_type': 'authorization_code',
   'client_id': CLIENT_ID,
   'client_secret': CLIENT_SECRET,
   'code': code,
   'redirect_uri': redirecturi,
   'scope': 'identify' 
  })
  let reqOptions = {
    host: "discordapp.com",
    path: `/api/oauth2/token`,
    headers: {
      // 'Authorization': `Bot ${TOKEN}`,
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: "POST"
  }
  let tokenGrant = https.request(reqOptions, (res) => {
    res.setEncoding('utf8');
    res.on('data', (response) => {
      console.log(`Response: ${response}`);
    });
    res.on('end', () => {
      console.log('Res end.');
    });
  })
  
  tokenGrant.on('error', (e) => {
    console.error(`Error: ${e.message}`);
  });
  tokenGrant.write(postData);
  tokenGrant.end();```
#

I tried it with and without authorization

#

wasnt sure if it was required because they dont do it in the example

earnest phoenix
#

have you ensured the codes match

amber fractal
#

Yep

#

The code in my url is the same one that it logged when I last tested

#

I thought it was client secret at first, but I regened and copied again, no luck

earnest phoenix
#

'scope': 'identify' in the post data is redundant, it doesn't ask for it

amber fractal
#

I did it without at first anyways

#

Ill remove it

#

It does the same thing tho

earnest phoenix
#

and your redirect uri matches?

amber fractal
#

yep

#

I was setting them when I made this so it's a copy paste

earnest phoenix
#

something in those props doesn't match

amber fractal
#

wym

earnest phoenix
#

because i have the equivalent of that in c# and it works

#

recheck values you're passing

amber fractal
#

weird, I ensured the id is right, the secret and the code

#

I can post the code it gives me right?

#

Theres no harm with that?

earnest phoenix
#

correct

#

can't use access tokens without your app's client secret

amber fractal
#

All that is correct.

#

I can log the post data if you want

earnest phoenix
#

and redirect uri?

amber fractal
#

Just my website

earnest phoenix
#

are you sure it's correct though

amber fractal
#

If copy pasting it from my browser could be wrong, I'd be upset

hushed berry
#

@amber fractal am i missing something or is the body never attached to the post req?

amber fractal
#

It is

hushed berry
#

where?

amber fractal
#

tokenGrant.write(postData);

hushed berry
#

oh i see

amber fractal
#

It's the same result if I append it to the end of the url

hushed berry
#

that may not actually work

amber fractal
#

Well I did it both ways

hushed berry
#

is that the correct way to do form encoded things?

amber fractal
#

both say access denied

#

querystring.stringify

#

Turns it into this

earnest phoenix
#

if it turns into url parameters

#

that's not how it works

#

you have to define values in the request body

hushed berry
#

i dont think hes wrong there

amber fractal
#

Oh

hushed berry
#

form-urlencoded is defined as just that

amber fractal
#

shit

#

Welp

hushed berry
#

?

amber fractal
#

Regen

#

FIrst time Ive done that

hushed berry
#

oh lol

#

we've all been there

#

no worries friend

amber fractal
#

Regened, it logs the new secret, same message tho

earnest phoenix
#

can you screenshot your redirect uris page on the discord app page

amber fractal
earnest phoenix
#

weird

amber fractal
#

Well, I'll try again on a better day, huh?

#

I'm gonna go do home work

earnest phoenix
#

im rereading discord's docs

amber fractal
#

If you have any ideas mention me so I can find them later ๐Ÿ‘Œ

earnest phoenix
#

seems that they require the scope param now too

amber fractal
#

Yeah, I had it there

#

I would need that in my initial redirect to authorize too wouldnt I?

earnest phoenix
#

yes

#

it might be something with your lib to make http requests

#

try a different one and see if it still occurs i guess?

amber fractal
#

I tried it with request and node https

earnest phoenix
#

i'm going to try booting up my old copy of oauth authorization and see if it works

amber fractal
#

wait I didnt get access denied this time

#

it actually didnt say anything

earnest phoenix
#

it isn't your fault

#

discord api is messing up

amber fractal
#

Oh

earnest phoenix
#

errors are happening to me too

amber fractal
#

Wait this whole time mmLol

#

I've been working on this for hours lmao

earnest phoenix
#

wait

#

i think i know a problem with mine

#

unmatched redirect uris

#

let me add and see again

amber fractal
#

I just went straight to the dev page and copied the link it gave me

#

And now it doesnt give me a response, weird

earnest phoenix
#

works flawlessly for me

#

https://discordapp.com/oauth2/authorize?client_id=336861298459410434&redirect_uri=http://localhost&response_type=code&scope=identify%20guilds

amber fractal
#

I have it redirect to my /auth then to the home page, https://discordapp.com/api/oauth2/authorize?client_id=529553417882959872&redirect_uri=https%3A%2F%2Fpetbot.tk%2Fauth&response_type=code&scope=identify

#

I just dont understand why it's access denied you know?

hushed berry
#

@amber fractal didnt you say you got 401 and not 403

amber fractal
#

That was a while ago

#

and I said 301

hushed berry
#

ik

amber fractal
#

I had the wrong page

hushed berry
#

just wanted to make sure you were actually getting 403

#

and not 401

amber fractal
hushed berry
#

You should be able to pull the code out of the response

amber fractal
#

that's logging the whole thing

#

because the request is successful

#

that's discords response

#

Actually yeah

#

why doesnt it give me the code

earnest phoenix
#

sorry for the bd logo too lazy to crack it just for a demonstration

#

auth process -> authorized -> grab the code by using new URL(..).searchParams.get("code") -> make a request to my backend

#

my backend then does a POST with the method i sent above

amber fractal
#

I'm just honestly not gonna do it for now. I dont know why it says access denied and I dont have the time to figure it out mmLol

topaz fjord
#

@amber fractal go it to work

#

*got

#

It's not json data

#

That's my code

amber fractal
#

What do you mean json data?

#

for what

#

It's a querystring

scarlet bane
#

did you create all_items_message before your for loop?

#

I can't see it in your snippet

high lava
#

While using this code as a promise, whether I use it like this or with Async/await it simply seems to skip over the .awaitMessages() method and go straight to trying to send an empty message.

m.channel.awaitMessages(filter, { max: 1, time: 10000, errors: ['time'] }).then(input => m.channel.send(input)).catch(err => console.log(err));
#

And yes, filter is defined elsewhere in the code

spring ember
#

What lib is that

high lava
#

djs

spring ember
#

What version

high lava
#

stable

spring ember
#

Also awaitMessages returns a promise of a collection @high lava

high lava
#

thanks for that. That helped me avoid a problem before I encountered it

#

Turns out I made one little typo in my filter so it still counted a null input from the bot before hand

spring ember
#

๐Ÿ‘Œ

blazing mason
#

Anyone know lots about discords rate-limiting? I have a bot that plays a game over DMs with many people (it's a MUD, for the curious) and I'm curious about when I might run into problems. I'm not concerned much about "per-channel" limits, more about "(when) Will Discord API care if I hammer out, say, 50 DMs to 50 different users, every few seconds"

mossy vine
#

dont mass dm

blazing mason
#

I've done a little research but haven't been able to find much that's specific about that

#

well, that's how it works

mossy vine
#

mass dming is api abuse no matter how you do it

blazing mason
#

ok, then, my question is "when is it mass dming"?

mossy vine
#

what do you count as "many" people?

blazing mason
#

that's my question, exactly

#

what's too much?

mossy vine
#

it also depends on how many games are played at once, rate-limit can quickly fuck you up

sinful lotus
#

mass dming consists of intentionally sending dm in a loop on all users the bot can seee

blazing mason
#

right. that's why I'm asking

#

no, that's totally 100% not what I'm doing then

#

so, what I'm asking is not "should I do this?", but "how far is it ok to do what I'm already doing?"

sinful lotus
#

if the user will send a command to bot before the bot will dm them

#

thats fine

mossy vine
#

say its like 3 people and there are 10 games running, i doubt that would really be api abuse

blazing mason
#

yeah, that's also not the concern, it's all very, very opt-in and voluntary

#

it's one single, shared game, with many people

#

when something interesting happens "in-game", it may DM all the active players. Players "login" and "logout" to set their "active" status.

#

no one ever gets DM'd that doesn't want/expect it, that sort of thing, it's all very polite with regards to users

#

it's being rude to like, "the discord API" that I'm worried about, in that, like... well, an important game event might DM 50 users (who are all willing and opted-in to receive such a DM, and probably waiting in anticipation for it even ๐Ÿ˜› )

#

is DMing 50 users that are totally expecting it, at once, ok? How about if I do that once a minute?

#

those are the sorts of questions I have. (those aren't my exact questions/numbers)

sinful lotus
#

better ask on discord api server

#

they can help you better there

blazing mason
#

so yeah, always interested in any discussions around that, if anyone wants to engage.

It's already an ongoing project and stuff, so it's not a "don't that thing". I have players and users and world editors that are enjoying what they're doing.

It's a "how far can I take this and still be OK with the API?" thing. And a "ok, how can me as a developer and my users still have fun and stay OK?". (And, eventually, I'm sure it'll come to a "Well, I guess we've outgrown this and I'll make a webapp instead" thing.)

icy sorrel
#

I think the main issue you're gonna run into is hitting the ratelimit on Discords end, if the bot grows and more people would need to be DMed you wouldn't be able to send the message to enough people fast enough under the Discord limits, but yeah send them an email or DM them about it to make sure it's alright.

blazing mason
#

yeah, that's a good idea I guess, thanks. Was just thinking some people here might have made something similar or had experience with something like that.

#

Like... suppose you made a bot that watched stocks, and then sent out DMs to anyone that opt-ed in

#

that would be rather similar to what I'm doing. a bot like that might DM 50 users "Hey, Amazon just dropped below your watch point!"

#

ah, good thoughts there, too... thanks Senither

#

and all of you

#

I use discord.js and wrote a handler to watch for rate limit events. The only time I see them is on "per channel" limits -- I'm DMing a single user too fast. That's fine, that doesn't break my game. Discord.js seems real chill with it's backoff feature and won't abuse the API once it hits those.

#

I haven't seen any other rate limit events telling me like, "Hey, you're just flat out DOING TOO MUCH"

#

(yet)

dense dove
#

If that's the case... doesn't yag bot mass dm for their cards of humanity game?

sinful lotus
#

the rate limit event just emit if d.js is doing the ratelimit preventer to prevent you going upward that ratelimit

#

you could also adjust the ratelimit preventer a bit

blazing mason
#

Nice! That's great info there... there's a Cards of Humanity bot that may do something similar!

#

tyvm

dense dove
#

That's on yag bot btw

blazing mason
#

Are you sure QuantumQt? It looks like a response header thing from the server. It tells me the difference between me and the server time, and stuff like that.

#

I thought it like... waited for a single time that the server was like "Hey, I'm gonna limit you, back off" and then it was like, ok... will handle

sinful lotus
blazing mason
#

yag bot. thanks. that's great info

sinful lotus
#

then look on the stuff that starts with rest

#

and d.js handle the request "before you reach the ratelimit"

blazing mason
#

ahhh... so I'm getting REST responses, not 500 errors I think? Am I saying that right?

sinful lotus
#

thats about the ratelimit handler of d.js

blazing mason
#

yeah, but... ok... yeah I think I'm getting it

#

yeah, thanks for that page, that's super helpful too

#

this game is like... I don't suppose anyone's familar with a MUD? Multi-user Dungeon?

#

like, text-adventure RPG game with multiplayers, kinda?

#

...runescape without the graphics?

sinful lotus
#

well as I said as long as you dont do something like using a bot to mass dm people an invite link

#

or using that to advertise

blazing mason
#

noooo nothing every remotely like that heh

sinful lotus
#

also if they opt in

dense dove
#

There's partnerships bot that do just that...

sinful lotus
#

I dont think thats api abuse either ways

blazing mason
#

this is is legit application, and like, fun, and totally opt-in

dense dove
#

Shouldn't those be discontinued?

sinful lotus
#

all you need to do is just dont get over the permitted requests per sec or mins

blazing mason
#

if the bot DMs you at all it's because you said "hey, I'm interested in receiving these specific DMs" and a single command turns them off totally

sinful lotus
#

but tbh if you have doubts about ratelimits in discord's api till now, better ask in Discord API Server

blazing mason
#

I care sooo much about my users, this project is so cool to see it working, and people walking around in a game world and mobs and stuff, I don't want to piss anyone off.

dense dove
blazing mason
#

Yeah, will do that, thanks. Really interested in hearing about any other bots that anyone can think of that sound similar, too... gives me a great "yardstick" to go "Ohhh well that one stock watcher bot I know about has to be sending out like, ...."

#

That was about the "closest" example I've thought of, a stock watcher bot or something. The use case is totally different, but it might have very similar traffic (and totally similar in that no one is ever getting DMs they wouldn't want/expect)

#

That yag bot/CaH example sounds great, too, thanks for that.

#

Thanks again everyone for the insights and thoughts and links and info!

#

I don't want to use the "partnership bot" as an example to anyone I'm talking to about my project, 'cuz I don't want to be grouped with that sort of application at all. But that's interesting to know that that's a thing, I didn't really consider those bots. Yuk.

cinder charm
#

how do you make a bot?

mossy vine
#

you learn a programming language first

sinful lotus
cinder charm
#

i cant install node.s

mossy vine
#

do you know any programming languages?

cinder charm
#

a little

#

but once i get the hang of im of

earnest phoenix
#

which ones

cinder charm
#

python for example

earnest phoenix
#

discord.py is a library for python, i suggest using that

cinder charm
#

ok

#

but my biggest problem in programming is starting the code

unborn bloom
#

when using discord.js, how would I check if the bot has permission to send a message to a channel?

sinful lotus
#

stable or master?

unborn bloom
#

"discord.js": "^11.4.2",

sinful lotus
#

<channel>.permissionsFor(<guild>.me).has(["VIEW_CHANNEL", "SEND_MESSAGES"])

unborn bloom
#

and how do I check if the bot is still in a guild?

sinful lotus
#

client.guilds.has(<guild_id>)

unborn bloom
#

thank you

amber fractal
#

Alright, I've been having this error since yesterday. I'm trying to exchnge a code for a token with OAuth, I keep getting access denied, the code, client id, client secret and redirect uri are correct, so I'm not sure what the error is. I've tried it with and without the Auth header

#
console.log("Code " + code)
console.log("ID " + CLIENT_ID)
let postData = querystring.stringify({
  'grant_type': 'authorization_code',
  'client_id': CLIENT_ID,
  'client_secret': CLIENT_SECRET,
  'code': code,
  'redirect_uri': redirecturi,
  'scope': 'indentify'
})
console.log(postData)
let reqOptions = {
  host: "discordapp.com",
  path: `/api/oauth2/token`,
  headers: {
    // 'Authorization': `Bot ${TOKEN}`,
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  method: "POST"
}
let tokenGrant = https.request(reqOptions, (res) => {
  res.on('data', (response) => {
    console.log(`Response: ${response}`);
  });
  res.on('end', () => {
    console.log('Res end.');
  });
})

tokenGrant.on('error', (e) => {
  console.error(`Error: ${e.message}`);
});
tokenGrant.write(postData);
tokenGrant.end();```
#

This is in node

rotund sinew
#

@amber fractal Code works for me, make sure your using the latest edition of Node

#

Oh wait... does this count as randomly pinging

#

if Im trying to make sure he sees the answer

amber fractal
#

No, Im fine with pings

#

That code works for you?

rotund sinew
#

Yea

amber fractal
#

So either the client id, code or secret is wrong

#

I checked those tho

rotund sinew
#

By the way, is there a free way to set up my bot to stay on 24/7?

#

I dont want it off while Im off

slender thistle
#

Really bad hosts are on point

#

You could rent some cheap VPS with small specs

rotund sinew
#

I heard you can run it through GitHub, but Im not sure

#

Thats not really how github works

amber fractal
#

I just send the code right? Not code=blah?

rotund sinew
#

Yea

amber fractal
#

I dont know why this wont work

rotund sinew
#

I do have a code question about node

#

How can I make a custom Join message?

#

Like Welcome to the server @bla-bla

mossy vine
#

read the docs

rotund sinew
#

I have, nothing is helping with that

mossy vine
#

also you can only host static websites with github pages

#

what lib

amber fractal
#

So the code is wrong Thonk

#

But it matches the one that I get in the url

rotund sinew
#

Hmmm

slender thistle
#

@rotund sinew some function that will be called when a member joins a guild/server

#

Picking a channel should be up to the server moderators

rotund sinew
#

Well yea, Im just making on public one and one private one

inner jewel
#

@amber fractal the code won't ever be equal to those

#

it's generated each time authorization happens

lime fiber
grim aspen
#

@rotund sinew best way to host a bot is a vps, yes it's possible to host a bot on github, but it's more likely you can get your bot token stolen and get banned for api abuse that way

rotund sinew
#

The thing is I can't afford a vps...

grim aspen
#

do you have a computer you don't use much?

#

you can run the program off the computer

#

and leave it running

slender thistle
#

@lime fiber your script somehow can't connect to DBL

#

Cpt. Obvious is here

rotund sinew
#

Sorta

#

I can't run it all night though

lime fiber
#

๐Ÿค” but why?

rotund sinew
#

I have a computer specifically for developing

#

Bot was a good pun lol

#

Because its at work

slender thistle
#

How are you using aiohttp and what is its version?

amber fractal
#

@inner jewel the code in my url is the same one that it passes to send the post request is what I'm saying

slender thistle
#

Oh, it's dblpy

amber fractal
#

This error is kinda annoying not gonna lie, can't find the issue

rotund sinew
#

I have a working ban code client.on("message", (message) => { if (message.content.startsWith("$ban")) { if(!message.member.roles.find("name", "MODS")) return; // Easy way to get member object though mentions. var member= message.mentions.members.first(); // ban member.ban().then((member) => { // Successmessage message.channel.send(":wave: " + member.displayName + " has been successfully banned :point_right: "); }).catch(() => { // Failmessage message.channel.send("Access Denied"); }); } }); This ban code works but you have to ping the person for it to work. If you do $ban User it crashes the whole bot, anyone got any ideas how to fix that?

mossy vine
#

if (!member) return

#

also dont do message.member.roles.find

#

instead check for permission

#

not every server names their moderators the same

rotund sinew
#

I've had trouble with permissions

#

Using the docs, the bot comes back with errors

#

if (!member) return Where would that go?

grim aspen
#

what is the error that's coming up?

rotund sinew
#

Im gonna have to find the code again to find it

slender thistle
#

U s e c o d e b l o c k please

grim aspen
#

god damnit

slender thistle
#

Also, rip spoonfeed

grim aspen
#

actually, if that message was

rotund sinew
#

Creeper

#

Would that code restrict the code to administrators?

#

That makes the ban not work

#

The code you gave

grim aspen
#

hold on

rotund sinew
#

DM me with an answer if you have one

earnest phoenix
#

Can someone help me with MongoDB?

slender thistle
#

What's up

earnest phoenix
#

I want to make a db for warnings

slender thistle
#

Store a document with reason, user ID and probably the user ID of the user who issued the warn

earnest phoenix
#

I can't figure out how...

#

I'm currently hosting on glitch

slender thistle
#

Dk if it supports mongo

#

There should be a method to insert a JSON document in your mongodb library

earnest phoenix
#

k

lunar knot
#

idk if this fits, but how do you create a webpage which automatically refers to another website?
Like you have the main site example.whatever and you can use example.whatever/invite to get to the discord stuff

lunar knot
#

thanks ^^

rocky dagger
#

apparently 'id' is undefined. does any1 know why?

marble needle
#

mind showing your code

rocky dagger
#

just wait a sec