#development

1 messages · Page 682 of 1

outer niche
#

Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), main.dict) File "<string>", line 4, in <module> ModuleNotFoundError: No module named 'youtube_dl' [Program finished]

#

What do I need to do

lusty dew
#

Kek

#

Read the error

outer niche
#

I did

#

I am very confused

lusty dew
#

Idk much about python but I’m sure errors mean the same thing in many languages

#

It isn’t finding the module youtube_dl

#

Either it’s it installed properly or at all or that’s not the name of the module

#

Or you imported it wrong

outer niche
#

Ok

west spoke
#

@outer niche pip install youtube_dl

#

In command prompt

outer niche
#

I did earlier did not work in PIP

west spoke
#

Works fine for me

#

(Dont have access to laptop atm)

sudden geyser
#

Does the Manage Messages permission also give members permission to clear and delete reactions from a message, or Manage Emojis

west spoke
#

Yes

#

Manage emojis are for creating/deleting emojis from the server

sudden geyser
#

alright

outer niche
#

I will try again

#

the bot is ready!
Echo music 479820732956934165 Ignoring exception in command play: Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped ret = await coro(*args, **kwargs) File "<string>", line 17, in play AttributeError: 'Bot' object has no attribute 'join_voice_channel' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 863, in invoke await ctx.command.invoke(ctx) File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.7/site-packages/discord/ext/commands/core.py", line 728, in invoke await injected(*ctx.args, **ctx.kwargs) File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.7/site-packages/discord/ext/commands/core.py", line 88, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'join_voice_channel'

west spoke
#

can you not read

outer niche
#

No not really

west spoke
#

'Bot' object has no attribute 'join_voice_channel'

#

have you read the docs

outer niche
#

No

earnest phoenix
#

No not really
well learn to

outer niche
#

@earnest phoenix well really can't because I have a learning disability

earnest phoenix
#

you could resolve your problem faster by yourself if you just read the errors you get (which is a lot of devs problems here)

#

don't blame your disability on basic cognitive functions.

west spoke
#

^

outer niche
#

Unless you're me then shut it because you don't know how I am and yes I am going to defend for myself because that's what's right

west spoke
#

What

earnest phoenix
#

translation: "i'm arrogant and my opinion is always correct"

west spoke
#

^

#

@outer niche if you cant read, then dont make a bot.

earnest phoenix
#

i mean, they're free to, it's just rather very much preferred that they self resolve problems instead of throw it in a chat and wait for someone to do it for them, especially when the problem is a simplistic error that can be solved by two google searches

west spoke
#

^^^

outer niche
#

Accept I've been looking since 9:00 this morning

west spoke
#

joining a vc isnt that hard

unique nimbus
#

Listen disabilities can make life harder. I have special needs. However Google always helps even if it is short words like "bot join channel discord". Disabilities shouldn't be used to make people do things for you except they should guide you like we are doing

balmy lantern
#

is it possible to get the first image off of google images

unique nimbus
#

I think there is a google image api

earnest phoenix
#

yes, but google's official apis are almost always paid and heavily ratelimited

#

you can scrape google but they don't allow it & have recaptcha

balmy lantern
#

sooo basically no

#

rip

#

Link it is then

earnest phoenix
#

you can scrape duckduckgo though

#

they allow it

#

I want to shard on multiple pcs

topaz fjord
#

ok

earnest phoenix
#

How do I pass data around

unique nimbus
#

sharding a bot is based on the main host I am not sure if you can pass it around

topaz fjord
#

afaik you would have to write your own sharding manager to do it

earnest phoenix
#

Already done

#

But

#

How do I shard it on 2 servers

#

Like run the bot on 2 different servers

#

Hence current server isn't powerful enough

#

And can't upgrade

#

I just want to know how to pass the data around

unique nimbus
#

How much are you spending on a server?

earnest phoenix
#

I am hosting at home

#

On a laptop hence the issue with servers is rate limiting from youtube

unique nimbus
#

hmm

#

I am not getting rate limits from YouTube

topaz fjord
#

it all depends on how much you request

#

multiple ips could help

earnest phoenix
#

Not the subject

#

I am using yt dl core

unique nimbus
#

so am I

earnest phoenix
#

What server you got?

#

Where from

unique nimbus
#

I am using Scaleway and its okay

topaz fjord
#

what are ur current specs

earnest phoenix
#

Interesting

#

I am in class

#

Rn tho

unique nimbus
#

I am using the 3 euro one from Scaleway which is yeet

quartz kindle
#

im using the 3$ one from galaxygate

uncut stirrup
#

Well, galaxygate looks good but they only have USA servers right now.

hushed berry
#

I use GG as well

#

I've got 5 dedis there

#

Really happy with their flexibility

uncut stirrup
#

What sort of flexibility o.o I've been using OVH for years now. would be happy to give others a try.

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.

uncut stirrup
#

what sort of website tho

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

uncut stirrup
#

omg

#

did u really XD

abstract crow
#

Stupid question but how do you guys use github? Do you just push an update for private repo's whenever you make a change and are done, or do you wait for an update to actually push the full thing
I currently have like 100s of commits because I always upload it to save in case I go anywhere but I am not sure that is how you use it

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

uncut stirrup
#

yeah. unlimited traffic means nothing if you got 100mbps limit.

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.

inner jewel
#

you did something wrong then

#

i have let's encrypt working flawlessly on a gg vps

sage bobcat
#

One message removed from a suspended account.

abstract crow
#

I will say this, the simplest of things I can't do on GG vps's. Ok maybe not the simplest, but something like git is broken

sage bobcat
#

One message removed from a suspended account.

abstract crow
#

Oh you don't have x installed install this to get that in order to get this

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

inner jewel
#

¯_(ツ)_/¯

#

blame plesk then

abstract crow
#

Try certbot

sage bobcat
#

One message removed from a suspended account.

abstract crow
#

Makes it able to redirect all urls to the https version

#

And give the site certificates

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.

uncut stirrup
#

are they managed servers or unmanaged

sage bobcat
#

One message removed from a suspended account.

uncut stirrup
#

unmanaged = OVH .... managed = godaddy

sage bobcat
#

One message removed from a suspended account.

uncut stirrup
#

aws vps's aren't that bad tbh

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

uncut stirrup
#

they dont magically take money. you didn't stop your services properly.

#

I had the same issue with bandwidth

sage bobcat
#

One message removed from a suspended account.

uncut stirrup
#

they was going to charge me like $400+ for bandwidth

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

uncut stirrup
#

I've been with Vultr, DO, OVH, SYS, AWS and some other ones like godaddy and hostgator. the majority except OVH and SYS had network issues at one point. but the moment i switched over to google... I've had 0 issues.

abstract crow
#

How was DO for you?

sage bobcat
#

One message removed from a suspended account.

abstract crow
#

I was with GG, then OVH, then DO, then Vultr, then DO currently

#

Yep

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

i have a vps on google as well

abstract crow
#

Yo

#

300 bucks

quartz kindle
#

for 12 months

sage bobcat
#

One message removed from a suspended account.

abstract crow
#

Forever

quartz kindle
#

since a long time ago

sage bobcat
#

One message removed from a suspended account.

abstract crow
#

google vps hosting

quartz kindle
#

google google compute engine

earnest phoenix
#

google cloud is overpriced

abstract crow
#

Not google it, but literally google vps hosting

earnest phoenix
#

but can be easily exploited

sick cloud
#

ngl

abstract crow
#

I don't know the pricing yet

sick cloud
#

i want the google maps api

sage bobcat
#

One message removed from a suspended account.

sick cloud
#

a lot

sage bobcat
#

One message removed from a suspended account.

sick cloud
#

i need to build a gps for my dad

quartz kindle
#

my bot was on google before i moved it to gg

earnest phoenix
#

they have a bunch of nice apis

sick cloud
#

he gave me the money to buy a rpi and a touch screen for it

earnest phoenix
#

i used their speech to text api to make voice commands

abstract crow
#

@sick cloud Let me know how that goes man

#

That seems awesome to make

quartz kindle
#

they have very good stuff, but they are pricey

earnest phoenix
#

indeed

quartz kindle
#

for example, google maps api is about 10x more expensive than mapbox

sick cloud
#

yeah i wish i could

quartz kindle
#

google vps charges for network traffic if you go over 1gb/month

sick cloud
#

but google maps api is expensive i guess?

#

idk i got the rpi here

#

i was thinking some kind of electron app to show the actual gps

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

you can try something like mapbox, its much cheaper

#

if it doesnt work well, then try google

sick cloud
#

yeah

#

ok

quartz kindle
#

anyway you get more than enough free usage

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

abstract crow
#

Holy fuck that shit expensive

#

For ubuntu 10gbs of disk

#

1cpu, 4 gbs ram

quartz kindle
#

google maps platform gives you $200 free usage each month

#

which is more than enough for private projects

sick cloud
#

i think i found what i need

earnest phoenix
#

@abstract crow they gave me 430 bucks

sick cloud
#
abstract crow
#

What are other things I would use with the Google Cloud Platform?

#

Besides VMs

quartz kindle
#

everything you can think of, they probably have

#

lol

earnest phoenix
#

I used it but eh

#

It's faster than azure

quartz kindle
#

storage, databases, maps, ai, voice recognition

abstract crow
#

For my website(s), should I just make multiple folders in the github repo or just make a repo for each site?

limber swan
#

Idk why, i have installed it
Error: Cannot find module 'enmap-sqlite'

slim heart
#

Each website should have their own repo

abstract crow
#

Ok. What about subdomains?

slim heart
#

I’d say also separate repos? If they’re different/unrelated from each other they should be separate

abstract crow
#

Ok. Thx bud!

slim heart
#

Ye

limber swan
#

Idk why, i have installed it
Error: Cannot find module 'enmap-sqlite'

abstract crow
#

try -g

limber swan
#

npm i enmap-sqlite -g ?

abstract crow
#

ye

limber swan
#

let me see

#

Nop still

hollow saddle
#

What's your code

#

enmap-sqlite is deprecated anyways since the newer versions of enmap don't use providers

limber swan
#

oof

#

damn

#

didnt know that

#

for the prefix and other stuff

hollow saddle
#

Yeah if you have a newer version of enmap that won't work

limber swan
#

what version of enmap works

hollow saddle
#

v3

limber swan
#

let me see

hollow saddle
#

v3 for providers but I recommend you stick with the newer versions (v5 currently) which use better-sqlite3

limber swan
#

alright, thanks

hollow saddle
#

np

mossy vine
#

write css in your long description between style tags

#

google is your best friend

#

once you know syntax, rest is just googling

#

you could find a bot that uses css for background and stuff, and use dev tools to look at the css written in the long description

sinful lotus
#

try it

#

yeah but

  1. You didnt provide an error
  2. I cant magically tell whats the problem if you just asked will thiis work
#

What are you even trying to do at this pointtt

#

then save it, then use it for yourself Thonk

#

as far as I'm reading, thats what you are ttrying to do

quartz kindle
#

i hope you're not trying to brute-force gift codes lmao

mossy vine
#

tim, thats literally what he is trying to do

earnest phoenix
#

What

#

Use a translation api

quartz kindle
#

You want automated translation or have translators/yourself do it?

#

Yes, but you want to do the translations or want automatic translations? Likr google translate

sinful lotus
#

store strings in a json file and label them accordingly

quartz kindle
#

Then you do two things:

  1. Save language preference in the database, the same way you do custom prefixes
  2. Replace all your hardcoded text with a string id, and save the strings somewhere like database or json file
sinful lotus
#
"en": {
  "deny": "you dont have etc etc"
},
"tag": {
  "deny": "hinde pwede"
}
#

something like that

#

then on your handler or something, check if the guild wants en or tag dependiing on their needs, then use the following property to reply

#

iidk if you get the iiddea but thats one

quartz kindle
#

Then Instead of .send("hello") you do .send(strings[lang][stringid])

#

Or similar

wheat jolt
#

Yeah, that's what I'm using too

quartz kindle
#

how are you checking the prefix?

peak quail
#

how can i fetch a user even the bot is not in a guild with the user

earnest phoenix
#

you can't

peak quail
#

: \

earnest phoenix
#

yes you can

#

you can get basic user information via the REST endpoint

fallen gulch
#
newUserMessage = "Welcome in"
#How can make bot to say The server name :c
normal temple
#

@fallen gulch Which language are you using?

#

If you are using javascript just do:

client.guild.name
fallen gulch
#

python

#

@normal temple

normal temple
warm marsh
#

It's the same in JavaScript.

normal temple
#

^^

fallen gulch
#

don t work 🤔

#

newUserMessage = "Welcome in" + bot.guild.name

@bot.event
async def on_member_join(member):
print("A intrat :" + member.name)
await bot.send_message(member, newUserMessage)
print("Mesaj trimis catre " + member.name)

earnest phoenix
#

message not bot

#

Smh

#

what

#

there's not even a variable named message what are you on about

#

Ik they need to define message

#

why so

#

from what i'm seeing they want to send a welcome DM to the user when they join the guild

#

Oh nvm I read part of the code

#

all they have to do is construct the string inside the method and instead of bot, use member

fallen gulch
#

😕 ?

quartz kindle
#

@fallen gulch as cry said, you need to use member.guild.name and you need to put the newUserMessage inside the on_member_join event

fallen gulch
#

🤔

slender thistle
#

server, not guild

west spoke
#

Wai

#

@fallen gulch

#

shiv, see, it's good to have someone know d.py async

quartz kindle
#

he wants the guild name tho?

west spoke
#

O

#

I just woke up Its hard to see some stuff

slender thistle
#

I'm fairly sure I can just rtd and remember what to do :^)

#

I also remember that it's servers in d.py async instead of guilds

west spoke
#

Yeah

#

I can change that lol

earnest phoenix
#

O.O do you guys get a "Beeping sound" when you ctrl+z in vs code's terminal ?

west spoke
#

That's undo

#

if you dont have anything to undo I think it does that

earnest phoenix
#

am i the only one finds that strange to have a audible feedback for that

flint trellis
#

you can disable it

cold trellis
#

im having problems with a certain bot, i get the reward after voting, but i dont get the message regarding i voted

flint trellis
#

go to that bots support server

cold trellis
#

im a support member, told me to go here

flint trellis
#

lol

cold trellis
flint trellis
#

you just got vote skammed

cold trellis
#

naw, many users have the same problem

#

bot is IdleRPG btw

flint trellis
#

not really a dbl problem

west spoke
#

^

earnest phoenix
cold trellis
#

may i send an image?

earnest phoenix
unkempt moon
#

Well, gameRoom[message.channel.id] is obviously not an array then...

earnest phoenix
#

how would i add an array to gameRoom ?

unkempt moon
#
gameRoom[message.channel.id] = gameRoom[message.channel.id] || []
gameRoom[message.channel.id].push(message.author.id)
#

Or if you're being fancy (not recommended)

gameRoom[message.channel.id] = (gameRoom[message.channel.id] && gameRoom[message.channel.id].push(message.author.id) && gameRoom[message.channel.id]) || [message.author.id]
earnest phoenix
#

bit confused about how that work

unkempt moon
#

The second one is confusing all right, you can ignore it. Did you understand the first code block?

earnest phoenix
#

why the gameRoom... = gameRoom part ?

unkempt moon
#

It just makes sure gameRoom[message.channel.id] is an array

#

You could see it as this condition

if (!gameRoom[message.channel.id])
    gameRoom[message.channel.id] = []
earnest phoenix
#

ok, what about the " or empty brackets "

#

ahh

#

okay i understand now

#

your condition example made sense to me

unkempt moon
#

One thing to understand is that the || (OR) operator in JavaScript does not create a boolean, it just returns the first value that is truthy.
If you take my first example, gameRoom[message.channel.id] is set to either gameRoom[message.channel.id] if it exists, or [] (an empty array) in the other case

earnest phoenix
#

thank you :)

unkempt moon
#

👍

stray garnet
#

anyone knows how to track ips in games?

#

Just askin

fallen gulch
#
Traceback (most recent call last):
  File "C:\Users\Acasa1\AppData\Local\Programs\Python\Python35\lib\site-packages\discord\client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "c:/Users/Acasa1/Desktop/MusicBot/Karma.py", line 29, in on_member_join
    print("A intrat :" + member.name)
  File "C:\Users\Acasa1\AppData\Local\Programs\Python\Python35\lib\encodings\cp437.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 15-16: character maps to <undefined>```
west spoke
#

print("A intrat :" + str(member.name).encode("utf8","replace"))

#

I'll spoonfeed for that, since it's a hard one to get working properly imo

#

without knowing how

fallen gulch
#
Traceback (most recent call last):
  File "C:\Users\Acasa1\AppData\Local\Programs\Python\Python35\lib\site-packages\discord\client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "c:/Users/Acasa1/Desktop/MusicBot/Karma.py", line 29, in on_member_join
    print("A intrat :" + str(member.name).encode("utf8","replace"))
TypeError: Can't convert 'bytes' object to str implicitly```
#

python

west spoke
#

Ah

fallen gulch
#

bot work

west spoke
#

print("A intrat :" + str(bytes(member.name).encode("utf8","replace")))

fallen gulch
#

when one person join in server

#

him don t get

#

messaje

west spoke
#

It's something that's happening with their name

fallen gulch
#
async def on_member_join(member):
    newUserMessage = "Welcome in " + member.server.name
    print("A intrat :" + member.name
    await bot.send_message(member, newUserMessage)
    print("Mesajul a fost trimis catre " + member.name)```
west spoke
#

nothing you can do unless they change it.

#

Their name isnt supported by utf8

#

eg characters that are raised up

#

and cannot be printed

fallen gulch
#

is problem with him name ? 🤔

#

@west spoke

west spoke
#

Yes

#

unless I encode my name, everything after the ( will send a error unless its encoded, and invalid characters are replaced

fallen gulch
#

oh

#

ty

#
        ^
SyntaxError: invalid syntax```
#

😐

slender thistle
#

Send full function

fallen gulch
#

@bot.event
async def on_member_join(member):
newUserMessage = "Welcome to " + member.server.name
print("A intrat:" + member.name
await bot.send_message(member, newUserMessage)
print("Mesajul a fost trimis catre " + member.name)

sudden geyser
#

You're missing a )

fallen gulch
#

Ty :))))))))))

mental thorn
#

Use f strings :p

#

Are you using async branch @fallen gulch ?

slender thistle
#

I'm pretty sure that's async and it does work for them

mental thorn
#

Ok then

#

Async is outdated though

slender thistle
#

While I would like to strongly discourage people from using async, I see no point in trying to convince them to use 1.0.0+ when they don't want to

mental thorn
#

What css should I define to change the appearance of the tags and bot user name in my bot page?

slender thistle
#

.atag and #bot-details-page .bot-name

mental thorn
#

Oh ok, thanks!

fallen gulch
#

how can make bot to react to one messaje

mossy vine
#

read docs

fallen gulch
#

exemple 🤔

mental thorn
#

Idk abt async

#

For rewrite its ctx.message.add_reaction

#

iirc

fallen gulch
#

(in python)

slender thistle
#

Honestly, this will cause more confusion

mental thorn
#

🤦

#

Mk then

slender thistle
#

So uhh let's not bring rw up in here

mental thorn
#

Idk

slender thistle
mental thorn
#

Shucks

slender thistle
#

No point

#

They don't support async version there

mental thorn
#

Oh yeah

slender thistle
#

What are you even doing to those lul

mental thorn
#

Welp

#

All I did was added padding and then that happened

earnest phoenix
#

-leave

mental thorn
#

@slender thistle any ideas?

slender thistle
#

Uhhh

mental thorn
#

Tell me if this is bothering you, ill stop pinging you :p

slender thistle
mental thorn
#

Ohh

#

But then

#

I did the exact same thing for the other buttons GWchadMEGATHINK

slender thistle
mental thorn
#

Well I added the four values anyway

#

And still got the same result :/

slender thistle
mossy vine
#

padding 0px 20px 0px 0px XDcursed

mental thorn
#

🤔 k

#

Still no luck owo

#

I guess im just gonna not pad it :/

jolly notch
#

Can bots ban people on server join?

earnest phoenix
#

yes, if they have perms to do so

slender thistle
#

Yes

jolly notch
#

How do you make a web dashboard?

earnest phoenix
#

you'd usually find a framework that allows you to host a webserver, then you would split it into backend and frontend, frontend is suggested to be a SPA (single application page) something like react or angular

#

you would then buy a vps and a domain, link your domain to your vps

jolly notch
#

I have the website

earnest phoenix
#

and hide your webserver behind a reverse proxy via something like nginx for maximum security

jolly notch
#

I have domain, ssl and hosting

#

Is there a tutorial for a python one?

earnest phoenix
#

google around

#

obviously don't search for "how to make a discord bot web dashboard in python", rather something like "python web server and SPA"

jolly notch
slender thistle
#

Could probably try Flask out

earnest phoenix
#

i don't know any python but that seems good

jolly notch
#

How do I send python variables from 1 file in France to a python script running In Ireland

earnest phoenix
#

web server

#

make a simple webhook handler

jolly notch
#

That is like telling a monkey how to do quadratics

earnest phoenix
#

no it's not

unique nimbus
#

Web Servers are quite easy to do

earnest phoenix
#

a monkey doesn't have access and doesn't have the mental capacity to do research via search engines

#

you, on the other hand, do

jolly notch
#

Does the bot need the webhook or the website need the webhook?

earnest phoenix
#

you can place your webhook handler anywhere you want, but from my perspective it would be better to do it on the web server that hosts the website as the website has to handle requests already

#

wait no

#

ignore what i just said

#

i was thinking websockets

#

for webhooks you have to place the handler wherever you want to receive the variable

#

if you want to exchange variables both ways real time, then use websockets and refer to my first message above

jolly notch
#

Okay thanks

pine jacinth
#

Hi everyone,
I am new to classes and the super() function.
I just ran into an error where I can't help myself.
Does anyone know why I get the below meniotned error?

class PresenceLoop(client):
    def __init__(self):
        self.bg_task = super().loop.create_task(self.my_background_task())

    async def my_background_task(self):
        [DO XY]

Called with

Presence = PresenceLoop()

ERROR: __init__() takes 1 positional argument but 4 were given

west spoke
#

self has 4 positional arguments

#

It may be defined somewhere else, but that's not how def() works

pine jacinth
#

What do you mean by that? (that's not how def() works)

west spoke
#

that self may have been defined somewhere else. But in that kind of thing, (def()) the variables are <var>="" (I think)

slender thistle
#

How do you even accidentally re-define self

pine jacinth
#

Yeah, self is not redefined in my class

#

@west spoke I should have mentioned that I am using python

west spoke
#

I know

#

I use python

#

By <var> I meant a blank variable

#

eg def Uname(name=message.author):

slender thistle
#

But where's that supposed to be

pine jacinth
#

Ah, now I get you. But then you would have defined it before calling it.

#

@slender thistle Do you mean me?

pine jacinth
#

ok

#

BUt do you have any idea, what would be wrong with my code?

west spoke
#

at this point, no.

#

try self=self (?)

slender thistle
#

What is client

west spoke
#

likely their discord client

slender thistle
#

There's no point in kwargs

pine jacinth
#

client is my discord.Client() object

west spoke
#

Oooh async

slender thistle
#

Huh, it's an instance, not the class itself, right?

pine jacinth
#

yeah

slender thistle
#

I'm getting a completely different error for instances lul

pine jacinth
#

shivaco would you mind, if I showed you the full code in a call?

slender thistle
#

I'd try subclassing Client class itself

#

Eh, a screenshot would be fine

west spoke
#

^

earnest phoenix
#

you can also use a paste service

pine jacinth
#

right

west spoke
#

wait client=client

#

you would need to define it in the def(client) in the other parts of the code

slender thistle
#

What

west spoke
#

class PrescenceLoop(client=client)

slender thistle
#

Yeah subclassing doesn't work like that

west spoke
#

that's how it works for me :v

pine jacinth
#

@slender thistle Here's the updated version: https://paste.mod.gg/emocibugaf.rb I now get 'super' object has no attribute 'loop' But super is discord.Client and it definetly has .loop

slender thistle
#

Yeah the client isn't ready yet when __init__ is called so .loop doesn't exist

pine jacinth
#

so, add await client.wait_until_ready() before?

slender thistle
#

__init__ is not a courutine

pine jacinth
#

Right

#

What would you suggest to do? I don't have an idea

#

😦

slender thistle
#

Send full traceback

pine jacinth
#
def __init__(self):
        super().wait_until_ready()
        self.bg_task = super().loop.create_task(self.my_background_task())

I guess wait_until_ready doesn't do much good without await

self.bg_task = super().loop.create_task(self.my_background_task()) AttributeError: 'super' object has no attribute 'loop'

slender thistle
#

Don't override __init__ when subclassing Client/Bot

#

You can use on_ready for this tbh

west spoke
#

^

#

async def on_ready():
<code>

pine jacinth
#

That's true. But what if I want my presence to have nice functions, etc. Wanted to learn a bit about super this way too. But seems like it doesn't work that easily xD

west spoke
#

And just make it loop in the on_ready

slender thistle
#

Meh, you can slap that task creating thing under on_ready, it's up to you

pine jacinth
#

But it on_ready isn't called. I guess because the discord.Client object is never run

slender thistle
#

Just subclass discord.Client, on_ready will be called when the client is somewhat ready to be used

#

That's why it's an event

pine jacinth
#

I have to call it with @<X>.event. But what do I put as <X>? Super() doesn't work

slender thistle
#

Nothing

#

It's just a function when subclassing

#

no decorators needed

pine jacinth
#

But in this example Mylient is being run with a token. Can I run with the same token twice?

slender thistle
#

Not sure if I'm following you here. Are you confused about the last line in that example where the parameter to .run is just a string without any variable?

#

You can use the same token as long as it isn't regenerated

pine jacinth
#

ok, yeah I was confused about that and wether I can run it a second time

west spoke
#

You can't run twice

slender thistle
#

Technically speaking, .run is blocking, so that's why you can't do

bot1.run('token')
bot2.run('token')```
pine jacinth
#

So I can't run twice? @slender thistle

slender thistle
#

You mean use two .runs at once?

pine jacinth
#

use another run in the first client's on_ready()

slender thistle
#

Not recommended

#

Oh wait, you are not using the 0.16.12 version, are you?

pine jacinth
#

newest

slender thistle
pine jacinth
#

This function must be the last function to call due to the fact that it is blocking. That means that registration of events or anything being called after this function call will not execute until it returns.

twilit rapids
#

What is a simple way to get the CPU usage using javascript.

slender thistle
#

Yes, .run is blocking

pine jacinth
#

I got it working now:

class PresenceLoop():
    def __init__(self, client):
        self.client = client
        self.bg_task = client.loop.create_task(self.my_background_task())

@client.event
async def on_ready():
    Presence = PresenceLoop(client)
slender thistle
#

uhhhh

pine jacinth
#

Thanks for helping 🙂

slender thistle
#

yw, I guess 🤣

pine jacinth
#

^^
One more question: Through the loops I get RuntimeError: Event loop stopped before Future completed. when doing CTRL+C
How do I prevent that?

slender thistle
#

Full error traceback would really help ngl

#

Not sure if that's too much of an issue honestly

pine jacinth
#
  File "Discord___Screen_Share_Bot.py", line 150, in <module>
    client.run(Token)
  File "/usr/local/lib/python3.7/dist-packages/discord/client.py", line 595, in run
    _cleanup_loop(loop)
  File "/usr/local/lib/python3.7/dist-packages/discord/client.py", line 92, in _cleanup_loop
    _cancel_tasks(loop)
  File "/usr/local/lib/python3.7/dist-packages/discord/client.py", line 77, in _cancel_tasks
    loop.run_until_complete(asyncio.gather(*tasks, loop=loop, return_exceptions=True))
  File "/usr/lib/python3.7/asyncio/base_events.py", line 582, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.```
#

It's not too much of an issue. But still one never wants to have Exceptions

west spoke
#

you need to ensure the future of the client

#

I think

pine jacinth
#

But I have to close it at some time xD

west spoke
#

just stop the process

slender thistle
#

What's your code looking like

pine jacinth
#
class PresenceLoop():
    def __init__(self, client):
        self.client = client
        self.bg_task = client.loop.create_task(self.my_background_task())

    async def my_background_task(self):
        await self.client.wait_until_ready()
        wait_time = 10
        while not self.client.is_closed():
            await self.client.change_presence([STUFF])
            await asyncio.sleep(wait_time)

@client.event
async def on_ready():
    Presence = PresenceLoop(client)

client.run(Token)
slender thistle
#
  1. Please make wait_time anything that's more than 12
  2. Looks like PresenceLoop's tasks don't get cancelled
  3. What's the point of the presence loop being a completely different class though?
pine jacinth
#

I still get the error when uping wait_time to 30 but will higher it to 30
I will look into cancellling tasks now :>

slender thistle
#

Could honestly make a loop that you'd run under on_ready instead of the whole separate class thing imo

pine jacinth
#

That's true but still think it's nicer with the class. I can verify that it does not have to do with using a class instead of on_ready()

slender thistle
#

that's up to you ¯_(ツ)_/¯

hallow prairie
#

someone knows how to make a bass boost using the lavalink setEquilizer?

inner jewel
#

boost the first bands

dapper glade
#

C!help

opaque eagle
#

No bot commands here fella

earnest phoenix
#

Hello, who can tell me how one can install quick.db under linux ubuntu 1804 neatly and completely?

deep rose
#

Does anyone have an idea on how to make a simple java code to make and store character sheets?

earnest phoenix
#

@deep rose Sublime Text

#

JetBrainsIDA

deep rose
#

?

onyx summit
#

I think he wanted ideas not an ide

earnest phoenix
#

xd

#

yes

deep rose
#

Lol

onyx summit
#

what do you guys use to deploy updates?
I thought about azure pipelines, or travis-ci
Not sure tho, dont have much experience with that, my old apps just pulled and restarted

quartz kindle
#

I update with sftp lul

#

I also test in production :D

zealous veldt
#

Cool kids test in production

onyx summit
#

ok so no serious answers here

hushed berry
#

@onyx summit i use semaphore for personal stuff

#

and circleci for work stuff

earnest phoenix
#

like, is it every user that has interacted with the bot ?

onyx summit
#

users that are stored in the ram

grim aspen
#

Basically

hushed berry
#

kinda

grim aspen
#

Maybe

earnest phoenix
onyx summit
#

you should always make sure and fetch specific users if you need them (if they are in the cached there wont go a request out)

#

for what purpose you need them?

earnest phoenix
#

seen some bots have "serving x amount of users" in the activity status and wanted to make something similar

hushed berry
#

ahh

onyx summit
#

sec

earnest phoenix
#

i got it working, but seems like a crazy large amount of users

hushed berry
#

what is it?

onyx summit
#

you probably forgot this server mm

zealous veldt
#

This server alone will ~60k to your user count

#

65k now iirc

earnest phoenix
#

my bot is in 100 servers but the .users returns 33k

onyx summit
#

read up

earnest phoenix
#

huh

slender thistle
#

Cache

earnest phoenix
#

but then it should be higher :/

#

oh right

#

cached

hushed berry
#

The bot doesnt automatically retrieve every member

onyx summit
#
client.guilds.map(g => g.memberCount).reduce((a, b) => a + b)

this will count all members, it won't be very exact tho
(probably better ways, but that is mine)

earnest phoenix
#

never tested my bot on this server

slender thistle
onyx summit
#

its one line who cares

earnest phoenix
#

xD

slender thistle
#

More than 0 so I do care

onyx summit
#

ur problem

#

u could literally go to my github and copy it notlikecat

earnest phoenix
#

so your method would return a larger number than the cache method

onyx summit
#

it will map all guilds by their memberCount (which should be exact) and then count them all together.
If a user is in multiple guilds he will count multiple times

earnest phoenix
#

oh, never considered that

#

likely not gonna make a big difference, but still thinkhfjkld

onyx summit
#

wdym

earnest phoenix
#

the likelihood of a users being in multiple channels, that your bot is in

onyx summit
#

guilds*

earnest phoenix
#

oh mb

onyx summit
#

tbh if ur bot is a bit bit bit big (> 100 Guilds) that few numbers won't matter

earnest phoenix
#

yeah, exactly

#

not gonna make a big difference

onyx summit
#

but still

earnest phoenix
#

just thought it was an interesting observation¨

#

has more than 60k users

onyx summit
#

no, only those who are on this server kek

earnest phoenix
#

caveBob time to get my bot on this server

#

but

#

thanks for the help

#

:)

torpid fox
#

anyone got a idea how the dbl widget could be included in a bots message?

amber fractal
#

By sending the link?

torpid fox
#

the widget link? if yes, that doesnt work

torpid fox
#

does that link update?

#

the png link...

amber fractal
#

Yes

earnest phoenix
#

yes, but the client caches it

#

so you need to add a cache breaker

torpid fox
earnest phoenix
#

basically

#

append a url param

#

something like ?v=whatever

#

and the client will redownload the picture instead of grabbing it from the cache

amber fractal
#

You can just use the time mmulu

earnest phoenix
#

i mean

torpid fox
#

does the url param need to be changed each time the command is run?

earnest phoenix
#

yeah

#

yes

torpid fox
#

k

#

mhh

amber fractal
#

Thats why the time would be easy

torpid fox
#

either i use random number or time

#

ye

earnest phoenix
#

unix timestamp of the current time

#

and you're gucci

torpid fox
#

also need to find my code for importing url to attachment 😅

#

made that a while ago when experimenting with rankcard

#

thx for the help

earnest phoenix
#

Wait you're the dank memer creator

amber fractal
#

No

unique nimbus
#

what

#

no

#

I dont think they are in the server still

amber fractal
#

You can send any bots widget

unique nimbus
#

isnt it just the id of the bot?

amber fractal
#

Yep

earnest phoenix
#

Mb, just assumed you gave an example of your own

#

Who is the biggest creator you've had on the server ?

unique nimbus
#

Pokecord

#

he still talks

zealous veldt
#

miles best waifu

unique nimbus
#

yes

#

would fuck

#

nohomo

quartz kindle
#

i remember when pokecord was broken af

#

most of its commands would do nothing half of the time lul

earnest phoenix
#

Sounds like my bot

#

Does that mean it will be just as popular

quartz kindle
#

nope

#

xD

earnest phoenix
#

pokecord is still a dumpster fire

#

Oof

#

Why u gotta roast

unique nimbus
#

Pokecord is just a bot for pokemon fans

earnest phoenix
#

What bot do you have most respectful for, code and function wise ?

#

non public ones

#

Stuff that can't be contained within 1 bot ?

#

private bots are more often than not higher quality than public bots

#

and that's mainly because it doesn't have to have all that extra code for multiple guilds

#

Why my bot cant send a help message into the mod tester server but it will send the message in minea

#

Anyone?

quartz kindle
#

i have respect for anything thats in over 100k guilds. i like to thinker about how each of them approached performance issues and load balancing

zealous veldt
#

Same

quartz kindle
#

im having fun customizing discord.js to run on 100mb ram

zealous veldt
#

oooo

quartz kindle
#

i made it compatible with pm2 clustering as well

zealous veldt
#

What changes have you made?

#

OOOOOOO

#

I'm intrigued

mossy vine
#

okay open that source pls

quartz kindle
#

its basically anti-caching

#

lul

#

caching only what the bot actually uses

#

it breaks a lot of stuff tho, so its not for everyone

earnest phoenix
#

Ty for summary

#

Was about to ask

quartz kindle
#

the only thing i cache is guilds

#

everything else i only cache what the bot uses

zealous veldt
#

aaa

earnest phoenix
#

What's the reason discord.js doesn't already "cache only what the bot uses"

zealous veldt
#

Are you going to be making that public?

quartz kindle
#

maybe

zealous veldt
#

If you do, I'd love to use it

quartz kindle
#

so far i've only tested it with messages, since my bot doesnt need anything else, so idk if voice works, but things such as roles, reactions and presences probably dont work (can be fixed)

earnest phoenix
#

is there a function is discord.js that checks when a user has no more servers common with a bot

west spoke
#

you would have to search through every server I think

earnest phoenix
#

yes

west spoke
#

and see if the member is in it

quartz kindle
#

and he might not be cached in all of them

west spoke
#

^

earnest phoenix
#

yup, you would have to download all of the members in all of the guilds which costs performance and bandwidth

#

unfortunately the endpoint that provides user information (common servers, badges etc.) on the client is for users only

#

cause basically my leaderboard command has a .tag and it can't read some users since they kicked the bot from the server

#

/ have no common servers with the bot

#

bot.users.get

#

does the same

#

it does not

#

if the user's in cache, it will provide the cached user, otherwise it will fetch the user via the REST endpoint which returns basic user information regardless of shared guilds

#
  paginatedItems.forEach(paginatedItem => {
     topembed.addField(i++, `<@${paginatedItem.ID.charAt(8) + paginatedItem.ID.substr(9)}> | Rupees: ${paginatedItem.data}.`)
   console.log(i++, `${bot.users.get(paginatedItem.ID.charAt(8) + paginatedItem.ID.substr(9)).tag} | Rupees: ${paginatedItem.data}.`)
   })```
#

I should replace bot.users.get with bot.fetchUser?

#

you'll have to adjust it a little since fetchUser returns a promise

#

but in theory, yes

hushed berry
#

@quartz kindle my DMs are always open if youve got questions about how I've scaled groovy 😊

inner jewel
#

scaling discord bots is a massive pain

unborn shoal
#

@hushed berry what did you do to scale it?

#

And to what extent can you scale it to?

hushed berry
#

The current system can scale pretty much as far as the database can scale

unborn shoal
#

Can you give some examples of what youve scaled and what memory youve saved from it @hushed berry

inner jewel
#

scaling horizontally doesnt save memory usually

hushed berry
#

yeah

unborn shoal
#

then what advantages are there?

hushed berry
#

Err

#

I have like mroe than enough ram because it basically comes free with the cpu we require

#

so i havent needed to optimize ram stuff very much

inner jewel
#

cost

#

vertical scaling can only get you where a single server is enough

#

and horizontal scaling has higher fault tolerancy

earnest phoenix
#

is there a way to show the tag when using bot.fetchUser?

inner jewel
#

bot.fetchUser(id).then(user => user.tag)

hushed berry
#

you cant scale vertically forever

inner jewel
#

^

#

massive servers are very expensive

#

and if you need more than what current hardware can handle you need to scale horizontally

earnest phoenix
#
const Discord = require("discord.js");
const db = require('quick.db');

exports.run = async (bot, message, args) => {
  const resp = db.all();
  resp.sort((a, b) => (a.data < b.data) ? 1 : -1);
  // Pagination
   
  let paginatedItems = resp.slice(0, 10);
  let total_pages = Math.ceil(resp.length / 10);
 
    const topembed = new Discord.RichEmbed()
    .setColor(16777215)
    .setTitle('LeaderBoard')
  i = 1;
  paginatedItems.forEach(paginatedItem => {
 bot.fetchUser(paginatedItem.ID.charAt(8) + paginatedItem.ID.substr(9)).then(user => topembed.addField(i++, `${user.tag} | Rupees: ${paginatedItem.data}.`));
      });
message.channel.send(topembed) 
}
exports.help = {
    name: 'leaderboard',
    "aliases": ['lb']
}```
#

and this keeps happening

#

this worked before so its not a db problem, this happened when I used bot.fetchUser

lusty dew
#

I’m also trying to make a leaderboard with better-sqlite3 kek

earnest phoenix
#

It worked before bto the bot.fetch is the problem

#

because you're sending the message before the async method completes

#

you're mixing sync and async

quartz kindle
#

does discord enforce the 1/5 ws login limit?

#

when using cluster mode, processes are able to restart independently, but since they are not aware of each other, they might attempt to login multiple times at once

dusky pawn
#

bot ları yiyin tm bok yiyin

#

iyi bok yiyn

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

How can I limit how many results I get?

#

In a better-sqlite3 db

#

I’m using a function my other dev made called getUser

#

And I wanna limit the results I pull to 10

#

Not sure how I’d limit the results to 10 as well as put them in order from greatest to least

#

Actually maybe I could make a new function hm

hushed berry
#

@quartz kindle yeah, discord does enforce it

#

you need to synchronize the identifies so that they dont step on each others toes

quartz kindle
#

im thinking about using a lockfile

#

so clusters wait until the lock is released before attempting to login

#

should be good enough for a single machine. running on multiple machines would require a centralized controller anyway, am i right?

loud salmon
#

imagine understanding any word that was said above

topaz fjord
#

I mean

#

logically yes @quartz kindle

#

I guess you could have a central thing that notifies a cluster that it's okay to login

hushed berry
#

@quartz kindle yeah, you're pretty spot on

quartz kindle
#

im making my bot compatible with pm2 clusters, which means it needs to be decentralized/stateless

#

its working pretty well

earnest phoenix
#
const Discord = require("discord.js");
const db = require('quick.db');

exports.run = async (bot, message, args) => {
  const resp = db.all();
  resp.sort((a, b) => (a.data < b.data) ? 1 : -1);
  // Pagination
   
  let paginatedItems = resp.slice(0, 10);
  let total_pages = Math.ceil(resp.length / 10);
 
    const topembed = new Discord.RichEmbed()
    .setColor(16777215)
    .setTitle('LeaderBoard')
  i = 1;

   
  paginatedItems.forEach(async paginatedItem => { 
 await bot.fetchUser(paginatedItem.ID.charAt(8) + paginatedItem.ID.substr(9)).then(user => topembed.addField(i++, `${user.tag} | Rupees: ${paginatedItem.data}.`));
      });
message.channel.send(topembed) 
}
exports.help = {
    name: 'leaderboard',
    "aliases": ['lb']
}```
#

Ok so I added a await and the issue is still happening

#

you're still mixing sync and async

#

How

#

your foreach func is async

#

everything else is sync

#

It doesn't matter, the end thing is the message isn't working

quartz kindle
#

you are sending the message before the loop finishes

#

.forEach() is not stopped by await

#

also await something().then() is not a thing

#

its either one or the other

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

maiden mauve
#

@earnest phoenix did you figure it out?

#

there are a lot of points in your code you should add console output to check variables

glossy trail
#

Epic

unkempt moon
#

@quartz kindle well actually await something().then() is totally a valid thing to do

opaque eagle
#

^

#

Real code from my bot:js const image = await $(APIs.CAT) .then(res => res.json());

unkempt moon
#

@quartz kindle I don't know how you've made D.JS stateless/without it's own supervisor process, but one of things you could use is ZeroMQ. Your first shard can be the listener, all the others can connect to it, and reconnections are entirely transparent. Plus, you can transmit any kind of data, and it's well-tested software

#

From their website:

ZeroMQ (also known as ØMQ, 0MQ, or zmq) looks like an embeddable networking library but acts like a concurrency framework. It gives you sockets that carry atomic messages across various transports like in-process, inter-process, TCP, and multicast. You can connect sockets N-to-N with patterns like fan-out, pub-sub, task distribution, and request-reply. It's fast enough to be the fabric for clustered products. Its asynchronous I/O model gives you scalable multicore applications, built as asynchronous message-processing tasks. It has a score of language APIs and runs on most operating systems.

onyx summit
#

if you need ipc clients and servers with responses I can recommend Veza.
I spawn a child on startup and then communicate with it over ipc so it does stuff for me that would be too heavy on the main process. (Like calculating string similarity between (yet) 400 Strings)

opaque eagle
#

When it comes to Role.position does a smaller number mean higher position or vice versa?

#

Using eris

earnest phoenix
#
    let gbanAutoStatus;
    if(Guild_Data.get(`${message.guild.id}.autoban`) === "0ui") {
        gbanAutoStatus == "`Activé`"
    }
    if(Guild_Data.get(`${message.guild.id}.autoban`) !== "Oui") {
        gbanAutoStatus == "`Désactivé`"
    }```

Why the bot say me "undefined" ?
opaque eagle
jolly notch
#

How to get my bots token?

#

@opaque eagle You spelt can't wrong

weary lark
opaque eagle
#

Thx but what about shortening the code @jolly notch

jolly notch
#

I don't do that language

#

@weary lark I meant the dbl token

opaque eagle
#

Oh

#

click on ur bot

jolly notch
#

Also the python server count is breaking the bot

#
Traceback (most recent call last):
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 580, in _load_from_module_spec
    setup(self)
  File "/home/runner/cogs/dbl.py", line 32, in setup
    bot.add_cog(DiscordBotsOrgAPI(bot))
  File "/home/runner/cogs/dbl.py", line 15, in __init__
    self.dblpy = dbl.client(self.bot, self.token)
TypeError: 'module' object is not callable

The above exception was the direct causeof the following exception:
#
Traceback (most recent call last):
  File "main.py", line 121, in <module>
    raise e
  File "main.py", line 118, in <module>
    bot.load_extension(cog)
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 625, in load_extension
    self._load_from_module_spec(lib, name)
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 584, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e)from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.dbl' raised an error: TypeError: 'module' object is not callable
weary lark
#

Then click on the bot you want the api key for

wide ruin
#

cmd isnt letting me get better_sqlite3

#

keeps saying not found

#

npm ERR! code E404
npm ERR! 404 Not Found: better_sqlite3@latest

split dune
#

@wide ruin this is named better-sqlite3

wide ruin
#

cmd says _ though

#

but thanks

#

@split dune its giving me an error now

split dune
wide ruin
split dune
#

@wide ruin install python

#

u must set "python" variable

#

i think python is just building this

tulip wave
#

Need windows build tools

#

I fixed my gyp rebuild errors with installing windows build tools and manually installing python

frigid juniper
#

Hello, I just had a question, how can I have my bot back to testing channel? Where should I apply when I will change my prefix?

tulip wave
#

Ask a mod @frigid juniper

#

Except for me I'm not home so I can't test anything

frigid juniper
#

Oki

#

Yeah I was just asking ^^

#

Thank you 😀

earnest phoenix
#

What is the line of code that allows the bot to check if the role mentioned is above its own role?
in d.js v12

brave anvil
#

Is there any eval code for discord.js to restart your bot?

earnest phoenix
#

@brave anvil use client.destroy()

brave anvil
#

Uhh

#

Okay

earnest phoenix
#

and client.login("token")

brave anvil
#

So I use pm2

earnest phoenix
#

uh so idk

brave anvil
#

Will it restart?

gleaming turret
#

@earnest phoenix that is python

earnest phoenix
#

What is the line of code that allows the bot to check if the role mentioned is above its own role?

gleaming turret
#

@earnest phoenix

earnest phoenix
#

i use v12

gleaming turret
#

When you ask a question you should put your language fyi

opaque eagle
#

wdym by "above its own role" @earnest phoenix

#

You mean like the bot's highest role?

quartz kindle
#

anyone good with classes and bindings, i have a question:
lets say i want to add a new method to djs.'s Message class, so that everytime i receive a message, i can do message.mymethod(something)
im using Discord.Message.prototype.mymethod = function(something) {} and it works, except i lose the this reference and i cannot access the properties of the current message instance from within mymethod()
how would i bind mymethod to every Message class instance?

opaque eagle
#

Do you use v12 or v11.x? @quartz kindle

quartz kindle
#

v12

opaque eagle
#

D.js makes this easy with structures```js
const { Message, Structures } = require("discord.js");
class CustomMessage extends Message {

// add all the getters and methods you want...
get hello() {
return "world";
}

foo() {
return "smth";
}

}

Structures.extend("Message", () => CustomMessage);```

#

All incoming messages will be an instance of CustomMessage

quartz kindle
#

oh interesting

opaque eagle
#

You have to extend all the structures before instantiating your client

#

You can extend any class that has a DataStore

fierce basalt
#

Anyone got any good commands that can be used for a bot?

opaque eagle
#

A DataStore is one of these, like MessageStore or GuildEmojiStore

fierce basalt
#

oof you use master in discord.j

#

.js

opaque eagle
#

i mean i dont use it

#

but when i do use d.js i use master

#

normally i like eris better

fierce basalt
#

Nice.

summer torrent
#

How to fix cannot read property 'content' of undefined error?

opaque eagle
#

Show code @summer torrent

summer torrent
#

const choice = response.first().content

opaque eagle
#

response.first() is undefined

fierce basalt
#

in what context are you using it for?

summer torrent
#

response is defined

opaque eagle
#

Where

#

Show that code

summer torrent
#

const response = await message.channel.awaitMessages(neblm => neblm.author.id === message.author.id, { max: 1, time: 1024 });

opaque eagle
#

No message was sent

#

response is an empty collection

quartz kindle
#

hmm im still getting an empty this

summer torrent
#

hmm

opaque eagle
#

Also how do you expect someone to respond in 1024 milliseconds

summer torrent
#

oh, this is a mistake

copper cradle
#

lmao

quartz kindle
#

@opaque eagle the only way i could get it to work was by using bind, although i was trying to avoid it

#
client.on("message", message => {
    message.send("something").then(message.mymethod.bind(message))
})```
#

anyway to simplify this?

#

i extended the class like this js Structures.extend("Message", Message => { class xMessage extends Message { constructor(client, data, channel) { super(client, data, channel); } mymethod(response) { console.log(this,response); } } return xMessage; });

#

basically im trying to join the received and the returned message in a single function

quartz kindle
#

nvm, theres no way to do this without binding because its a promise

inner jewel
#

.then(()=>message.mymethod())

#

it's not because it's a promise

#

it's because using obj.method as a value wont have it bound to the instance by default

quartz kindle
#

or that yes

#

im thinking of doing something else rn

#

i kinda want to do this behind the scenes, im looking into hooking into the message.reply function

#

or just making my own message.send

quartz kindle
#

help with what?

copper cradle
#

just send the error and the segment of code where it's happening

#

I'm not gonna read through all of that

languid dragon
#

im surprised that even works

vagrant bison
#

How to get data from the text file line in node.js?

earnest phoenix
#

How to add role with an id role to an user in discordjs v12

wheat jolt
#

you have docs i think

#

¯_(ツ)_/¯

onyx summit
#

@vagrant bison google fs.readFile (dont use the sync method if u care about performance)

#

wait text file line?

#

you mean command line?

vagrant bison
#

I want to get the text from a given line of the txt file

onyx summit
#

read the file. split at \n, boom you have an array with each line

#

if the file is big you should stream it tho

vagrant bison
#

where should I change it?

onyx summit
#

change what?

vagrant bison
#

\n

#

this verse number

onyx summit
#
require('fs').readFileSync('som/file/u/need').split('\n')[3] // line 4 (I think)`

Dont use sync methods tho, it blocks the event loop (your process wont do anything besides reading the file)

vagrant bison
#

thanks

#

(:

#

@onyx summit /:

#
TypeError: require(...).readFileSync(...).split is not a function
inner jewel
#

readFileSync returns a buffer

onyx summit
#

ye my bad, just wrote this without thinking

#

use .toString()

#

afaik

vagrant bison
#
require('fs').readFileSync('count.txt').split('\n').toString(1);
#

?

#

good?

inner jewel
#

no

vagrant bison
#

/:

inner jewel
#

read the docs on those functions instead of asking how to do everything

onyx summit
#

damn, dunno if its my bad for writing this in one line, or yours

vagrant bison
#

if I could speak English (:

onyx summit
#

you can write it at least

vagrant bison
#

ok how can I fix it?

onyx summit
#

My english sucks too, but its enough for reading some lines mmLol

#

okay, readFileSync returns a buffer, and you need a string, so you call toString() on the buffer

#
const buffer = require('fs').readFileSync('sumfile.txt');
const theString = buffer.toString();
// theString is now a string, whow
quartz kindle
#

or you can set the encoding to utf8

vagrant bison
#

Where to enter the verse?

onyx summit
#
require('fs').readFileSync('./index.js', 'utf8')
vagrant bison
#

I don't want coding, just where should I enter the number of lines

onyx summit
#

you should learn what .split does, and how you access arrays

vagrant bison
#

can you write it for me?

#

script *

onyx summit
#

I got tired from spoonfeeding blobtrashsleep
chy did enough spoonfeed for today

vagrant bison
#

xd?

onyx summit
#

means: write your own code

inner jewel
#

rule 7b

#

dont ask to be spoonfed

vagrant bison
#

good
I will do another way

onyx summit
#
  • moves on to the next server and asks for code *
vagrant bison
#

no?

maiden mauve
#

that is intense

onyx summit
#

I dont get the joke, can you explain it?

stray garnet
#

Workspeace: No Workspace or idk @onyx summit

onyx summit
#

@earnest elm
try

client.guilds.map(g => g.memberCount).reduce((a, b) => a + b)

this will count all members, it won't be very exact tho
(probably better ways, but that is mine)

earnest elm
#

Yeah that would work too

#

Thank you

#

Yeah it can read it right

#

Thanks

wheat jolt
#

any ideea?

west spoke
#

You need to promise it I believe

wheat jolt
#

hm

onyx summit
#

I dont think a url is a valid file, is it?
(or am I reading something wrong?)

#

just create a embed and use `setImage(url)

opaque eagle
#

Are there any advantages to using express.js to write a restful api in node?