#development

1 messages · Page 722 of 1

glossy vigil
#

hey, is here someone that can me help with message.attachments in discord.py rewrite`?

earnest phoenix
#

for javascript you'd use node.js, for c#/any other .net language you'd use .net core

slender thistle
#

What's up, Shinya

glossy vigil
cedar brook
#

No chatting here.

slender thistle
#

I hope you saw their question

glossy vigil
#

shivuwu do you know how i get the url from the from a attachment?

loud salmon
#

@cedar brook please dont minimod

glossy vigil
#

message.attachments[0]['url'] give me a error

slender thistle
#

Yeah Attachment object isn't a dict

cedar brook
#

I am not. @loud salmon

loud salmon
cedar brook
#

;-;

loud salmon
#

you were telling people what to do and to stop chatting

#

when they werent actually breaking any rules

cedar brook
#

Read topic please.

glossy vigil
#

can you explain me how i get the url?

cedar brook
#

I am just trying to don't break rules.

loud salmon
#

I do know the topic

#

and they were chatting about bot development

#

they were just being polite

#

and saying hello to each other first

slender thistle
#

@glossy vigil Tried <Attachment>.url yet?

glossy vigil
#

with <> ? no

cedar brook
#

The, hello Spider, what's up?

slender thistle
#

Not literally my fam

glossy vigil
#

lets see

slender thistle
#

message.attachments is a list consisting of discord.Attachment objects

#

By doing message.attachments[0] you get a first item from that list, which will be an instance of discord.Attachment
Now, that instance should have property url

#

Or on <1.3.0 versions, stringify the object k3llyShrug

glossy vigil
#

print(message.attachments[0]['<Attachment>.url'])
this like?

slender thistle
#

Nop

#

Attachment object (message.attachments[0]) is not a dictionary

#

it's a separate object with its own attributes

glossy vigil
#

ah 😮

slender thistle
#

And what I meant by <Attachment>.url is Attachment object should have an attribute url, which by itself should return a link

lofty hamlet
#

Hi, how i can get the id of all personn of a discord ?

slender thistle
#

iterate through all members, store IDs

lofty hamlet
#

How ? oliythink

glossy vigil
#

how i get from message.attachment[0]
to <Attachment> then?

slender thistle
#

A simple iteration, get member.id special_think

earnest phoenix
#

why do people not know how to do their research

sudden geyser
#

it's discord

glossy vigil
#

for i in ctx.guild.members:
await ctx.send(i.id)
lol

slender thistle
#

No

#

That's a bad example

glossy vigil
#

its spam i know

earnest phoenix
#

why do people think everyone's working in the same language they're working in

glossy vigil
#

cry, we all are genius thats why

slender thistle
#

message.attachments[0] is already the Attachment object
<Attachment> in my messages is supposed to be replaced by your Attachment object, which you get by getting the first item of list message.attachments

#

You don't literally put <Attachment> in your code, nor do you get it

#

It just stands for "Attachment object"

glossy vigil
#

i can follow you, but i need to print out the url without the rest

slender thistle
#

Well yeah you sent the object repr

#

Ehh try using .url attribute

barren brook
#

So I want a sertain message to go into a embed that will track when someone says something and end up in a Embed saying Completed or Uncompleted If its uncompleted they didnt type A
If its completed they did Can someone help make that and Dm me

slender thistle
#

and no, it's not a key that you access in a dict

glossy vigil
#

i can not handle this as a list, not as a dict.
how than?
message.attachment.url don´t works too 😂
I am stupid i know

slender thistle
#

How did you get the Attachment object itself

glossy vigil
#

print(message.attachments)

slender thistle
#

That doesn't exist

earnest phoenix
#

why are you disregarding everything that's being said

#

you already got told you have to use message.attachments

#

however, since it's a list of attachment objects, you need to get one out of it, by indexing

glossy vigil
#

NonType

earnest phoenix
#

what

slender thistle
#

How did you get the first item of message.attachments

#

or really anything from that list

glossy vigil
#

with a for loop

#

for i in message.attachments:

slender thistle
#

Oh well, your i variable inside the loop is an Attachment object

#

and that object has attribute url

glossy vigil
#

ok.
now i have understand 😮

slender thistle
#

... I just hope you don't send a message per attachment...

glossy vigil
#

nono

#

thank you very much

earnest phoenix
#

Every Discord.PY Bot Tutorial:

@client.command```
ME:
```python
if message.content.startswith('&rng'):
        print("[FLAME] RNG Command Sent")
        args = message.content.split(" ")```
#

why? cause its the only method that works

#

ok

slender thistle
#

No

#

Every discord.py commands ext tutorial:

@bot.command()
#

You are not supposed to name an instance of commands.Bot anything other than bot or anything similar

#

Especially if you, for some unknown stupid reasons, use both discord.Client AND commands.Bot in your code

lofty hamlet
#
                console.log(i.id)
            }``` does not work, no error
slender thistle
#

Don't you need to use i.user

lofty hamlet
#

I do use what ?

slender thistle
#

.id seems to be an attribute of an User object

earnest phoenix
#

you can use id on a guild member too

slender thistle
#

while you are iterating over Member objects

#

Oh

earnest phoenix
#

members is a collection, which implements a map

slender thistle
#

interesting

slender thistle
#

JS has some interesting things

#

Actually doesn't py have that too

earnest phoenix
#

yeah py's version of that is a dictionary

lofty hamlet
#

KK

slender thistle
#

So I can pretty much say that dict is a JS Map?

mossy vine
#

arent dicts more like objects in js

slender thistle
#

Eh either way

#

Should read up on some stuff to refresh memory

lofty hamlet
#
                if (member.id != bot.user.id && !member.user.bot) console.log(member.username)
            });```
#

Good track?

earnest phoenix
lofty hamlet
#

😂

#

Yeah but console say undefined

earnest phoenix
#

people here have to understand not everything is going to be first try, run it, see if it does what you expect, if not, go back and see where you went wrong

#

foreach provides you with three arguments

#

look at the doc page i sent you

frozen cedar
#

{
    "guildid": "",
    "premium": "",
    "cooldown": "",
    "binds": [
        {
            "bindID": 0,
            "bindGID": 0,
            "bindROID": 0,
            "bindALLWDRLS": 0
        }

    ]

   }```

Any ideas how to use NodeJS to add a 'binds' *object*?
#

I can't quite figure it out.

lofty hamlet
#

I can add and remove lot of role of personn ona discord who have 1500 peronns ?

#

Or my bot get banned ?

frozen cedar
#

Sigh, add a delay and follow the ratelimit guidelines

#

and you will be fine.

lofty hamlet
#

LMmmh ok what is the rate limit ?

mossy vine
#

arent ratelimits flexible

lofty hamlet
#

?

earnest phoenix
#

yes, they are

#

ratelimits aren't static

#

they adapt to how much you respect them (which if you don't it leads to an api ban) and can change anytime

lofty hamlet
#

SoI can add a role to 1700 people?

frozen cedar
#

🤦

#

yes, just add a 2-3 sec delay per person

#

if u really want to not get rate limited

#

itll only take a hour 😛

#

anyone know how to answer my question above?

lofty hamlet
#
                if (member.user[sender.id]) {
                    if (Dresseur[member.user.id].Points <= 350) {

                        message.member.addRole("538459462734839829")
                    } else if ((Dresseur[member.user.id].Points >= 351) && (Dresseur[member.user.id].Points <= 650)) {
                        Dresseur[member.user.id].Grade = "Dresseur Novice (351 - 650)"

                        message.member.addRole("502550139693563906")
                        message.member.removeRole("538459462734839829")

                    } else if ((Dresseur[member.user.id].Points >= 351) && (Dresseur[member.user.id].Points <= 1000)) {
                        Dresseur[member.user.id].Grade = "Dresseur Branché (651 - 1 000)"

                        message.member.addRole("502549651560464395")
                        message.member.removeRoles(['538459462734839829', '502550139693563906'])

                    }
                }
            });```
#

For exemple

#

I want make this

#

If i add timeout of 4-5 seconds i have legit ?

#

I do not want to be deprived of API

frozen cedar
#

yea

#

4 is good

sudden geyser
#

oh god

lofty hamlet
#

@sudden geyser what ?

earnest phoenix
#

lel

frozen cedar
#

{
    "guildid": "",
    "premium": "",
    "cooldown": "",
    "binds": [
        {
            "bindID": 0,
            "bindGID": 0,
            "bindROID": 0,
            "bindALLWDRLS": 0
        }

    ]

   }```

Any ideas how to use NodeJS to add a 'binds' *object*?
short siren
#

let binds = {}

#

@frozen cedar

#

Also why is there an array in binds

#
{
    "guildid": "",
    "premium": "",
    "cooldown": "",
    "binds": {
       "bindID": 0,
       "bindGID": 0,
       "bindROID": 0,
       "bindALLWDRLS": 0
    }
}```
frozen cedar
#

wym?

#

isnt that propper formatting?

#

the array i already have in binds is an example of what i want to push into the object

#

@short siren

#

also just setting another array variable doesnt help, i gotta be able to push it into the json as a whole

#

I need to know how to turn this

#

{
    "guildid": "",
    "premium": "",
    "cooldown": "",
    "binds": [
        {
            "bindID": 0,
            "bindGID": 0,
            "bindROID": 0,
            "bindALLWDRLS": 0
        }

    ]

   }```
#

into this

#

{
    "guildid": "",
    "premium": "",
    "cooldown": "",
    "binds": [
        {
            "bindID": 0,
            "bindGID": 0,
            "bindROID": 0,
            "bindALLWDRLS": 0
        }, 
        {
            "bindID": 1,
            "bindGID": 0,
            "bindROID": 0,
            "bindALLWDRLS": 0
        }
    ]

   }```
short siren
#

Ohh, That's what you were trying to do

#

@frozen cedar It's an array so you can just push

frozen cedar
#

i can push a whole object?

valid frigate
#

that's what object oriented programming is all about

#

you can push anything you want

short siren
#
let target = {
    "guildid": "",
    "premium": "",
    "cooldown": "",
    "binds": [
        {
            "bindID": 0,
            "bindGID": 0,
            "bindROID": 0,
            "bindALLWDRLS": 0
        }
    ]
}

const source = { "bindID": 0, "bindGID": 0, "bindROID": 0, "bindALLWDRLS": 0 }
          
target.binds.push(source)

console.log(target);```
#

Mine doesn't look that neat as it was quick ignore inlines

frozen cedar
#

😮

#

so i legit just push

#

oml thx

#

i didnt know i could push like that

dusky marsh
#

oop ftw

earnest phoenix
#

well my clear command broke itself

modest maple
#

F

undone rose
#

@lofty hamlet Make sure you're doing it right

#

Don't just setTimeout() your loop lmao

distant plank
#

I get this problem a lot in the mysql database, I use keyv to upload data, discord.js

2019-11-03T21:41:09.382506+00:00 app[worker.1]: (node:22) UnhandledPromiseRejectionWarning: Error: Incorrect string value: '\xF0\x9D\x90\x98\xF0\x9D...' for column 'value' at row 1
2019-11-03T21:41:09.38252+00:00 app[worker.1]:     at PromiseConnection.execute (/app/node_modules/mysql2/promise.js:102:20)
2019-11-03T21:41:09.382524+00:00 app[worker.1]:     at sql (/app/node_modules/@keyv/mysql/src/index.js:19:30)
2019-11-03T21:41:09.382526+00:00 app[worker.1]:     at connected.then.query (/app/node_modules/@keyv/sql/src/index.js:39:19)
2019-11-03T21:41:09.382529+00:00 app[worker.1]:     at <anonymous>
2019-11-03T21:41:09.382531+00:00 app[worker.1]:     at process._tickCallback (internal/process/next_tick.js:189:7)
2019-11-03T21:41:09.382724+00:00 app[worker.1]: (node:22) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2019-11-03T21:41:09.382846+00:00 app[worker.1]: (node:22) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
#

and I don't know why it is

quartz kindle
#

are you trying to save emojis?

distant plank
#

@quartz kindle no

quartz kindle
#

what are you trying to save then?

distant plank
#

@quartz kindle

undone rose
#

Perhaps they typed emojis then lol

#

\xF0\x9D\x90\x98\xF0\x9D

quartz kindle
#

@distant plank thats the key

#

what about the value

distant plank
#

but I have never saved what they write, that I remember

quartz kindle
#

keyv.set(key,value)

#

your key is "text"+message.author.id

#

what is your value?

distant plank
#

normally it's only true or false

quartz kindle
#

double check it then, because that error says its not

distant plank
#

or links

quartz kindle
#

what kind of links?

distant plank
#

images

earnest phoenix
#

and now i had to remove error messages from my clear command just to get it to work again

#

the error messages which told it that if it did not have an argument filled out

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

@distant plank the reason for the error is that the underlying database that keyv is using (keyv is not a database, its just an interface) does not support or is not configured to support certain characters, like multibyte characters

#

so you need to find exactly what characters are causing this error, can be an emoji, a character in a different language, or some weird character

#

and then report this error to the keyv developers

#

or check if the underlying database can be configured to accept multibyte characters

#

for example in an sql database, you would need to change the encoding from utf8 to utf8mb4 or something

distant plank
#

@quartz kindle I think it's because I have a function, that when you delete a message, save the deleted message so I can show it with a command. maybe they use emojis

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

or, if your situation accepts it, check your data and remove such characters from it before saving

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

@sage bobcat no, i dont use mongo

sage bobcat
#

One message removed from a suspended account.

distant plank
#

@sage bobcat only in that I use it

#

xD

#

@quartz kindle how can I delete the characters ?, or make them not appear in the database but if when it is obtained or something?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

distant plank
#

@sage bobcat snipe command :C

quartz kindle
#

a hacky way would be to check the length of each character

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

idk if it will work, never tested it

distant plank
#

I have another question :v

#

I have a code that is to detect spam, in Spanish

#

But it makes the bot slower, is there a way to simplify it or not more ping, giving the same result?

#
      var affectbotsenadis = await keyv.get(
        "spam" + "affectbots" + "enadis" + serverid
      );
      var delmsgenadis = await keyv.get(
        "spam" + "delmsg" + "enadis" + serverid
      );
      var getsupsafeenadis = await keyv.get("supsafe" + "enadis" + serverid);
      var getenadis = await keyv.get(
        "spamprotection" + "enadis" + channelid + serverid
      );
      let messagewom = message.content.toLowerCase();
      let messagewod = messagewom
        .normalize("NFD")
        .replace(
          /([^n\u0300-\u036f]|n(?!\u0303(?![\u0300-\u036f])))[\u0300-\u036f]+/gi,
          "$1"
        )
        .normalize();

      if (messagewod.includes("acaba") || message.content.includes("unio"))
        return;
      else if (messagewod.includes("unanse") && messagewod.includes("server"))
        avise();
      else if (messagewod.includes("unir") && messagewod.includes("server"))
        avise();
      else if (messagewod.includes("uniros") && messagewod.includes("server"))
        avise();
      else if (messagewod.includes("unios") && messagewod.includes("server"))
        avise();
      else if (messagewod.includes("unanse") && messagewod.includes("server"))
        avise();
      else if (messagewod.includes("unete") && messagewod.includes("server"))
        avise();
      else if (messagewod.includes("une") && messagewod.includes("server"))
        avise();
      else if (messagewod.includes("unanse") && messagewod.includes("servidor"))
        avise();
      else if (messagewod.includes("une") && messagewod.includes("servidor"))
        avise();
      else if (messagewod.includes("unir") && messagewod.includes("servidor"))
        avise();
      else if (messagewod.includes("uniros") && messagewod.includes("servidor"))
        avise();
      else if (messagewod.includes("unios") && messagewod.includes("servidor"))
        avise();
#
function avise() {
        if (affectbotsenadis == "false") {
          if (message.author.bot) return;
        }
        if (getsupsafeenadis == "true") {
          if (message.member.hasPermission("MANAGE_MESSAGES")) return;
        }
        if (getenadis == "disable") return;
        if (delmsgenadis == "true") {
          message.delete();
        } else {
          if(message){
          message.react("⚠");
            }
        }
        const embed = new Discord.RichEmbed()
          .setDescription(message.author + ", Cuidado con ese spam")
          .setColor("RED");
        message.channel.send(embed);
      }
quartz kindle
#

what makes it slow is keyv

#

you have several database queries for each message

#

thats very bad performance

distant plank
#

I know

#

I can do something?

quartz kindle
#

yes, dont use keyv everytime

#

use caching

distant plank
#

:o, how is that used

quartz kindle
#

get what you need from the database once, and save it into a variable

#

then use that variable everytime

distant plank
#

Is the variable always with the same text?

#

Doesn't it restart or something?

quartz kindle
#

what do you mean?

#

a variable will not lose its value unless you change it, or the process dies

distant plank
#

oh

rocky mesa
#

bruh

sudden geyser
#

oh god that codeblock

earnest phoenix
#

there was worse

blissful scaffold
#

when in doubt, add another else if

zinc condor
#

ok so im working on a rest image api similar to nekos.life but with more images, more endpoints and no registration required. thought i would post about it here since all my projects never take off :/

#

anyone interested in using it in their bot

#

im also writing a node wrapper

earnest phoenix
#

Is this an ad I smell

zinc condor
#

cant be an ad because its not even finished yet

earnest phoenix
#

selling knowledge

#

5 sheckles

sudden geyser
#

I will gladly buy knowledge.

zinc condor
#

if anyone has jojo's dvd's ill gladly pay 100 sheckles

sudden geyser
#

btw Riku can you DM me the api

zinc condor
#

its not up yet, im still working on it

sudden geyser
#

okay

zinc condor
#

right now the whole thing is mostly finished

#

im just collecting images

#

im at 16gb

lavish shuttle
#

@zinc condor what's it called?

zinc condor
lavish shuttle
#

Hm, maybe I can use it for my bot

#

@silk remnant

zinc condor
#

i like the logo XD

#

icon... profile... i dunno what to call it

#

its more logo like than anything tbh

valid frigate
#

beating an already popular service is ambitious and yeah id classify that as an ad

#

the problem with making things anonymous is you have to be prepared for anything

zinc condor
#

anonymous? wym

valid frigate
#

you mentioned no login/registration

#

that would mean anonymous

zinc condor
#

yep

valid frigate
#

also if it does take off are you ready to scale

#

you should look into creating file servers/clusters in that case

zinc condor
#

well i mean... i have a vps on google cloud and a cdn ready, the vps has max bandwith of 4000gb per month

sick cloud
#

so with my locale system it's all stored in a db, and i was wondering whether i should cache the data or not
if it is cached, it uses more memory, but it means the bot wouldn't be querying the db for every message
if it isn't, it's less memory but for every valid command message it'll be querying the database

to be clear, all it'll be caching is a map with sever_id => locale ie. 454409434676854786 => en_uk

valid frigate
#

tony, databases can handle thousands of i/o operations per second

zinc condor
#

if its 16gb of files i have that means i can take 250 users requesting every single image 250 times a month

valid frigate
#

if your bot is especially large id suggest just not querying unless your db is blocking

sick cloud
#

i have 20k servers vysion

valid frigate
#

LOL ok then uhhh

sick cloud
#

dunno how many are active but a fair bit

valid frigate
#

i honestly think it comes down to what you prefer

sick cloud
#

well my rewrite is supposed to cut down on memory usage and clutter

sudden geyser
#

cache sounds better imo

valid frigate
#

the tradeoff of memory usage vs db queries is not something in my control

#

then again more db queries could equal more memory usage

zinc condor
#

waIT i have cdn too so it can take 250 users and more due to the cdn caching the images

sick cloud
#

i use a really high-traffic db that handles loads REALLY well

#

but yeah

#

i'm not sure what's better, caching or querying constantly

valid frigate
#

if you choose caching, it's probably caching constantly

#

and vice versa

sick cloud
#

well i can explain the locale logic if it helps?

valid frigate
#

k

#

i assume you have a json/other language file

#

well in that case, if the locale doesn't change often definitely go for caching

sick cloud
#
on message:
    getLocale(server id)
        if cache has server_id
            return locale_id from cache
        if not
            query db for locale_id
                set cache as server_id:locale_Id
                return locale_id
#

the db just stores the locale id like en_uk

valid frigate
#

yeah that sounds reasonable

sick cloud
#

then i access the file ie. locales/en_uk.js

valid frigate
#

to be fair, if servers are not setting their locale often this would be a good choice

#

you know what they all say though, try it and see

sick cloud
#

it doesn't get changed much

valid frigate
#

if you're monitoring performance and see anything different then you know what's better ig

sick cloud
#

most people stay on en_us

valid frigate
#

hmm

sick cloud
#

also anything is better really, i currently somehow manage 10gb memory usage

valid frigate
#

what about if the server locale from the db is different than en_us

zinc condor
#

wait is there a tool to track how many times a certain api endpoint has been hit

sick cloud
#

@zinc condor pretty simple to track it

valid frigate
#

that would cut down on the amount you would have to save to memory greatly

sick cloud
#

on request: have a variable and +1 it

zinc condor
#

yeah i was gonna use statsd but thats extensive for something pretty simple

valid frigate
#

prometheus is a thing

sick cloud
#

yeah if it checks default, but i don't know the best way to implement it

valid frigate
#

hmmm

sick cloud
#

most people use en_us and some change it

valid frigate
#

i mean think about it this way

zinc condor
#

easy enough :/ ill set this up

valid frigate
#

if more people are using en_us but only some servers are changing their locale

sudden geyser
#

do you update it when the user changes locale

valid frigate
#

you would check for if the server's locale is not en_us

#

and if not, cache it

#

wait nvm

sick cloud
#

wait i have an idea

valid frigate
#

that would require a query every time LOL

sick cloud
#

based off that, i could check if the cache has the server, if not, i assume its en_us

#

if its in there i use that

valid frigate
#

big brain time

sick cloud
#

would save some errors too in case it doesn't save

#

i think that'd work

valid frigate
#

that would mean iterating over the cache

#

idk if that would cause more memory usage or not

sick cloud
#

it's just a map

valid frigate
#

oh a map

sick cloud
#

so map.has really

valid frigate
#

smh yeah

sick cloud
#

i think that'd be decent then

#

there's no "amazing" way to do it

#

i have to try not to butcher my db and i need to keep memory low

#

dunno how to reduce memory usage generally though

#

i set up a message sweep but idk

valid frigate
#

clustering

#

nah jk

#

in all seriousness i think you should go for caching judging on what you talked about

sick cloud
#

alright

zinc condor
#

is it bad that i have more nsfw than sfw on the api :/

#

more images and endpoints

sick cloud
#

probably

#

but who's judging

zinc condor
#

15 endpoints on nsfw

#

12 on sfw

sick cloud
#

honestly who, who cares

zinc condor
#

nobody

#

infact i forsee more people using nsfw stuff than sfw stuff

sick cloud
#

my api has more debug and error endpoints then my actual feature endpoints

zinc condor
#

oh and i have one endpoint that just sends jojo images and memes

#

AStbhfam OH SO YOU ARE APPROACHING ME

valid frigate
#

you mean an image manipulation api

zinc condor
#

no

#

its just jojo memes

valid frigate
#

lmao

zinc condor
#

:/

valid frigate
#

so static images

#

k

zinc condor
#

2 gigs of collected jojo static images

#

not even collected for the api

#

they were on my desktop

#

for like a year and a half

#

and i just kept adding to it

valid frigate
#

where do you see your api 1 year from now

#

large, with a collection of servers or dead

zinc condor
#

uhm..... yes

west spoke
#

nowhere for me

zinc condor
#

large i guess

valid frigate
#

imo id agree

zinc condor
#

im prepared for growth

#

and i cant exactly see the future

valid frigate
#

what have you done specifically

west spoke
#

I mean if nekos.life dies ima advertise my api

#

because yes

valid frigate
#

when making an api like this you needa prepare

sick cloud
#

nekos.life generally has a bad reputation now

#

on ksoft we deny bots for using it's nsfw endpoints

valid frigate
#

apis have their lifetimes unfortunately

west spoke
#

Yep

sick cloud
#

the idiots api died for example

sudden geyser
#

nekos.life is where I go to do my research

valid frigate
#

you may have heard of pomf & mixtape

west spoke
#

@sudden geyser oi bad

valid frigate
#

they died bc 4chan and copyright

sudden geyser
#

nah, not that research

zinc condor
#

well i have a vps with enough bandwith to have 250 people load every single image once and i setup a cdn so less bandwith is used

sudden geyser
#

imagine if I could become a cat girl

#

the power of the human body

valid frigate
#

can i have a source on that chief

zinc condor
#

what the hell does pomf have to do with 4chan?

#

thats a file uploader

valid frigate
#

bruh what you're making sounds like that

zinc condor
#

im making nekos.life but with MORE images

west spoke
#

@sudden geyser ah yes, wrong organic tissue types. It's nearly impossible for cat ears to be put on a human

valid frigate
#

lul ok ok

#

for real though

west spoke
#

lul sure

sudden geyser
#

You better watch what you say before I convert you to a cat girl

valid frigate
#

if it does gain popularity feel free to come back and get help with scaling

west spoke
#

nekos.life has around 100,000 images total

#

btw

valid frigate
#

this is true

#

can you beat 100k images

west spoke
#

@sudden geyser I'm already a catgirl

zinc condor
#

i have 8 thousand

sudden geyser
#

owo

zinc condor
#

and i doubt they have that much

#

well ok what im having as a "feature" is an endpoint request area for people to request endpoints to be added, they can also attach images which helps their chances of the endpoint being added

west spoke
#

sounds a bit overcomplicated but ok

sudden geyser
#

Like I could suggest a catboy endpoint along with an example image?

zinc condor
#

yeah

#

you could also attach a zip

#

which is thrown into the endpoint

#

so people can add their own images to endpoints after review

sudden geyser
#

Sounds a bit over complicated for just an endpoint. How about having a form on the main page and allowing devs to suggest endpoints like that?

#

or just both

valid frigate
#

also fetch the list of endpoints and list them on the main site so people know what exists and what doesnt

zinc condor
#

yeah im doing that

valid frigate
#

along with their statuses like pending, active, removed, etc

zinc condor
#

yeah

#

when you go to the api url it shows you all the stuff aswell

#

i removed the img because lewd stuff is on there :/

earnest phoenix
#

Uh need help i even tried to make the brief description shorter and it still didn't work, if anyone can help me please dm and explain how i can fix this. I would appreciate it

hoary elm
#

@earnest phoenix for brief description just put a intro to your bot Example: A basic Moderation & Support bot coded in Blah Blah Blah

#

Should work

zinc condor
#

you just exposed your bot client id

slender thistle
#

Who honestly cares

undone rose
#

lmao

#

462828548080664577 @zinc condor

zinc condor
#

xd

undone rose
#

👻

tight mountain
#

Sometimes my bot just says [object Object] [object Object] when I do any command. What could it be?

#

only sometimes though

zinc condor
#

change your bots avatar to this

#

it might fix it

tight mountain
#

no

zinc condor
#

lul you didnt get the joke

tight mountain
#

i get this too many times

zinc condor
tight mountain
#

oh wow it worked thank you so much riku

zinc condor
#

no problem :3

delicate saddle
#

hug, kiss, hit are NSFW commands? No. Why did you reject my bot?

coral trellis
#

It mentions NSFW in the description

delicate saddle
#

I said it contains NSFW commands. What's wrong with that?

earnest phoenix
#

Read rules.

delicate saddle
#

I will have to. Thanks for the answer dblWink

distant plank
#

Does using command handler help decrease bot ping?

earnest phoenix
#

it can

lunar crystal
earnest phoenix
#
message.member.voiceChannel.join().then(function(connection) {
})
#

@lunar crystal

dull ember
#

probably stupid question but is there still a way to detect when someone has voted without webhooks

#

cos when i use the example on the dblapi.js docs it logs this

Webhook running at http://0.0.0.0:3000/dblwebhook
#

or is that normal

quartz kindle
#

Yes its normal

#

Then you need to paste that url in your bots edit page webhook address in the website, but replace 0.0.0.0 with your servers external ip address or your project url if using glitch/heroku/etc

dull ember
#

does using express effect it

#

affect*

earnest phoenix
#

if its running ont he same port yea

#

if you have a webhook running on a port nothing else is on

#

should be fine

dull ember
#

alright thanks

cerulean salmon
#

is it possible to get the message when someone response the bot's in DM ?

green kestrel
sudden geyser
#

If you're shooting yourself over C++, you should take a look at JS before it was tolerable.

quartz kindle
#

To shoot your foot in js you need to shoot every single dependency your foot was built with

#

betterToenail.js

green kestrel
#

you go to shoot yourself in the foot

#

first you have to import 30 node dependencies

#

one for bullet metal, one for bullet explosive, one for bullet casing, one for trigger... etc

#

then before you go to fire, you get stuck in an endless loop of dependency updates as one of them has a vulnerability and a fix available

#

😄

quartz kindle
#

You import gun.js

#

Gun.js imports bullet.js

green kestrel
#

yeah

#

😄

quartz kindle
#

Bullet.js imports gunpower.js

#

Gunpowder.js imports betterPhysicsEngine.js

green kestrel
#

@sudden geyser begs the question, when did JS become tolerable, or are you all using it because its the most supported language? 🙂

#

theres a reason im using C++ lol

quartz kindle
#

Js was largely abandoned for like a decade

#

Until about 2009

sudden geyser
#
  • emc5 or emc6 too
green kestrel
#

at one point, js was just microsofts 'extend, embrace, extinguish' tool for stomping out netscape

#

i think if there wasnt firefox and chrome, it might have stayed that way and js may have been a forgotten dead language

quartz kindle
#

Yeah i think google's V8 engine is one of the reasons why js was revived

green kestrel
#

im still no fan of untyped languages, though

#

although iirc newer js does help a lot with regard to that

quartz kindle
#

Im used to it, so for me its weird to use typed langs

green kestrel
#

i originally wrote the discord part of my bot in php

#

if you think js is bad, try that 🙂 especially with an abandoned lib

quartz kindle
#

No thx lul

#

Does php even support websockets?

green kestrel
#

of course, but like most languages, not natively

quartz kindle
#

Ya

#

I remember restcord was a discord lib for php

green kestrel
#

you hafve to use a symfony lib on top of guzzle

quartz kindle
#

Bur rest only

#

No websockets

green kestrel
#

in C++ you use ASIO and websocketpp, or uwebsockets

sudden geyser
quartz kindle
#

LOL

green kestrel
#

lol

#

if discordphp was on that list, it can do most of those things

#

but, its abandoned

#

it took serious work just to make it stable

#

wheres that table please?

#

i want to see if the lib im using now is on it

#

and nope it isnt, no C++ ones

#

who do i speak to, to get extra libraries added there? i can name two you dont have that are in active development, and another thats dead

quartz kindle
#

Ask in the discordapi forums or something idk

#

Or maybe they have a github for that page

#

Like they do for docs

green kestrel
#

yes

#

it is, but they archived the /unofficial

sudden geyser
green kestrel
#

it looks like they'd reverse engineered api docs before discord officially made it public

#

now its public, theyve taken down their docs and redirected the address

#

however archive.org still has their old docs if anyones interested, they seem interesting 🙂

quartz kindle
#

Did people reverse enginner discords own client to start developing bots?

#

Then discord said fuck it, and made bots official?

#

Not surprising, if thats how it went

frank wyvern
#

Anyone know how to get server creation date using discord.py?

earnest phoenix
#

use the appropriately named property

west spoke
#

str(ctx.guild.created_at)

#

@frank wyvern

raven torrent
#

👀

zinc condor
#

Php is a joke now

earnest phoenix
#

php's always been a joke

glacial mango
#

Does anyone know how to get the 27s, aka the time the song has been played?

earnest phoenix
#

sure do

#

but you have to realize not everyone knows what you're using

glacial mango
#

I'm dumb, how do I see that?

lunar crystal
#

@earnest phoenix thank u 😄

earnest phoenix
#

np

#

@lunar crystal u tried what i say ?

grim aspen
#

connection is not defined like it says

earnest phoenix
#

your bot failed to join the voice channel

lunar crystal
#

Sorry I give u the wrong one 😬

earnest phoenix
#

hence why the connection is undefined

#

Lol

#

😂

lunar crystal
earnest phoenix
#

well... yeah

#

you don't define the connection anywhere

#

of course it's going to complain

raven torrent
#

C'est un peu dégueulasse @lunar crystal

#

"Je suis prêt à caresser des gens"

#

C'est genre chelou de fou

earnest phoenix
#

This is outside from function thats why its not defined connection

mossy vine
#

@earnest phoenix do you have any sources for that image above

earnest phoenix
#

as in...?

earnest phoenix
#

It's funny either way xd

mossy vine
#

it is

earnest phoenix
#

those are his tweets

lunar pewter
#

e

#

wait wrong channel my pc is laggy

mossy vine
#

yeah but i meant links to the tweets lol

earnest phoenix
#

idk those

#

but they're old

#

one of his quotes

#

on his old blog

meager belfry
#

can i ask here for discord aouth2 support or it isn't allowed?

modest maple
#

whats the issue with it? xD

slender thistle
#

Well that would fit this channel k3llyShrug

modest maple
#

^

meager belfry
#

i can't get the access token with curl

modest maple
#

xD

#

why do you need aouth2 anyway?

meager belfry
#

dashboard

slender thistle
#

Are you sending the client secret

meager belfry
#

i did it some time ago but now it doesn't work lol

#

yes

#

i can't get a good response even trying a request with postman

#

it says invalid client but everything is ok lol

modest maple
#

since when did you need to have OAuth2 enabled to use dashboard?

#

confused me now

slender thistle
#

User's login system

meager belfry
#

yes

mossy vine
#

to make a dashboard you usually want to authenticate the user

meager belfry
#

you need oauth2 to login

#

always

#

the thing is i did it some time ago without any issue but now it doesn't work

#

i also tried some examples from github and same happens

mossy vine
#

you could just use an otp but thats not very user friendly
anyways just make sure you are providing the right id and secret

meager belfry
#

i checked it like 5 times

#

i regenerated another secret key

#

and same

modest maple
#

Is your token valid?

meager belfry
#

it should

#

well where i'm stuck is getting the authorization token

#

this makes no sense for me (i will regenerate the secret code so np about the pic)

#

as you can see in the screenshot client id and client secret are both the same

modest maple
#

bruh

#

that ss is impossible to read xD

meager belfry
#

open it with browser

#

and zoom in

slender thistle
meager belfry
#

yes

#

that's exactly what i'm doing

#

i got the code from /authorize

#

then i'm doing exactly what it says with /token

#

but the response is an error

slender thistle
#

shrug

meager belfry
#

f

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

mossy vine
#

if you want to do it like that, yes

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

as long as you provide a valid string to the function, yeah

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

its just args[0] if you dont count setavatar as an arg

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

it doesnt have any spaces

#

so if you split arguments at spaces, its 1 argument

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

args.join[0] makes no sense

#

join is a function

#

args.join(' ') if you want to join them with spaces

#

but you are providing a link anyways

#

why join??

slender thistle
#

Can't you just split the message content and then get the second item from the array

mossy vine
#

thats what args are

slender thistle
#

What is .join for, then special_think

mossy vine
#

i was wondering that too

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

first element of the array

slender thistle
#

That would give you the command name

mossy vine
#

if you dont remove the command from the argument array first

#

depends on your command handler/parser

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

args[1] then

late hill
#

0 ?!

undone rose
#

I recommend you learn js before asking questions here

#

join[0] makes no sense and you, the person who coded it, should know what args[0] means

#

@sage bobcat

#

Learning Javascript will be whats going to be most helpful to you

#

You wont get anywhere you want to be by following a guidebot tutorial

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender thistle
#

Some noroles have proven themselves to be smarter and/or more mature than 80% of this server
Just because they don't have any roles does not mean you are free to disregard all of their words

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

zinc condor
#

after calculating some things

#

im gonna use google cloud platform for the storage for images

#

on my api

valid frigate
#

ol ive been using gcs for years

zinc condor
#

yeah

#

what worries me is 20 bucks is for 1000 gb out

#

while my vps itself has a 3tb bandwith limit

#

i dunno if i should use google or just use my vps to host the files

#

wait my bandwith overage limit after 3tb is 0.01$ per gig after 3tb

#

i think im ok for now but if this thing grows ima have to switch to google

proud valley
#

twitch legendarystars

loud salmon
#

@proud valley what?

valid frigate
#

he's advertising

loud salmon
#

worst advertising I've seen

zinc condor
short siren
#

hi

zinc condor
#

hi

earnest phoenix
#

Is there a reference documentation to better unerstand discord api other than its orginal api page

raven torrent
#

the original api of discord?

earnest phoenix
#

Yes

raven torrent
#

well, it's explained pretty good on discord's api webpage

frozen cedar
#

Wait what are the discordapi endpoints? I've never actually been able to find them.

undone rose
#

@sage bobcat im a whitename who's been a developer longer than u, I was cert dev and web mod here. I can tell you to learn Javascript because you lack the knowledge of basic array functions. You also say your repository is Typescript but there isnt a single ts file in your repository.

I wouldnt be so quick to deflect your criticism with "whitename" as if me having a white name doesnt mean im a dev.

Im simply telling you that itd be more beneficial for you to gain a base of knowledge in the language you are trying to use before you attempt to seek help in a subject area you dont understand. I tell you to learn js first because once you know things like basic array functions your abilities will grow tenfold and you can spend less time explaining your issue in a dev chat, and more time actually creating features

sage bobcat
#

One message removed from a suspended account.

undone rose
#

Understandable

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender thistle
#

imo you should discuss this in DMs guys

undone rose
#

I don't think you dont know anything, Im just saying that args is something that you defined so you above anybody should know how this works. And not knowing basic array functions tells me that you probably copypasted your args variable. Im not trying to discourage you im literally just saying that you should try to learn everything you can about the language so youre not wasting time asking devs to help you, and you can instead spend that time actually developing your features. I didn't intend to offend you if that's how you took it. Don't get so easily offended, and don't try to deflect all criticism with poor excuses like not using variables that you defined using array methods that you do not understand. Once you learn more about the language, your eyes will be opened to much more and you wont normally have problems like this in the future!

valid frigate
#

why do you bring up this unnecessary drama

#

just tell him to study array concepts

sage bobcat
#

One message removed from a suspended account.

undone rose
#

I did but then he wrote me off as "uh dumb whitename telling me to learn js i already know js" when he clearly does not know. Im just saying, when you talk in this chat, it is nobody's responsibility to baby you or explain basic concepts. When you ask for help here, expect constructive criticism

earnest phoenix
#

Chill tanner lol

undone rose
#

And in this case the constructive criticism is to learn array methods so you wont have problems with these types of issues

short forge
#
root@debian-s-1vcpu-1gb-lon1-01:~/Sublime# npm install sqlite3

> sqlite3@4.1.0 install /root/Sublime/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

sh: 1: node-pre-gyp: not found
npm WARN discord.js@11.5.1 requires a peer of @discordjs/uws@^10.149.0 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js-commando@0.10.0 requires a peer of sqlite@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN sublime@0.0.1 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! sqlite3@4.1.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the sqlite3@4.1.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-11-04T19_11_29_750Z-debug.log
root@debian-s-1vcpu-1gb-lon1-01:~/Sublime# ```

Getting this error whenever running `npm install sqlite3` (or any package for that matter)
I can't install any packages.
mossy vine
#

sh: 1: node-pre-gyp: not found

#

npm i node-pre-gyp --global should solve that

short forge
#

thanks!

#

Now i'm getting an even more confusing error when running node .

root@debian-s-1vcpu-1gb-lon1-01:~/Sublime# node .
sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules/discord-leveling/node_modules/sequelize/lib/sequelize.js:245:13
═[Discord-Leveling Database Loaded -V1.1.0]═[Support server: https://discord.g/3456346]=
FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
 1: 0x9d33e0 node::Abort() [node]
 2: 0x9d4596 node::OnFatalError(char const*, char const*) [node]
 3: 0xb32b8a v8::Utils::ReportApiFailure(char const*, char const*) [node]
 4: 0x7fa4602aef69 Require(v8::Local<v8::Object>, char const*) [/root/Sublime/node_modules/better-sqlite3/build/better_sqlite3.node]
 5: 0x7fa4602afe8e Integer::Init(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Object>) [/root/Sublime/node_modules/better-sqlite3/build/better_sqlite3.node]
 6: 0x7fa4602b2348 RegisterModule(v8::Local<v8::Object>, v8::Local<v8::Object>) [/root/Sublime/node_modules/better-sqlite3/build/better_sqlite3.node]
 7: 0x9affd7  [node]
 8: 0x9af1f2 node::binding::DLOpen(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 9: 0xb9ec19  [node]
10: 0xba0a07 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
11: 0x136d639  [node]
Aborted```
amber fractal
#

Love me some better-sqlite3 errors

#

What node version do you have

short forge
#

v12.11.1

amber fractal
#

Does your projects root folder have a package.json or no

short forge
#

it does

amber fractal
#

Can you send it?

short forge
#

sure

#
{
  "name": "sublime",
  "version": "0.0.1",
  "description": "The next generation of Discord Bots.",
  "main": "index.js",
  "scripts": {
    "run": "node index.js"
  },
  "keywords": [
    "bot",
    "discord",
    "sublime"
  ],
  "author": "Croft",
  "license": "ISC",
  "dependencies": {
    "@sentry/node": "^5.7.0",
    "better-sqlite3": "^5.4.3",
    "canvas": "^2.6.0",
    "configcat-node": "^2.2.1",
    "dblapi.js": "^2.3.0",
    "discord-anti-spam": "^2.0.2",
    "discord-economy": "^1.1.6",
    "discord-leveling": "^1.1.0",
    "discord.js": "^11.5.1",
    "discord.js-commando": "^0.10.0",
    "nekos.life": "^2.0.4",
    "node-fetch": "^2.6.0",
    "quick.db": "^7.0.0-b22",
    "sequelize": "^5.21.0",
    "sqlite": "^3.0.3",
    "sqlite3": "^4.1.0",
    "weather-js": "^2.0.0"
  }
}
amber fractal
quartz kindle
#

Why do you have sequelize and quick.db and 2 different sqlites?

#

3 different sqlites

#

Lmao

earnest phoenix
#

lol

wintry wing
#

So apparently theres an issue with my bot as when it doesn't have a managed role, and when the bot checks for permissions (and it has the required permissions but doesn't believe it does apparently) it shows an error, is there a solution for this?
Code Example im using is below: (discord.js)

if (!msg.guild.member(bot.user).hasPermission(["MANAGE_ROLES", "MANAGE_CHANNELS"])) return msg.reply("**I do not have perms!**")
earnest phoenix
#

you could use <message>.guild.me instead of <message>.guild.member(<client>.user) because the first represents your bot in the guild as a member already

#

and you say it has an error but you never posted the error

distant plank
#

@quartz kindle Regarding what you told me yesterday about storing the cache, I don't know how I can do it for all the servers that the bot is. since if I use only the variable I get as undefined

var affectbots;
var delspammessage;
var supsafe;
#
  let serverid = message.guild.id;
  affectbots = await keyv.get("affectbots" + "enadis" + serverid);
  delspammessage = await keyv.get("spam" + "delmsg" + "enadis" + serverid);
  supsafe = await keyv.get("supsafe" + "enadis" + serverid);
#
  client.commands.get("spam").execute(message, keyv, affectbots, supsafe, delspammessage);
shadow dust
#

Hey, using d.js is there a way to iterate through all clients created by sharding before the ready event is fired?

quartz kindle
#
Let cache = {}

client.on(message, message => {
    let guildcache = cache[message.guild.id]
    If(!guildcache) {
        guildcache = cache[message.guild.id] = {}
    }
    let affectbots = guildcache.affectbots
    if(!affectbots) {
        affectbots = guildcache.affectbots = await keyv(...)
    }
})
#

Basic caching scheme

distant plank
#

o

quartz kindle
#

If cahe doesnt exist, load from keyv and save in the cache

distant plank
#

thanks!

quartz kindle
#

Subsequent requests will be loaded from cache

wintry wing
#

@earnest phoenix I'm saying it's an error because apparently a mod is saying it doesn't have permissions even though it does, but when it has its managed role and has the permissions there, it wont say that

late hill
#

That's very difficult to understand

earnest phoenix
late hill
#

Where does it say that it's missing permissions

#

The bot's message you coded or in your console pepesuspicion

#

Because manage channels can be overwritten per channel

#

maYbe

wintry wing
#

@late hill The bot message I coded, and ask the moderator who rejected my bot because im not sure

late hill
#

oh

sudden geyser
#

maybe permissions are being checked by channel?

#

your message checks the overall guild permission

distant plank
#

@quartz kindle ```JS
guildcache = cache[message.guild.id]
if (!guildcache) {
guildcache = cache[message.guild.id] = {}
}
affectbots = guildcache.affectbots
if (!affectbots) {
affectbots = guildcache.affectbots = await keyv.get("affectbots" + "enadis" + serverid)
}
delspammessage = guildcache.delspammessage
if (!delspammessage) {
delspammessage = guildcache.delspammessage = await keyv.get("spam" + "delmsg" + "enadis" + serverid)
}
supsafe = guildcache.supsafe
if (!supsafe) {
supsafe = guildcache.supsafe = await keyv.get("supsafe" + "enadis" + serverid)
}

#

I had never used anything like that

quartz kindle
#

Yes, but dont use global variables

#

Unless you defined those before

#

And yes, you can set a value to multiple variables at once like that

#

a = b = 5

#

Both a and b will be 5

distant plank
#

@quartz kindle Do I have to use that code for every time I use it?

frozen cedar
#

@quartz kindle your so wholesome

#

you help all the kiddos of the next generation learn to code

#

You get a gold star!

mossy vine
#

tim is the peak of this channel

frozen cedar
#

Yes

#

Tim = best coder

humble pendant
#

^^ true ^^

frozen cedar
#

give Tim an award or we will have an uprising

scenic kelp
#

Yeah Tim is honestly a legend tho

quartz kindle
#

Lol

scenic kelp
#

Like i'd legit donate if i had money

humble pendant
#

same

frozen cedar
#

Yeah too bad we all broke from paying for vpss so people can take advantage of our work

humble pendant
#

lol

distant plank
#

@quartz kindle why does undefined return me?

#

:'''''c

quartz kindle
#

Where?

forest trench
#

Hello 👋

#

Does somone have a discord bot writed with discord.js with more than 2500 serveurs (shards) ?

distant plank
#

@quartz kindle affectbots = undefined

quartz kindle
#

Did you change them to local variables?

frozen cedar
#

How can I check if a user has a role?

#

userVariable.roles.find(roleVariable)?

west raptor
#

Member#roles#has

frozen cedar
#

got it

#

[ 
   { 
      "Name":"The NERVA Association",
      "Id":5246058,
      "EmblemUrl":"http://www.roblox.com/asset/?id=4240795913",
      "EmblemId":4240795913,
      "Rank":255,
      "Role":"Holder",
      "IsPrimary":false,
      "IsInClan":false
   },
   { 
      "Name":"State of Firestone",
      "Id":2803360,
      "EmblemUrl":"http://www.roblox.com/asset/?id=4265490349",
      "EmblemId":4265490349,
      "Rank":20,
      "Role":"Middle Class Citizen",
      "IsPrimary":true,
      "IsInClan":false
   },
   { 
      "Name":"Περίοικος",
      "Id":4625738,
      "EmblemUrl":"http://www.roblox.com/asset/?id=2719690491",
      "EmblemId":2719690491,
      "Rank":10,
      "Role":"Perioikoi Metioikoi",
      "IsPrimary":false,
      "IsInClan":false
   },
   { 
      "Name":"Greek City-State of Lakedaimon",
      "Id":2939482,
      "EmblemUrl":"http://www.roblox.com/asset/?id=2160193304",
      "EmblemId":2160193304,
      "Rank":40,
      "Role":"Perioikoi",
      "IsPrimary":false,
      "IsInClan":false
   }
]```
How would I sort through to find which of these has the ID I want?
valid frigate
#

array.find()

frozen cedar
#

sic

#

thx

valid frigate
#

np

distant plank
#

@quartz kindle what?

frozen cedar
#
                        console.log("b")

                        try {

                        message.member.removeRoles(element.drolesetID)


                    
                        }catch(error) {

                    }
                    } else { 
                        const result = binds.filter(id => id.groupID == element1.Id);
                        console.log("b")
                        if(result.length < 1) {
                                    
                            message.member.removeRoles(element.drolesetID)

                             
                            }
                          
                    }```
#

the second else statement is being triggered

#

and it gets in the if statement

#

but doesnt remove the role

#

idk why

modest maple
#

result.length ! < 1 i Guess

frozen cedar
#

Ah wait, I got it

zinc condor
#

i finished my api :/

distant plank
#

@zinc condor good

zinc condor
#

:3

sudden geyser
#

Lemme check it out HyperAI

zinc condor
#

ye

frozen cedar
#

@zinc condor cool api :))

zinc condor
#

thank:3

frozen cedar
#

:333

zinc condor
#

sorry it was down for a sec

#

i was adding cors stuff

#

since sum stuff was not working cuz of that

wintry wing
#

@sudden geyser as ive explained before I don't know what channel permissions that the moderator used had

sudden geyser
#

I know, but that could have been the reason.

#

It's also good to check by channel permission in general

wintry wing
#

If that could've been the reason, then why did the moderator reject my bot for the "bug"?

sudden geyser
#

for the reason you've been talking about (invalid permission). It's just a guess ¯_(ツ)_/¯

steel cloak
#

in discord.js: i was wondering if anyone knew how to fix this
DiscordAPIError: Missing Permissions
the permissions its saying it doesn't have is 'manage nicknames' but i made sure and it has that permission. i feel like i get this a lot for no particular reason

earnest phoenix
#

because it's role is not higher than the end member's role

#

or it just doesn't have the permission to do that

#

discord doesn't lie

steel cloak
#

oh i wasn't aware it wouldn't work if the end members role is higher then the bots. Is there any work around without moving the levels of roles

earnest phoenix
#

Is there a way I can set "varName3" to another variable? I would like to give the embed message a randomly generated ID number

{
      "storage": "1",
      "varName": "embedToSend",
      "channel": "0",
      "varName2": "",
      "storage3": "2",
      "varName3": "${tempVars(\"embedIdNum\")}",
      "iffalse": "0",
      "iffalseVal": "",
      "name": "Send Embed Message"
    }
#

(I don't know why the spacing is weird)

sudden geyser
#

Just assign it?

earnest phoenix
#

I want to make it a pre-generated random number. I don't know how to make "varName3" a custom variable.

tight mountain
#

Im working on a weather command. When I send the command, it sends the message. When I send it again, it sends it twice. When I send it again, it sends three times. Here is my code: ``` if (message.content.startsWith(prefix + "weather")) {

let zipCode = message.content.split("r ")[1];

if (zipCode === undefined || zipCode.length != 5 ||  parseInt(zipCode) === NaN) {
  message.channel.send("Please provide a valid ZIP code! Note: this only works for the U.S.A.")
  .catch(console.error)
  return;
} else {
fetch(`http://api.openweathermap.org/data/2.5/weather?zip=${zipCode},us&APPID=no`)
  .then(response => {
    return response.json()
  })
  .then(parsedWeather => {

    const weatherPics = {
      "Clouds": `https://i.imgur.com/UbS3wXO.gif`,
      "Rain": `https://i.imgur.com/RU8iwIE.gif`,
      "Thunderstorm": `https://i.imgur.com/MH7QnT8.gif`,
      "Sunny": `https://i.imgur.com/qTO6lBE.gif`,
      "Clear": `https://i.imgur.com/ZNVcoap.gif`
    }

    if (parsedWeather.cod === '404') {
      message.channel.send("This ZIP code either doesn't exist or there is no information avaliable for it!")
    } else {
      const currentWeather = parsedWeather.weather[0].main

      message.channel.send({embed: {
          color: 3447003,
          fields: [{
              name: `Location: ${parsedWeather.name}, ${parsedWeather.sys.country}`,
              value: `
                It is ${(Math.round(((parsedWeather.main.temp - 273.15) * 9/5 + 32 )))}° F with ${parsedWeather.weather[0].description}!
              `
            }
          ],
          image: {
               url: `${weatherPics[currentWeather]}`,
          },
          timestamp: new Date()
        }
      })
    }
  })
}

}
});```

zinc condor
#

for my api i smashed together this thingy

#

just as an image explorer

#

its basically just a modified simplified html thingy i found on github but it works

valid frigate
#

do you need help with development or

#

is this just advertising

earnest phoenix
#

It's just advertising

earnest phoenix
#

Is there any way I can turn "varName3" into a pre-defined number?

{
      "storage": "1",
      "varName": "embedToSend",
      "channel": "0",
      "varName2": "",
      "storage3": "2",
      "varName3": "Can I get a pre-defined variable here?",
      "iffalse": "0",
      "iffalseVal": "",
      "name": "Send Embed Message"
    }
heavy spade
#

Client.once('message', async message => {
    db.add(`globalMessage_${message.author.id}`, 1);
    db.add(`guildMessages_${message.guild.id}_${message.author.id}`, 1);
})

else if (command === 'messages') {
                exports.run = async (client, message, args, tools) => {
                let member = message.mentions.member.first() || message.member;
                let global = await db.fetch(`globalMessages_${member.id}`);
                let guild = await db.fetch(`guildMessages_${member.guild.id}_${member.id}`);
                message.channel.send(`**Global Messages: \`${global}\`\nguild Messages: \`${guild}\`**`)
                }
        }
#

it wont work for some reason

#

says first is not defined and client, message, args, tools even though 300 lines up i use them and they are defined

distant plank
#

@quartz kindle I already corrected the problem, thanks for helping me

#

The ping of my bot is no longer high

heavy spade
#

help anyone?

cerulean salmon
heavy spade
#

Yes

#

Have they changed it you use to be able to use first

raven torrent
#

@cerulean salmon Everything is explained in the error it self

#

cmd.mentions.members is null

#

So it cannot read the first property

cerulean salmon
#

cmd.mentions.members != null

#

its shows same error

raven torrent
#

Because cmd.mentions.members is null

#

So the statement is actually useless in your case

#

Since it's null

cerulean salmon
#

discord.js

raven torrent
#

why do you check for mentioned members in a command

#

Can't you put in discord.js arguments for the commands

cerulean salmon
#

i am trying to do something like this

when someone will mention the bot ,then bot will reply some particular sentence
its working fine

problem is when i bot try to get the response from user in DM

raven torrent
#

Then check if the guild is not none?

#

I never used disc.js, but I think this should be possible

cerulean salmon
raven torrent
#

wait

#

that's normal

#

Shouldn't you replace the && by an or or something similar

#

wait nvm

cerulean salmon
#

then bot will send every single message to the channel

raven torrent
#

Also, shouldn't you put

#

message.channel.type === dm

#

or

#

message.channel instanceof DMChannel

cerulean salmon
#

if i disable that mention and reply option
i can grab bots dm messages fine or vice-versa
but can't run them together

raven torrent
#

The thing is that the error you sent above is no where in the code you sent

#

So it's just impossible to help

cerulean salmon
#

🤦

#

Thanks for all the help I do appreciate it really much

raven torrent
#

On the error you sent above it's:
else if (cmd.mentions.members.first() != undefined) {

#

And on the screenshot

#

there is no where a code like that

#

am I right?

manic basalt
#

i cant find a solution for this (discord.py, python)

json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)
raven torrent
#

well

#

It should be " and not '

manic basalt
#

what do you mean actual data

#

its a array and has data in it

heavy spade
#

Make the array then see

raven torrent
#

As it's a string

#

You need to put

#

"

heavy spade
#

Is no one going to help me with my .first command

raven torrent
#

instead of '

heavy spade
#

For message counter

manic basalt
#

that doesnt change anything

heavy spade
#

It won’t change anything

raven torrent
#

It does

heavy spade
#

Do you just have import json because that’s all I see

raven torrent
#

JSON is "

manic basalt
#
[':staff:']

this doesnt seem like a correct output

#

wtf

#

why is discord doing that

raven torrent
#

It's not discord

manic basalt
raven torrent
#

It's your code

#

Not the same

manic basalt
#

no its changing the text in the codeblock

raven torrent
#

Dude

#

Get some IQ @heavy spade

heavy spade
#

Ik

raven torrent
#

That's not python

#

omg

heavy spade
#

This is python I am JavaScript

raven torrent
#

Yea then

#

Don't help with js code

#

Won't help him at all

#

@manic basalt As stated many times on internet

#

this error happens when;

#
  • non-JSON conforming quoting
  • XML/HTML output (that is, a string starting with <), or
  • incompatible character encoding
bronze bramble
#

Guys

#

Traceback (most recent call last): File "lesterisawesome.py", line 9, in <module> for option in open('config', 'rt').read().split('\n'): FileNotFoundError: [Errno 2] No such file or directory: 'config'

slender thistle
#

There was no file "config" in the working directory

raven torrent
#

The error explains everything

green kestrel
#

if i made a generic program that can post statistics to various bot list apis like the one for this site, so you just run it from the commandline with a site name, bot id, api token and couters and it knows what to do, is that something people would use?

valid frigate
#

lol imagine it this way

#

when a method already exists and its been used for years

#

you would need traction in your project

valid frigate
#
  • people normally dont post their server count and adding an additional step is 2 lazy 4 some
green kestrel
#

they might, if this is easy to do.

valid frigate
#

why is a db involved lolw

green kestrel
#

the way ive created this was for my bot, so i only have to write the code once and its compatible with all these services out there that just take a json post to a https endpoint, the only variance is in field names

#

@valid frigate two reasons, it centralises reporting so that each shard isnt responsible for having to report the counters, and secondly a db is used by my bot anyway

#

so it made no difference for me to put an extra couple of tables in that db

valid frigate
#

in most libs shards arent responsible

#

you use upper level management to report that

#

if you're reporting per shard you're doing something wrong

green kestrel
#

i'd originally inteded each shard to be responsible to report to a db cluster, that way the failure of one shard didnt affect the others, with shards on separate machines

#

but ive thrown out that idea as the lib i use now uses the model you described

#

the db remains though, as the rest of the bot uses a db to store 1.4 million facts for chatbot use

valid frigate
#

mk might as well make it a bot stats reporter

#

you would have to support a lot more than just 1 language, aka supporting djs and eris

green kestrel
#

the most practical way to do this would be to have the program background itself... so you run it once on boot, and it just looks for the values of some env vars or something

valid frigate
#

the great majority of bots here are like that

green kestrel
#

that way you dont need to directly support a language

#

just say 'set these env vars with your stats from within your bot'

#

env vars might not be the best solution though

#

its not as smart on windows etc

valid frigate
#

so how would this be run on linux

#

additionally requiring a tool such as screen which most new bot devs are unfamiliar with

#

or run as a background process

green kestrel
valid frigate
#

i didnt ask for that

green kestrel
#

i only run on linux

#

i said windows might be the problem

valid frigate
#

cross-platform shouldnt be too different

#

except for some libs that only work on linux

green kestrel
#

forking a background process isnt difficult, i can do that on any platform

#

doesnt need screen

valid frigate
#

more like spawning

green kestrel
#

i do use screen to run my bot core, but thats not related to this idea

#

thats just because i was too lazy to background it, and wanted to watch the debug log 😄

valid frigate
#

what

#

so what did you even ask help for

green kestrel
#

tbh, im not sure i'd leep the reporter bit in php, if i was going to make it available for others

#

perhaps a C++ project, with a prebuilt windows exe for the unable to compile

valid frigate
#

you're literally talking to yourself right now

#

what do you want help with

green kestrel
#

im asking for feedback on the idea, @valid frigate not help per se

valid frigate
#

k

#

well for experienced devs sure

#

otherwise, it's gonna be too confusing for newbies unless you actually give a solid tutorial on how to use it

buoyant osprey
#

how many characters are allowed in a embed field value

slender thistle
#

1024

raven torrent
#

Any ideas why when I try to get my bot informations with my bot I always get {'error': 'Unauthorized'}

(with the API)

#

HTTP Error 401: Unauthorized

earnest phoenix
#

wrong token

raven torrent
#

Do you even need the token for a GET request?

#

well

#

yea

#

you do need

#

lmao

#

thanks

earnest phoenix
#

Do you even need the token for a GET request?
you need a token for every request christmasthink

split hazel
#

How do you remove a specific event listener from discord.js?

#

for example remove client.on("message", niceevent)

wheat jolt
#

Just don't use it

split hazel
#

great thanks for the amazing answer

quartz kindle
#

@split hazel you can remove it from client._events

#

Its an array of arrays of functions iirc

fallow spire
#

Can you get Guilds by Their Name?

modest maple
#

Yes

fallow spire
#

so? bot.guilds.get(args[0]

#

@modest maple

mossy vine
#

no

#

they are mapped by their ids

modest maple
#

Nvm then xD

fallow spire
#

Then whats right?

mossy vine
#

what are you trying to do anyways?

fallow spire
#

Backdoor Command (Owner Only of cause)

mossy vine
#

thats a huuuge breach of privacy

grim aspen
#

backdoor?

fallow spire
#

really? @mossy vine

grim aspen
#

sounds like criminal stuff but ok

modest maple
#

That is a MASSIVE breach of privacy yes

mossy vine
#

yes, we are talking about a literal backdoor to a server