#development
1 messages · Page 1824 of 1
Does canvas has a way to get a url from the image?
Or do I have to set up an express server
custom emojis have a url
get the url from the custom emoji object
then download/fetch the image from that url
Ok
And then I add that image onto a canvas image, what’s the best way of using that image in an embed?
you can use canvas.loadImage
what does the time does in the params of .generate([time])
the timestamp of the snowflake
by default it uses the current date (Date.now())
convert canvas image to buffer, and use buffer to generate a image file, and then attach the file to the embed
What does it do?
you dont need to generate an image file
wait what is a snowflake again 
ik snowflake as like an id or somth
I dont want to us emessage attachments
Snowflake IDs, or snowflakes, are a form of unique identifier used in distributed computing. The format was created by Twitter and is used for the IDs of tweets. The format has been adopted by other companies, including Discord, and Instagram, which uses a modified version.
snowflake is a unique ID that is built with 3 variables
As when you edit it the image just appears at the top
im just confused on why does time correlates to snowflake if u know what i mean
read the link
timestamp is one of the variables in the snowflake
I too wanted that behaviour back before, to edit the image in embed. But couldn't find any solution.
Tell me, if you could find any
Creating an express server is an option or sending the image in a dummy channel and getting the link from there
That’s what I’ve been doing
ohhh now i get it
im not understanding what you mean
thx!
But I wanna know if there’s a better solution
why do you need to save an image to a dummy channel?
u can save the image to a storage, and get the link
why not just.... upload as an attachement
or use an actually content serving system
you want to use embeds without the actual file?
than we cant change it
Cuz I said earlier when you edit it and dont use the image it just sits there ontop of the message
Can you upload to imgur using code?
or (shameless plug) depending on your needs: https://github.com/ChillFish8/lust
hot
this will be a unique snowflake right?
So I can use this to get a url to the image?
we get it, you vape
discord embeds
somewhat yes, depends on what you're using it for
you can yes
threads were available for a while but what the fuck does "dropped" mean
as in being added or being removed
removed
ic
deprecated ig
ah, little bobby tables we call him
and then
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
literally what
the events will probably get replaced with something uniform in later gw versions
they did say it was not stable but v9 is available without those gateway events
oh
aka the library cant pick up those events when i tell it to listen for them
no thats not what it is
maybe skill issue or discord just said nah
those events are dropped in api v8-
in the sense that if you dont have api v9, you will not receive any of those events
from messages inside threads
or messages using the threads system
i see
thread events you obviously dont receive if you dont use api v9
and the others may be dropped if they are part of threads
yeah ive already updated it to use v9 but raw events dont show any thread events being received
so im curious if its just not a thing yet or something
this was tested on a server with threads enabled
Mine has it!
i really want to believe this is a issue with my code but im wondering if anyone else's bots can pick up these events
Do you think threads will be usefull for bots?
also
private threads are hard to test since theyre limited to servers with tier 2 or higher
as for this
depends, your bot will still receive message create events for messages inside threads
when on v9
tbh i dont get the whole idea of threads
the idea of a private thread was that the person who instantiated it can invite other people
and yeah me neither, though i guess the implication was keeping chat tidy
wait, really?
discord really gonna make it hard for everyone who doesnt have a partnered server
the whole thing about threads was about allowing users to continue a topic on private, if that's limited to tier 2 or above then wtf?
just create group dms
yeah
i really do not know the motivation behind threads but im going on a tangent here
But to create group DMs you have to add that person as friend
I dont like having friends 😦
threads are genuinely pointless imo
but its not like its gonna be removed or anything
they say people have been requesting them for years but i haven't met a single person who said that
same
People have been requesting custom statuses for bots for years, but they're not here yet
:]
it's just their attempt to copy slack and cater to a wider audience
I mean, in my case I'd have a GREAT use-case for threads, but the private ones
public threads are fckin pointless
the issue is not necessarily why they implemented threads its how
because i think i have confirmation that no bot is receiving thread events
also why tf can't I send ephemeral messages at will?
limited to interactions mfw
datsucks
Public threads are only useful to side-talk about something in chat
ie someone said something in chat and you wanna talk about it, but can't do it in general
But yeah it's pointless to make private threads accessible to tier 2...
Yeaah
if they want people to like it at least make it easy to implement
instead of dispatching a "thread delete" event every time the client loses access
this happens
const { appID } = require("../config.js");
module.exports = {
players: {
data: {
[appID]: {
queue: [],
}
}
}
}
``` hey anyone know's how do I push and pull data from that queue array
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
can you please don't bump it that way?
"no we dont send you thread delete events, youll have to use context to figure it out"
yourthing.players.data[appid].queue.push()
.push() works in mongodb offical package?
wut
push is an array operation
your code doesnt say anything about mongo
oh my bad, I forgot to tell it's the data structures for my mongodb document
what's the inverse of pop()? poll()?
like, pop removes first element, what removes last element?
pop removes the last element
pop removes the last element
shift removes the first one
unshift adds an element to the beginning
ah yeah, gotta think like a stack
add element to end is push(), how sad 😦

could be push/pull
in js, the opposite of push/pop is unshift/shift
i was about to type 
do I need any extra lib for buttons, or discord.js can handle it out?
buttons are supported in v13/master
in v12 you need to either use a library or implement them using raw events
i don't recommend 3rd party lib
most people use discord-buttons
just use dev version
tim do you know there is https://npmjs.com/discord-reply
how does that work exactly?
yes someone else was asking me about that
listen to the raw event for INTERACTION_CREATE, then use client.rest to send the response
no
nope, raw events are not documented
its not public thing
i can show you my code tho
also tim, it is client.api
oh, I see
well, if you don't mind that would help me
this you put on your main file?
yes
ok
and in my interactions function i have
and my createButtons makes the button structure
that you can find in the discord api docs
just one more thing, this code is in what file?
holy hell
anywhere
just use v13
so it can be on the main file?
yes
nah fuck v13
why
im using it in dev too
plus the caching changes screwed me over
i have to redesign djsl around them, which i didnt do yet
anyone good at flask
do we need djsl now

i'm using flask for a log system
basically, my bot creates a html file and saves it to a folder. I want people to be able to login with Discord and if their ID is on a list of allowed Id's, they can access the html file
is there any need for that
yeah, i don't want unauthorised users to be able to access the html file
Is there a type that's similar to Map except I can just have 2 keys and no value? I'm trying to associate a server id and user id together, but there might be multiple entries of both. I'm thinking Map<string[], string> except I don't know what do put in the value portion of the map
can't you just send the html file in dms is what i was implying
a Set is basically a Map of keys
there is no get(), only has() and delete()
i mean true, but its a moderation bot which multiple people will be there working on it and it will be hosted on a url
like i have it on backend.(botdomain).xyz and its just login redirect looping atm
seems like you want a proper dashboard then
so the login feature works, its just looping and I need help with making it not loop
not just generating html files
an html file by itself has no backend
you need the backend to verify the authorization before sending the contents
i know but i am currently restricting access to the directory with discord login
i'm now looking at discordbotdash module
so you can read the file into flask, then send the file as text from flask
if the user is authorized
it isn't really a proper way to do it
don't generate html files in the first place
One message removed from a suspended account.
do SSR with flask or create an SPA that makes calls to your backend api
One message removed from a suspended account.
/hug
you need a /login endpoint and a /auth endpoint,
the /auth should return an object of the user or a 401 error, the /login should handle all the stuff and redirect you to the discord oauth page
SSR is essentially the same
the end result is
the process isn't
why in the hell would you save html files in a directory and then save/update them constantly
and then serve them
that makes no sense
you save the html template/unchanged parts
its never updated, it generates the html when i run the command
if you want to do that use a library like ReactJS
then serve it with changes
if all you're doing is authorization and nothing else, then you dont need SSR, you just send the entire unchanged html contents
after the proper authorization
N:\Desktop\ColdRP bot\node_modules\kurasuta\dist\Sharding\ShardingManager.js:85
this.emit(Constants_1.SharderEvents.ERROR, new Error(`Cluster ${cluster.id} failed to start`));
^
Error: Cluster 0 failed to start
at ShardingManager.spawn (N:\Desktop\ColdRP bot\node_modules\kurasuta\dist\Sharding\ShardingManager.js:85:64)
Emitted 'error' event on ShardingManager instance at:
at ShardingManager.spawn (N:\Desktop\ColdRP bot\node_modules\kurasuta\dist\Sharding\ShardingManager.js:85:26)
;-;
debug time!
ok
ok
I now have a set containing an array of 2 strings, as [userid, guildid], however when I use the Set.has([userid, guildid]), it's not seeming to find my entries. Anyone have an idea why?
you cant do that
Set doesnt store the contents of the array, it stores the reference to it
every time you do [a,b] you create a new array, so the reference will never be the same
unless you save the ref in a variable
a = [1,2]
Set.set(a)
Set.has(a) // true
you want to store a unique combination of user id and guild id?
Yup
Like... concatenated?
yes
its not always the same
Oh
Alright
Is it possible to run js stuff and inject it in the script before building the file in esbuild?
Astro does this but I want to do it with vanilla js
I'll try that out
a bigint will be much more memory efficient than string
probably yes. i never used esbuild, but most builders/packagers can be configured with pre-scripts and post-scripts
imma look for a plugin that does that
how do i make a discord.py bot panel lol
wdym bot panel
I'll look into the bigint solution in a little bit (no pun intended), but the string solution should do as a temporary fix for now. Thanks tim!
Spin up an http server that serves the html for the page
Add some javascript in the html to send the updated settings to an endpoint on your server
The server should update the settings in your db
i use json for storing data
I dont know python but flask seems like a good server
Is there a way to get typescript (or eslint) to require me to put semicolons? I seem to forget sometimes, and even though they're not necessary I like using them for consistency
just use prettier
It automatically puts semicolon everywhere
I have prettier, not sure why it's not doing that
You have to configure it in the settings. Just search for prettier
Or do
"semi": ["error", "always"]
in eslintrc.json
I suggest using this tho
"semi": ["error", "always", { "omitLastInOneLineBlock": true }]
eslint does work for me
idk it's what the doc says
https://eslint.org/docs/rules/semi
APA INI ANJAY
Got it to work, thanks!
np
Where u from:v
I'm from #general
will the Structures be removed in djs13?

yes it is already removed
wtf
ah yes structures fix: remove structures
the devs are saying, it is removed, and shouldn't be able to be imported now with djs13
but for some reason I'm able to do
I'v cleared my yarn cache, tried deleting node_modules, but no luck
really though
Please don't remove Structures. My bot's entirely dependent on it. If someone adds something that doesn't work, its them to blame, not you. They should've known what they're messing with before updating the structure.
lmao
"please don't remove this so I can continue to incorrectly use it"
they can be useful, but yeah the disadvantages outweigh the advantages
Imagine storing your custom server prefixes in a mongodb collection
You'll only need to fetch the collection ONCE then djs will cache the prefixes because you extended Guild with a customPrefix property
you can store the prefixes in a map which is attached to your client instance
don't do that either, just pass a context to your commands that has all the data you need to run commands
everything that people did with structure extensions you can easily do without them
can someone confirm , if Structures been removed from discord.js@dev, bcoz for me it is still there.
yes it was removed lol
type CommandContext = {
client: Client,
message: Message,
db: Database,
prefixes: Map<string, string>
}
wtf ts bad!!!
just pass this around why would you need to fuck with the discord.js API just to check a prefix
why would you even need to pass prefix around after the initial check in the message event?
yep
I can still import and use it.
What do i do
vsc?
yes
delete djs and install detritus
Attaching the database instance to your client could be useful when you need it in an event rather than a command
you could create an EventContext too
vsc caches typings for dependencies
this is how you deal with problems like this in any other language
no, even the files are there
then you didnt update your dependencies
how would you do that tho
i tried these
i did to the latest
oh nvm just thought of a way of doing it
how did you do it
type EventContext = {
client: Client,
db: Database,
}
type CommandContext = EventContext & {
message: Message,
}
what's &
and
merges 2 types
use the github version
That's not what I meant by how would you do it, how would you replace the argument in the event
what if my code is on gitlab 
ur fuxed
I did this discord.js@dev
or macrohard excel
ok
const ctx = createContext({ client, db })
client.on("memberAdd", (...args) => f(ctx, ...args))
what is that code supposed to do
I'm talking about how you can pass around a context without modifying the discord.js api
adding random shit on top of client isn't the best either
yo how did you reply to my message before i typed it
you can keep all your stuff in a single client property object
basically lets you create a context that is passed around to every event handler as the first parameter
to keep it orgnized
but yeah you can also create contexts like that
more upkeep tho
why would i need that
you're essentially doing the same thing as Structures there and it's a pain to work with in typescript
I don't want to pass client everywhere if I don't need to
this way you can create different kinds of contexts and pass the things you need to different things
Most discord.js objects have the client attached to em
thats the thing, you dont need to. client exists everywhere inside djs
that solved my problem, but how?
because thats how you install master versions
not the way you did it
then y they say to install this discord.js@dev
what is the equivalent of window in node
the way you did it looks into npm for a version with that tag, which requires the devs to actually publish that tag to npm. and dev versions are not regularly published to npm, if ever
if you were executing a command and wanted to include the current command being executed in the function you would need to pass it as an extra positional argument whereas with ctx pattern you can just create a separate CommandContext that has a non-nullable command property on top of it that extends from a base context
that's just how I like to organize my programs I guess though
in short: discord.js@dev = the latest version that the devs explicitly put on npm
discordjs/discord.js = the latest version directly from github including the very latest commits
Up to preference, If I had a huge codebase I'd use the context pattern
but with a small bot I'll just attach everything to the client
I don't like mutating things because it's extra work to represent it in typescript
true, there's always the ! postfix tho
eslint has a rule against that operator by default
when Client gets created it doesn't have any of those properties, you just have to remember to add them and fool the typescript compiler into believing they exist when you try to access them
which is not an approach I like
contexts can be safely typechecked
#824411059443204127 message (on djs server)
here they were saying discord.js@dev should work fine.
well it didnt for you
and apparently they didnt know why either
or you did something wrong
i dont think so. I cleared yarn cache, than removed node_modules, reinstalled all packages again
did you actually run npm i discord.js@dev again?
or just npm i?
Is it a good idea for a bot to automod stearn scam?
probably?
O rly?
as long as people know the bot is doing it
IK. Now it filters swears and its said on bot's page
show where you defined graph
https://rust-lang-nursery.github.io/rust-cookbook/database/sqlite.html#insert-and-select-data Having a look at this code example, I presume that ?1 would refer to color.to_string() because it's an an array?
Collection of useful Rust code examples
yes
no it would not be an array
i dont know jack about rust but iirc that sql statement produces a single value for cat color
By array he means the parameter list is in an array and ?1 refers to the first element in the array
AH
Though, it could be shortened to just ? if the same value doesn't need to be represented in multiple parts of the query
Nekomaki. Who
heck, you can even give named parameters (https://docs.rs/rusqlite/0.25.3/rusqlite/struct.Connection.html#method.execute)
@ripe prairie
yes
I don't know why they rejected my bot for some emojis
Your bot's commands have emojis or gifs that could cause epileptic seizures due to its flashy and flickering nature. Please remove all content of such nature in your commands.
It means the emoji/gif your bot presents is too flashy/flickery.
e.g. a blob rainbow dance emoji
if you know what one I'm talking about
But you'll want to explain your issue in #support or contact a moderator via DMs.
I already contacted, I'm going to change them and wait again
Ooooo
That's best
Neat
Thanks a lot
Watch me corrupt my db within seconds
first time with docker 
what is docker useful for
u can use already configured docker container e.g. for db and they are pretty fast up and running
but thats probably not the best explanation for dockers advantages
Is it considered a privacy breach if I create a command to list the servers my bot is in (by name) as long as the command is only available to me, in a private channel?
if its only available to you then no
Alright
For some reason its not sending a webhook when i vote for a server any idea why?
What was the command to show on the status in how many guilds are the bot (discord.js)
client.guilds.cache.size
Ty
const x = "hello [go here](http//websitelink.com) blah blah [another link](http//websitelink2.com) blah blah"
i am trying to split out the markdown links, but this isn't working.
x.split(/\[.*\]\(.*\)/)
i need to use a different character set than .
can i say all characters besides [ ] ( ) somehow?
You can use [^chars] to specify any characters except for those specified in the Array (the ^ is necessary)
pub struct TimedCache<K, V>
where
K: Eq + Hash + Clone + Send + 'static,
V: Eq + Hash + ShallowCopy + Send + 'static,
{
state: RandomState,
internal_queue: DelayQueue<K>,
internal_map: MultiValueMap<K, V>
}
impl<K, V> TimedCache<K, V>
where
K: Eq + Hash + Clone + Send + 'static,
V: Eq + Hash + ShallowCopy + Send + 'static,
{
}
``` Ngl really wish there was a simpler way of defining large blocks of traits combinations other than super traits
My statistics bot is not receiving any messages coming from threads. Is there a way with discord.js to also get the message events from threads, not only from the main channels?
You'd need to upgrade to djs master and add logic to listen for thread related events
v12 does not support threads
or you use the raw gateway :)
you need to be in the api v9 to even receive events
shouldn't this work?
"hello [go here](http//websitelink.com) blah blah [another link](http//websitelink2.com) blah blah".split(/\[[.^\]]*\]\([.^\)]*\)/);
and even then someone here said they were on v9 and were still not receiving events from threads
so we dont know the current state of the threads api
v9 is a lil all over the place
nope. Does not work
I messed up my regex by mistake. This is the fixed one: /\[[^\[\]]+\]\(([^\(\)]+\))/
You can use this to make and test regular expressions. It's very helpful https://regexr.com/
and you shouldn't use split since it would remove the link
my isn't as helpful
i want to remove it and then put it back in, but as a react component
and make the strings react components too
[.] matches the . not all characters
then you can match the string with the regex I provided and string.replace(match[0] /* The matched string */, "") and then do something with the match[1]
If you include the g flag and don't iterate over the string, then you'd have to chain replaces
the split function will iterate for me
matching the string with the g flag will reduce the amount of iterations you have to do when using the regex against the string. Using regexs should be done sparingly
first i will get a list of markdown links. then a list of the text with links missing. then i iterate over the text and add back in the links
["[go here](http//websitelink.com)", "[another link](http//websitelink2.com)"]```
i want to get these two lists
then i'll make <React.Component>hello <React.Component2 href="asdfasd">go here</React.Component2> ... </React.Component>
there must be a way to do .split and .match at the same time
\[(?<text>.+)\]\((?<link>.+)\)
then just get named groups, "text" will be the text, and "link" will be the link inside parentheses
That regex doesn't work
the . matches outside of the bounds
does the most actual version of discord.js support threads?
FF doesn't support named groups
ah I see what you mean
you can still use numbered groups
Hey! Why did I get a message that my bot got approved?
those number groups are magic
My bot was approved for like half a year already or something
never pushed any other bot
If someone listed you as a collab, it probably DMs you about that as well
how would you explain regex if not magic?
Logical expressions
very dumb question, but I'm new to this. How do I determine the webhook URL for my bot?
like, I know where to enter it on my top.gg page, but I don't know what it should be
Once you create a route on your web server which is designed to handle requests from topgg, then you pass that route to topgg
ye
No lol. How is your bot supposed to know what to do if you don't provide any code for it
the bot is just a connection between your code and discord
the actual bot is the code
i have a bot, just dont know how to webhook lol
im still confused
Ah nvm, how bad can it be
Look into how to make a web server and how to handle topgg requests with their docs
a webhook is just a reverse api, you handle requests made to it
Topgg sends a request to your endpoint (webserver) and it will manage the request, for example running your code sending a message via your bot
if you setup a webserver together with your bot you can grab the requests directly and pass to the bot
do you have a link? I've been reading docs for an hour and obviously missing something. (this is what I've been reading https://docs.top.gg/resources/webhooks/)
what don't you understand
so I have my bot I've had for 6 months now but want to add this integration. what I don't understand is how to also setup a webserver for this top.gg integration
here
mozilla explains it well
like i know what a webserver IS, I just dont know HOW to easily set one up alongside the bot
you have a common misconception that your bot == your app
your bot is merely something you're using inside of your app
it isn't your app entirely
you can add anything you want into your app
your app just happened to run the discord bot as well
my understanding is the follow:
python code running on my AWS server is connecting discord API to send/receive requests.
How to efficiently do it which is scalable is to have the website be independent from the bot and then have some form of IPC like a websocket layer. and your web server would act as a coordinator for front facing requests
you what?
Or simply follow the docs and it’s examples to host the webhook service (webserver), importing your discord client to it, spawn a second instance and if a request comes from topgg, do whatever you want the bot to do
this is the best choice, allows for multi-process sharding as well. however if you can't afford to do that yet, taking the monolithic design approach where your bot and your webserver are running in the same app is fine
yeah definitely sticking the monolithic approach. but tbh this sounds kinda confusing I might just not integrate with top.gg
I assume I'd have to mess with something like Flask
or django
Not entirely necessary unless that's what you absolutely want to go for
all I want at the end of the day is getting notified when a user votes for the bot
my users keep asking me for vote command lol
(mainly cause they want free stuff lmao)
Fair... A simple back end server without any fancy front end should be more than sufficient to process that
It’s surprisingly easy, it really is.
the website logic should still follow what I suggested
How can i download node js raspberry pi
The package manager should offer node since node should support rpi
I can only download version 10.24.0
Then you'd have to build the latest version of node yourself or find builds online
is there a guide i can follow for how to set something simple up for this purpose in python?
Version of linux i can not
that's what ive been doing for an hour now
Then don't do top gg specifically. Get a basic structure laid out first and then try to adapt what the docs say to your structure
i guess ill ask just one more question: what python package do you recommend for this?
flask
I don't code in python, so I wouldn't know
awesome. I will move ahead with flask then thank you
The docs are providing the code for the webhook already.
All you need to do is to import your discord client and spawn a second instance.
what
donuts
And the is after that has gone as well 🤦♂️
ig if i have two word commands, should i keep the words separate, underscored, combined, or dashed?
up to you
Anyone know how to respond to button interactions using detritus?
Do I get the Bot Developer role when my bot get's verified on top.gg?
Wrong Channel sry
Thx 👍
in socket when trying to connect, how could i make that if the connection didn't worked:
do something
(python)
The connection object should return a state
idk how to see that, when i try to connect with the server offline it seems it's a windows error, it is in my language, not in english and also it stops the process
Well you could always try showing me
s.connect((host, port))
ConnectionRefusedError: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione
C:\Users\Eugenio\Desktop\hexye developing\automation>```
translation: Impossible to connect. Persistent refusal from the destination computer
Hi
Try except in your case
hi sir
Hi
hru sir
Nice
now how could i make an infinite loop so while except it try to connect again?
yes actually good idea
python
setTimeout
Oh F
You should probably use asyncio
so it doesn't block the rest of your code
then asyncio.sleep for the cool down
An async function?
asyncio is the async library for python
Well I'm gonna sleep bye guys have a nice day
Yh I know :D
gn
embed.image.url: Could not interpret "{'name': 'welcome-image.png'}" as string.
y tho
i give code once someone pings or somthn lol
oh look someones here
or just give it
how could i make the loop of the exception? because using While True would not break the exception when it connects
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage('link lol');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'welcome-image.png')
const welcembd = new Discord.MessageEmbed()
.setTitle(`Welcome to ${member.guild.name}, ${member}`)
.setImage(attachment)
message.channel.send(welcembd);```
have a global variable isConnected or something
me
me
sigh i didnt get help
you have no patience at all bud
and i need help with those issues
ctx.beginPath();
ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' }));
ctx.drawImage(avatar, 25, 25, 200, 200);
y does the begin path arc closepath and clip not work lol
I'm pretty sure clip doesn't work like that
Hello there deos anyone have a bot that when someone is banned by a bot or a user it displayes a message in a channel saying like user is banned for reason.
wrong channel
dang i just copied that part off of google
remove closePath
how can i add codeblocks in my embed description?
```language
code here
```
i tried that but it messes with the rest of the description and the bot cant start bc of it
then you're doing it wrong
like i only want certain words highlighted
do thread id's act the same as channel ids?
Yep, it is also a type of channel
ok
https://discord.com/developers/docs/resources/channel you can read this to get more infos
Escape the backticks with \
anyone know what channel_ids is supposed to represent in THREAD_LIST_SYNC?
(Assuming you’re using js, not sure how it works in py)
this is what the docs say https://discord.com/developers/docs/topics/gateway#thread-list-sync-thread-list-sync-event-fields
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
but i really dont understand its use
do events like CHANNEL_DELETE register for channels that the client cannot see?
seems like something to test yourself, people here will shout random answers at that.
ok
watchbot.app might be something you could be interested in.
Uptime of your own bot, right? You could save when the bot starts and stops in your db and calculate the uptime yourself. More hassle than it's worth imo. Especially the part where you save the stop time.
I use watchbot and it's pretty much what you're asking for; get the % uptime of your bot.
Or list your bot on discord.bots.gg. They add all their bots to their server and monitor their uptime % that you can see by using a command.
anyone how to get notification of my vote bot?
It's the parent channels which are being synced to the client. Those IDs can either belong to a News Channel or a Text Channel
Any general idea how I can stress test memory usage of my bot?
I don't I can just throw it to public for testing
Spin up a dev bot and add to large servers you have authority over and add the presence intent
or store user data in a db and then create fake message create payloads and fill in the user data with stored which you can fill from live and then your lib will cache those users
when syncing threads is member already included in the channel object or am i required to use the members field
^ I don't have presence intent, only ['GUILDS', 'GUILD_MESSAGES', 'GUILD_VOICE_STATES']
Users and Messages are what take the most memory
you could consider increasing the amount of messages your library is allowed to store per channel
you don't necessarily need a large server for that but it might be hard to write messages over and over
that why I ask on it since I dont think I can measure with me all alone spamming message
lol
client.sweepMessages(10 * 60 * 1000); djs master branch have this feature now, what I fear is the hidden one
this is what i have so far, i'm replacing channels in the cache if a channel is sent through the thread sync event
That's why I mentioned making fake message payloads and filling in with users you store in a database from live
The channel ID has to be real and cached is the only requirement for message create on Discord.js's end
you should also be making those fake message payloads for a guild text channel as DM channels won't work
Just so I'm prepared in the future... how many guilds per shard should I be using?
I just return when it is a DM, now the real question how am I executing it 🤔
The max amnt is 2500 before Discord says you can't connect. If you're a music bot owner, consider 1500. Otherwise, 2000-2500
Alright
Discord.js' web socket manager exposes the handlers for raw gateway events iirc
it does
listen for "raw"
unless they changed that, i havent used the lib since v11
For stress testing, it really depends on what you're testing and how it'll be used. I find it more efficient to calculate the cost of something ahead of time and see how that would scale in the future (like SQL's EXPLAIN clause) rather than trying to simulate the real environment and hoping it's accurate enough.
For a developer working on an algorithms library, it would mean reviewing the amount of processing your functions does. Maybe it looks fine at first until you realize it's n * n.
What step by step I should go? I think I can do test run online few days on my test server first? and does process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2) is suffice to measure it?
Use a benchmarking library
If node has one
It'll probably give you more insight than just standard calculation of the memory (and some console.time)
I need some help with my battery
My battery is having trouble charging. I've changed sockets and tried charging the phone in short blasts and it seems to be charging a bit better but still takes way too long. The problem ain't with the charger because my mom's phone (same brand as mine and older model) charges fine and WAY quickly.
Last night I put it on charge at 5% and I wake up to see it at 1%
I tried to clear off apps in the background but then my phone died
Specs
vivo 1173
FuntouchOS (vivo doing a great job at vendor lock in)
Help
ur phone is hacked
ngl
this.graph isn't defined, define the graph function before module.exports and call it using graph
You can still export it if needed
Will erwin lend me a free usbc charger for saying detritus rules?
this is a bit random
but does anyone know if thread sync event syncs only channels the client couldnt see before
this is because if not, then the event would wipe the message cache of channels which the client could see before the event happened
👀
Learn the ways of the discord bot library king itself, detritus!
lol
any suggestions on how to fix this?
imagine shilling for a lib

npm i request
request gud
ignore deprecation warning is good.
a 1GB install size is a small price to pay for request
/s
npm i is-odd
Well my Samsung had the same problem
It had fast charging but for some reason it stopped fast charging with original charger
I cleaned the charging port, bg apps nothing happened
So I changed the charging cable and it started working
But the old cable still works with other phones
Is it normal for my charger to just stop working bc I've had to change the charger way too many times
function isOdd(num) {
return /\d/.test(String(Number(num) / 2).split(".")[1])
}
want a very low memory usage bot?
npm i cloudstorm
learn raw gateway
npm i snowtransfer
learn raw rest
I only have one usbc charger




🗑️
Try changing the usb connector
huh ?
O no-
someone pls help in #topgg-api
Anyone know why my host (temporarily a free heroku dyno) is incredibly slow? I'm getting a response of about 2300ms when posting a simple message to a channel. On my local machine, the process takes only about 60mb of ram. Can heroku just not handle that, or is the connection on their end bad?
what does this error mean
How are these temporary messages made?
Well this may be because the server is way too far from the discord server (unlikely)
Or the shard is faulty
Or maybe you have a shitty code (also unlikely)
Because my Heroku has a 23ms ping
use flag 64 when sending slash command reply
yes, is it bcoz I hv set strict to true in tsconfig?
most likely
or 16 I don't remember
Can we do this whenever we want? Is it only valid for slash commands?
Anyone here hosted a bot using AWS? I need some help with connecting to an instance. It tells me to run these commands, but I'm on a windows pc, not linux.
Only valid for interaction responses, and yeah, it's 64
oh ok thanks
bot.on("ready", function () {
bot.removeListener("ready", arguments.callee)
})
so this wouldn't work in strict mode. What are other alternatives, other that using bot.once()
Anyone know anything about the buttons ??
How would I make the key not publicly available (basically a windows alternative to chmod)
const readyFn = () => {
bot.removeListener("ready", readyFn);
}
bot.on("ready", readyFn);
what's the point of that anyway
you just create a listener and then instantly remove it
wouldn't it be better if u didn't create it in the first place?
you remove it after the first time it's emitted*
is that replit
frees up memory
it does if you want to remove it only if a condition is met
ya lol
ok that's not a good reason
I want it to listen only once
then use .once
Not on your PC. It says there open your SSH client?
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'WaffleBot.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "WaffleBot.pem": bad permissions
myAWSserver: Permission denied (publickey).
That's the error I get when attempting to open an ssh client to it
It says to run chmod 400 WaffleBot.pem if I need to, but I can't do that without being connected to the server, as I'm running windows not linux
Got it to work
Followed a yt tutorial on how to do the equivalent on windows using icacl
also button clicks
How do I update node from a linux terminal window? I've tried this so far, but it keeps outputting v10.19.0 whenever I type node --version
Also throws this when I try to run my normal startup command
I'm gonna assume that's just thrown because of the outdated node version
Actually that's a slightly big problem, every npm command throws that error
Just tried uninstalling and reinstalling nodejs and npm, still throws that error :/
guys, how do i store a text with emojis in sqlite3 ?
does mee6 uses discord.js?
most likely no
then which popular bot uses discord.js?
Most popular bots use a custom library
Mudae
Okay wh-
new RegExp("git\+|\.git", "g")
eslint is telling me to remove the \ because they're unnecessary but they are not
You forgot to censor your IP in this screenshot, and the screenshot below.
Regarding that error:
You're require-ing semver somewhere in your script, so I guess do npm install semver in the directory where the package.json is
oh nvm
The IP is fine, whatever
But no, it's not an issue with my code
It's likely an issue with NPM itself
No I didnt say it's an issue with your code
I'm saying that you require semver in your code but it's not installed as a module
oh alright, what OS are you running on that VPS?
And what node version does your script need?
My script needs v14 or above (I believe that's when null-coalescing was introduced into node)
Alright, and which OS? Debian, Ubuntu, etc.?
Ubuntu
My current method of installing is running the commands as follows:
sudo apt-get update sudo apt-get install nodejs sudo apt-get install npm
However this is my first time ever using Linux, so I'm not entirely sure if that's correct or not
That itself is correct
But it may be that your current package repository doesnt have v14 in it
How would I get that to have v14?
If you're fine in copy pasting commands do this:
sudo apt-get remove nodejs && sudo apt-get remove npm && sudo apt-get update && sudo apt-get install nodejs && sudo apt-get install npm
Uninstalls both nodejs and npm, updates, and reinstalls
After that please go run
node --version and tell me if it works and what it says
alright that means your package repository is just behind
Let me get you the commands for v14
I'm getting the commands from here:
https://computingforgeeks.com/install-node-js-14-on-ubuntu-debian-linux/
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt-get update && sudo apt-get remove nodejs && sudo apt-get install nodejs
so he's using either <=ubuntu 18.04 or <=debian 8
First command downloads the v14 package repository URLs and puts it in /etc/apt/sources.list.d/nodesource.list
It's ubuntu 20.something I believe
cat /etc/*-release will show you your ubuntu version if you wanna know
20.04.2 LTS
I see...
Go do the commands from here which should install you node v14
Do what?
What you just explained
oh

Yeah the (official OS) package repositories are usually behind
Ohh
Perfect, node is now on v14.17.2
awesome
Great
Does your script now just work out of the box?
Yes
Not yet, still have to figure out how to add in env vars
Hmm
Is that something I should just create the file for manually or...
Yes you create the .env file in the directory where your script.js is
But you do have to install it first:
npm install dotenv
Yeah, I'll run npm install to get all my dependencies
ah alright so it should be mostly set up
Where did you guys learned this stuffs...I can just develop simple games with coding till now...
Probably easier to just manually create the env file though
Yeah
I'm using Linux for a long time now, I've seen alot and tried alot. Over time you just remember stuff "oh I did this before, so in order that it works I gotta do X"
i see ..
How would I manually create the env file in the terminal?
touch .env creates an empty .env file in your current directory
Or is that not a possibility
You can also use your favorite text editor directly
nano .env
vi .env
damn you AWS, not letting me copy paste my token...
I have to type it out manually, ugh
hold up
Wait a minute
Usually SSH client are: Right click to paste
yeah
If you highlight something and left click it, that usually is copy
depends on the ssh client tbh
I can just exit once I'm done editing the file right, or is there a keybind to save?
Which editor are you using? Nano?
Yeah
nano is:
CTRL+X
Press Y
Press Enter
Thank you
CTRL+X to close the file
Then it asks if you wanna save -> Y
Then it asks if the file name/path is right: Enter
hmmmm... it's decided to tell me that I still need a token...
Go check your script for process.env
Did you type the variable correct for the bot token?
The code is all correct, it works perfectly when hosting through VSC
Should it list the .env when I type ls -a?
yes
i do ctrl + s then ctrl + x
Okay, it's there
Oh yeah that also works
Not sure why it's not working
@wheat mesa If you do cat .env does it also show you the content?
Yup
Ok then go check your bot script where it logs in
Check that the variable in your .env is the same as in your script, case sensitive
or maybe, yeah no check that first
dotenv.config({ path: __dirname + '/.env' });
const prefixes = config.prefixes;
const startup = Date.now();
console.log('Starting bot...');
const commandClient = new CommandClient(process.env.BOT_TOKEN ?? '' // Other stuff after this doesn't matter
ok yeah and I assume you put BOT_TOKEN = 'asdf' in your .env file?
Yes
ok that should work then
Is the .env file in the same directory as this file?
err: if anyone joins to any server it is coming in my server smh
const canvas = require('discord-canvas'),
welcomeCanvas = new canvas.Welcome(),
leaveCanvas = new canvas.Goodbye()
const Discord = require('discord.js')
const client = require('../index')
client.on('guildMemberAdd', async member => {
client.guilds.cache.forEach(guild => {
if (!guild || !guild.id) return;
const Schema = require("../models/joinchannel")
Schema.findOne({ guild: guild.id }, async (err, data) => {
if (!data) return;
if(!data.channel) return;
let image = await welcomeCanvas
.setUsername(member.user.username)
.setDiscriminator(member.user.discriminator)
.setMemberCount(member.guild.memberCount)
.setGuildName(member.guild.name)
.setAvatar(member.user.displayAvatarURL({
format: 'png'
}))
.setColor("border", 'BLUE')
.setColor("username-box", 'RED')
.setColor("discriminator-box", 'GREEN')
.setColor("message-box", 'BLACK')
.setColor("title", 'YELLOW')
.setColor("avatar", 'PINK')
.setBackground('https://media.discordapp.net/attachments/847794443180048394/863973336035885056/wallpaper.jpg?width=1178&height=662')
.toAttachment()
let attachment = new Discord.MessageAttachment(image.toBuffer(), "welcome-image.png");
client.channels.cache.get(data.channel).send(attachment)
})
})
})```
Yeah that's what I'm thinking
Is your script in /src/? 😄
Perhaps 😅
Yeeeah
That would do it!
I'm gonna move the env
I really don't feel like pushing an update to the repo then grabbing it and all that stuff
mv .env src
mv is also used for renaming, fyi
mv .env hurrdurr renames .env to hurrdurr
Finally, it works!
👌
In your opinion, do you think pm2 or Forever is better for keeping the bot up?
tbh I never used any of those
Does your vps do it automatically?
start.sh
do
node discord-bot.js
done
Ah
A while loop to start the script when it exits 😄
But I started using pm2 on other projects and I really like it
I think I'll use pm2 because I'm lazy and want a module to do the work for me
and you can use pm2 plus (free version) to have a neat-o webinterface to remotely restart your bot (and more)
In case you didnt know 🙂
Stupid question, but is there a way to get out of this window without closing the terminal?
how did you start that: node bot.js?
npm start runs node -r ts-node/register/transpile-only ./src/index.ts
ctrl+c
alright so it's running in your current SSH session
My bot got declined even tho I have a help command. :|
The only way is like Tsukuyomi said is to kill it entirely with CTRL+C
Sounds good
You have to use something like screen, tmux or straight up pm2 for it to run in the background
Yeah, was just testing for the sake of my sanity lol
i use screen -S node
then i press ctrl + a then ctrl +d
when i go back i type screen -x node
oh right
Screen is a nice tool
When I run sudo npm install -g pm2 does it matter what directory I run it in?
nope it doesnt matter
Alright
cause you install it -globally
Thanks!
Wc!
Is there a way for pm2 to run npm start, or should I just have it run node -r ts-node/register/transpile-only ./src/index.ts
I dont have much experience in pm2 but I think you can achieve it by using a pm2.json start file
@wheat mesa your bot looks cool
Thank you 🙂
I think I'll make a start.sh script that runs npm start then run that with pm2
tbh a pm2.json is simpler than your approach
But if you wanna do it, make sure that your start.sh is executable after you create it:
chmod +x start.sh
pm2.json = ecosystem file
Looking at this (https://pm2.keymetrics.io/docs/usage/application-declaration/) I'm thinking I write something along the lines of this
module.exports = {
apps : [{
name : "app1",
script : "npm start"
}]
}
Is that allowed?
Either do it that way, then you have to create a .js file
or do it the way I sent up there, with a pm2.json
Why not pm2 start "npm start"
Do you have an eval command?
Nope
