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]
#development
1 messages · Page 682 of 1
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
Ok
I did earlier did not work in PIP
Does the Manage Messages permission also give members permission to clear and delete reactions from a message, or Manage Emojis
alright
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'
can you not read
No not really
No
No not really
well learn to
@earnest phoenix well really can't because I have a learning disability
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.
^
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
What
translation: "i'm arrogant and my opinion is always correct"
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
^^^
Accept I've been looking since 9:00 this morning
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
is it possible to get the first image off of google images
I think there is a google image api
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
you can scrape duckduckgo though
they allow it
I want to shard on multiple pcs
ok
How do I pass data around
sharding a bot is based on the main host I am not sure if you can pass it around
afaik you would have to write your own sharding manager to do it
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
How much are you spending on a server?
I am hosting at home
On a laptop hence the issue with servers is rate limiting from youtube
so am I
I am using Scaleway and its okay
what are ur current specs
I use the 10 dollar one from https://galaxygate.net/hosting/vps/
GalaxyGate Hosting
I am using the 3 euro one from Scaleway which is yeet
im using the 3$ one from galaxygate
Well, galaxygate looks good but they only have USA servers right now.
What sort of flexibility o.o I've been using OVH for years now. would be happy to give others a try.
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.
what sort of website tho
One message removed from a suspended account.
One message removed from a suspended account.
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
One message removed from a suspended account.
One message removed from a suspended account.
yeah. unlimited traffic means nothing if you got 100mbps limit.
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.
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
One message removed from a suspended account.
Oh you don't have x installed install this to get that in order to get this
One message removed from a suspended account.
One message removed from a suspended account.
Try certbot
One message removed from a suspended account.
Makes it able to redirect all urls to the https version
And give the site certificates
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.
are they managed servers or unmanaged
One message removed from a suspended account.
unmanaged = OVH .... managed = godaddy
One message removed from a suspended account.
aws vps's aren't that bad tbh
One message removed from a suspended account.
One message removed from a suspended account.
they dont magically take money. you didn't stop your services properly.
I had the same issue with bandwidth
One message removed from a suspended account.
they was going to charge me like $400+ for bandwidth
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
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.
How was DO for you?
One message removed from a suspended account.
One message removed from a suspended account.
i have a vps on google as well
for 12 months
One message removed from a suspended account.
Forever
since a long time ago
One message removed from a suspended account.
google vps hosting
google google compute engine
google cloud is overpriced
Not google it, but literally google vps hosting
but can be easily exploited
ngl
I don't know the pricing yet
i want the google maps api
One message removed from a suspended account.
a lot
One message removed from a suspended account.
i need to build a gps for my dad
my bot was on google before i moved it to gg
they have a bunch of nice apis
he gave me the money to buy a rpi and a touch screen for it
i used their speech to text api to make voice commands
they have very good stuff, but they are pricey
indeed
for example, google maps api is about 10x more expensive than mapbox
yeah i wish i could
google vps charges for network traffic if you go over 1gb/month
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
One message removed from a suspended account.
you can try something like mapbox, its much cheaper
if it doesnt work well, then try google
yeah
ok
https://developers.google.com/maps/documentation/directions/start so this isnt free right
anyway you get more than enough free usage
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
google maps platform gives you $200 free usage each month
which is more than enough for private projects
i think i found what i need
@abstract crow they gave me 430 bucks
Toggle navigation Home Download Screenshots Donate Contact Us Toggle navigation Home Download Screenshots Donate Contact Us Navit is free and without ads. Free maps based on OpenStreetMaps. Navit does not track your usage and respects your privacy. Navit can be used fully off...
storage, databases, maps, ai, voice recognition
For my website(s), should I just make multiple folders in the github repo or just make a repo for each site?
Idk why, i have installed it
Error: Cannot find module 'enmap-sqlite'
Each website should have their own repo
Ok. What about subdomains?
Should I just make
vinniehat.tk > vinniehat.tk & pbs.vinniehat.tk?
I’d say also separate repos? If they’re different/unrelated from each other they should be separate
Ok. Thx bud!
Ye
Idk why, i have installed it
Error: Cannot find module 'enmap-sqlite'
try -g
npm i enmap-sqlite -g ?
ye
What's your code
enmap-sqlite is deprecated anyways since the newer versions of enmap don't use providers
oof
damn
didnt know that
its for this https://gyazo.com/6d1a05588af6ed4663bc77f3b6d49b8b
for the prefix and other stuff
Yeah if you have a newer version of enmap that won't work
what version of enmap works
v3
let me see
v3 for providers but I recommend you stick with the newer versions (v5 currently) which use better-sqlite3
alright, thanks
np
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
try it
yeah but
- You didnt provide an error
- 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 
as far as I'm reading, thats what you are ttrying to do
i hope you're not trying to brute-force gift codes lmao
tim, thats literally what he is trying to do
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
store strings in a json file and label them accordingly
Then you do two things:
- Save language preference in the database, the same way you do custom prefixes
- Replace all your hardcoded text with a string id, and save the strings somewhere like database or json file
"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
Yeah, that's what I'm using too
how are you checking the prefix?
how can i fetch a user even the bot is not in a guild with the user
you can't
: \
newUserMessage = "Welcome in"
#How can make bot to say The server name :c
@fallen gulch Which language are you using?
If you are using javascript just do:
client.guild.name
Then do: message.guild.name
It's the same in JavaScript.
^^
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)
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
bot.guild.name won't work
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 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 message.author.name
Wai
@fallen gulch
shiv, see, it's good to have someone know d.py async

he wants the guild name tho?
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
O.O do you guys get a "Beeping sound" when you ctrl+z in vs code's terminal ?
am i the only one finds that strange to have a audible feedback for that
you can disable it
im having problems with a certain bot, i get the reward after voting, but i dont get the message regarding i voted
go to that bots support server
im a support member, told me to go here
lol

you just got vote skammed
not really a dbl problem
^
anyone know why this doesnt work
may i send an image?
but this does
Well, gameRoom[message.channel.id] is obviously not an array then...
how would i add an array to gameRoom ?
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]
bit confused about how that work
The second one is confusing all right, you can ignore it. Did you understand the first code block?
why the gameRoom... = gameRoom part ?
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] = []
ok, what about the " or empty brackets "
ahh
okay i understand now
your condition example made sense to me
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
thank you :)
👍
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>```
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
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
Ah
bot work
It's something that's happening with their name
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)```
nothing you can do unless they change it.
Their name isnt supported by utf8
eg characters that are raised up
and cannot be printed
Yes
unless I encode my name, everything after the ( will send a error unless its encoded, and invalid characters are replaced
Send full function
@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)
You're missing a )
Ty :))))))))))
I'm pretty sure that's async and it does work for them
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
What css should I define to change the appearance of the tags and bot user name in my bot page?
I managed to get this far
.atag and #bot-details-page .bot-name
Oh ok, thanks!
how can make bot to react to one messaje
read docs
(in python)
Honestly, this will cause more confusion
So uhh let's not bring rw up in here
Idk
In on_message, you have one parameter to the event, which is an instance of discord.Message, which you can pass as first argument in bot.add_reaction (https://discordpy.readthedocs.io/en/v0.16.12/api.html#discord.Client.add_reaction)
What are you even doing to those 
-leave
@slender thistle any ideas?
Uhhh
Tell me if this is bothering you, ill stop pinging you :p

padding 15px 15px https://shivaco.is-inside.me/CQSJvFp3.png
padding-right 20px https://shivaco.is-inside.me/QOPyYCT7.png
padding 0px 20px 0px 0px 
Can bots ban people on server join?
yes, if they have perms to do so
Yes
How do you make a web dashboard?
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
I have the website
and hide your webserver behind a reverse proxy via something like nginx for maximum security
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"
This any good? https://www.aosabook.org/en/500L/a-simple-web-server.html
Could probably try Flask out
i don't know any python but that seems good
How do I send python variables from 1 file in France to a python script running In Ireland
That is like telling a monkey how to do quadratics
no it's not
Web Servers are quite easy to do
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
Does the bot need the webhook or the website need the webhook?
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
Okay thanks
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
self has 4 positional arguments
It may be defined somewhere else, but that's not how def() works
What do you mean by that? (that's not how def() works)
that self may have been defined somewhere else. But in that kind of thing, (def()) the variables are <var>="" (I think)
How do you even accidentally re-define self
Yeah, self is not redefined in my class
@west spoke I should have mentioned that I am using python
I know
I use python
By <var> I meant a blank variable
eg def Uname(name=message.author):
But where's that supposed to be
Ah, now I get you. But then you would have defined it before calling it.
@slender thistle Do you mean me?
What is client
There's no point in kwargs
client is my discord.Client() object
Oooh async
Huh, it's an instance, not the class itself, right?
yeah
I'm getting a completely different error for instances 
shivaco would you mind, if I showed you the full code in a call?
^
right
wait client=client
you would need to define it in the def(client) in the other parts of the code
What
Yeah subclassing doesn't work like that
that's how it works for me :v
@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
Yeah the client isn't ready yet when __init__ is called so .loop doesn't exist
so, add await client.wait_until_ready() before?
__init__ is not a courutine
Send full traceback
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'
Don't override __init__ when subclassing Client/Bot
You can use on_ready for this tbh
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
And just make it loop in the on_ready
Meh, you can slap that task creating thing under on_ready, it's up to you
But it on_ready isn't called. I guess because the discord.Client object is never run
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
I have to call it with @<X>.event. But what do I put as <X>? Super() doesn't work
Nothing
It's just a function when subclassing
no decorators needed
As shown here https://github.com/Rapptz/discord.py/blob/master/examples/edits.py, basically
But in this example Mylient is being run with a token. Can I run with the same token twice?
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
ok, yeah I was confused about that and wether I can run it a second time
You can't run twice
Technically speaking, .run is blocking, so that's why you can't do
bot1.run('token')
bot2.run('token')```
So I can't run twice? @slender thistle
You mean use two .runs at once?
use another run in the first client's on_ready()
newest
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.
What is a simple way to get the CPU usage using javascript.
Yes, .run is blocking
Could this be helpful, Timo? https://stackoverflow.com/questions/36816181/get-view-memory-cpu-usage-via-nodejs
Stack Overflow
I see there are several node packages that allow you to look up a specific process's usage, such as https://www.npmjs.com/package/usage
I am trying to get the overall sever usage/stats (CPU and Me...
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)
uhhhh
Thanks for helping 🙂
yw, I guess 🤣
^^
One more question: Through the loops I get RuntimeError: Event loop stopped before Future completed. when doing CTRL+C
How do I prevent that?
Full error traceback would really help ngl
Not sure if that's too much of an issue honestly
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
But I have to close it at some time xD
What's your code looking like
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)
- Please make
wait_timeanything that's more than 12 - Looks like
PresenceLoop's tasks don't get cancelled - What's the point of the presence loop being a completely different class though?
I got rid of the Exception with a try, except on client.run(Token). But that does not seem to be the perfect solution.
https://discordapp.com/channels/264445053596991498/272764566411149314/615952221598646303
- ok
- how can I cancel the task and where should I cancel it?
- uhm So I can add functions to it in the future if needed.
I still get the error when uping wait_time to 30 but will higher it to 30
I will look into cancellling tasks now :>
Could honestly make a loop that you'd run under on_ready instead of the whole separate class thing imo
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()
that's up to you ¯_(ツ)_/¯
someone knows how to make a bass boost using the lavalink setEquilizer?
boost the first bands
C!help
No bot commands here fella
Hello, who can tell me how one can install quick.db under linux ubuntu 1804 neatly and completely?
Does anyone have an idea on how to make a simple java code to make and store character sheets?
?
I think he wanted ideas not an ide
Lol
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
Cool kids test in production
ok so no serious answers here
does anyone know what "cached" specifically means ?
like, is it every user that has interacted with the bot ?
users that are stored in the ram
Basically
kinda
Maybe

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?
seen some bots have "serving x amount of users" in the activity status and wanted to make something similar
ahh
sec
i got it working, but seems like a crazy large amount of users
what is it?
you probably forgot this server 
my bot is in 100 servers but the .users returns 33k
read up
huh
Cache
The bot doesnt automatically retrieve every member
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)
never tested my bot on this server

its one line who cares
xD
More than 0 so I do care
so your method would return a larger number than the cache method
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
wdym
the likelihood of a users being in multiple channels, that your bot is in
guilds*
oh mb
tbh if ur bot is a bit bit bit big (> 100 Guilds) that few numbers won't matter
but still
just thought it was an interesting observation¨
does that mean every bot on discordbots.org
has more than 60k users
no, only those who are on this server 
anyone got a idea how the dbl widget could be included in a bots message?
By sending the link?
the widget link? if yes, that doesnt work
Yes

basically
append a url param
something like ?v=whatever
and the client will redownload the picture instead of grabbing it from the cache
You can just use the time 
i mean
does the url param need to be changed each time the command is run?
Thats why the time would be easy
also need to find my code for importing url to attachment 😅
made that a while ago when experimenting with rankcard
thx for the help
Wait you're the dank memer creator
You can send any bots widget
isnt it just the id of the bot?
Yep
Mb, just assumed you gave an example of your own
Who is the biggest creator you've had on the server ?
miles best waifu
i remember when pokecord was broken af
most of its commands would do nothing half of the time lul
Pokecord is just a bot for pokemon fans
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?
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
Same
im having fun customizing discord.js to run on 100mb ram
oooo
i made it compatible with pm2 clustering as well
okay open that source pls
its basically anti-caching
lul
caching only what the bot actually uses
it breaks a lot of stuff tho, so its not for everyone
aaa
What's the reason discord.js doesn't already "cache only what the bot uses"
Are you going to be making that public?
maybe
If you do, I'd love to use it
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)
is there a function is discord.js that checks when a user has no more servers common with a bot
you would have to search through every server I think
yes
and see if the member is in it
and he might not be cached in all of them
^
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
this is a http://xyproblem.info/
Asking about your attempted solution rather than your actual problem
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
@quartz kindle my DMs are always open if youve got questions about how I've scaled groovy 😊
scaling discord bots is a massive pain
The current system can scale pretty much as far as the database can scale
Can you give some examples of what youve scaled and what memory youve saved from it @hushed berry
scaling horizontally doesnt save memory usually
yeah
then what advantages are there?
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
cost
vertical scaling can only get you where a single server is enough
and horizontal scaling has higher fault tolerancy
is there a way to show the tag when using bot.fetchUser?
bot.fetchUser(id).then(user => user.tag)
you cant scale vertically forever
^
massive servers are very expensive
and if you need more than what current hardware can handle you need to scale horizontally
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
I’m also trying to make a leaderboard with better-sqlite3 kek
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
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
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
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
@quartz kindle yeah, discord does enforce it
you need to synchronize the identifies so that they dont step on each others toes
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?
I mean
logically yes @quartz kindle
I guess you could have a central thing that notifies a cluster that it's okay to login
@quartz kindle yeah, you're pretty spot on
im making my bot compatible with pm2 clusters, which means it needs to be decentralized/stateless
its working pretty well
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
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
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
@earnest phoenix did you figure it out?
there are a lot of points in your code you should add console output to check variables
Epic
@quartz kindle well actually await something().then() is totally a valid thing to do
^
Real code from my bot:js const image = await $(APIs.CAT) .then(res => res.json());
@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.
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)
When it comes to Role.position does a smaller number mean higher position or vice versa?
Using eris
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" ?
Any recommendations on how to shorten this code?
https://gist.github.com/SinistreCyborg/654becf406357ae009e489aa26092b67
@jolly notch You get your bots token by heading over to https://discordapp.com/developers/applications, then click on the app/bot you want the token for, click on the "bot" button on the left side and click on "click to reveal token"
Discord Developer Portal
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Thx but what about shortening the code @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
@jolly notch https://discordbots.org/api/docs#mybots
Then click on the bot you want the api key for
cmd isnt letting me get better_sqlite3
keeps saying not found
npm ERR! code E404
npm ERR! 404 Not Found: better_sqlite3@latest
@wide ruin this is named better-sqlite3
@wide ruin install python
u must set "python" variable
i think python is just building this
Need windows build tools
I fixed my gyp rebuild errors with installing windows build tools and manually installing python
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?
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
Is there any eval code for discord.js to restart your bot?
@brave anvil use client.destroy()
and client.login("token")
So I use pm2
uh so idk
Will it restart?
@earnest phoenix that is python
What is the line of code that allows the bot to check if the role mentioned is above its own role?
@earnest phoenix
i use v12
When you ask a question you should put your language fyi
wdym by "above its own role" @earnest phoenix
You mean like the bot's highest role?
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?
Do you use v12 or v11.x? @quartz kindle
v12
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
oh interesting
You have to extend all the structures before instantiating your client
You can extend any class that has a DataStore
Anyone got any good commands that can be used for a bot?
A DataStore is one of these, like MessageStore or GuildEmojiStore
i mean i dont use it
but when i do use d.js i use master
normally i like eris better
Nice.
How to fix cannot read property 'content' of undefined error?
Show code @summer torrent
const choice = response.first().content
response.first() is undefined
in what context are you using it for?
response is defined
const response = await message.channel.awaitMessages(neblm => neblm.author.id === message.author.id, { max: 1, time: 1024 });
hmm im still getting an empty this
hmm
Also how do you expect someone to respond in 1024 milliseconds
oh, this is a mistake
lmao
@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
nvm, theres no way to do this without binding because its a promise
.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
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
help with what?
just send the error and the segment of code where it's happening
I'm not gonna read through all of that
im surprised that even works
How to get data from the text file line in node.js?
How to add role with an id role to an user in discordjs v12
@vagrant bison google fs.readFile (dont use the sync method if u care about performance)
wait text file line?
you mean command line?
if you meant command line:
https://www.npmjs.com/package/readline
I want to get the text from a given line of the txt file
read the file. split at \n, boom you have an array with each line
if the file is big you should stream it tho
small file: read the whole file and split it by \n
big file: stream it (e.g. with https://www.npmjs.com/package/line-reader)
where should I change it?
change what?
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)
thanks
(:
@onyx summit /:
TypeError: require(...).readFileSync(...).split is not a function
readFileSync returns a buffer
no
/:
read the docs on those functions instead of asking how to do everything
damn, dunno if its my bad for writing this in one line, or yours
if I could speak English (:
you can write it at least
ok how can I fix it?
My english sucks too, but its enough for reading some lines 
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
or you can set the encoding to utf8
Where to enter the verse?
require('fs').readFileSync('./index.js', 'utf8')
I don't want coding, just where should I enter the number of lines
you should learn what .split does, and how you access arrays
I got tired from spoonfeeding 
chy did enough spoonfeed for today
xd?
means: write your own code
good
I will do another way
- moves on to the next server and asks for code *
no?
I dont get the joke, can you explain it?
Workspeace: No Workspace or idk @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)
You need to promise it I believe
hm
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)
Are there any advantages to using express.js to write a restful api in node?





time to get my bot on this server
