#development
1 messages · Page 128 of 1
that code may not be isolated
wym
if you don't know debugging, this is a good time to learn it
starting from here #development message
nothing in console?
what console

by default it debugs only current file
go to your program's entry point and run debug there
that is the value of the variable
hit f5 to continue execution
observe on the left to see what changes
or you can use the watch tab
i don't
when it pauses at this staement, look at the console, see if they do get duplicated
did you even insert the breakpoint 
you can, in watch tab click on the + symbol
just tap f5 and watch how many times it hits console.log(rank)
did you open the debug console tab?
then check your terminal's console
nothing happens there
so it's happening within the function
well yeha
i said that awhole ago
awhile
i just don't know whats causing it
there is no jump statement
what is jump
so it could be something messing with the iterator, aka xp.rank
goto
there is a break
even that
that break should only escape the inner for loop
and does not affect the outer one
what could triggered a re-iteration of the last item hmm
hang on i have an exam now
@wheat mesa, @earnest phoenix if you have time, look at this
the last item of xp.rank gets iterated twice, there is no sign of the iterator being modified and the bug happened within the function
could be Array.prototype modification but that's very unlikely
i mean i think my code works but thats a weird issue
anyone can suggest me great hosting ? vps
yes
Depends on your budget
should I hash the data that being sended to client and then the client dehash it?
Please don't say hash and dehash
You can't dehash something
At least not easily
Are you perhaps referring to encrypting?
Depending on how it's sent, through browsers that's mostly done by https if used
yes, "hash" and "dehash" with base64 :^)
hey tim
starmie?
Tim weeb
unfunny
Funny
So who knows anything about embedded systems?
More wondering how I am supposed to run a machine learning thing on a microcontroller or how to make use of a ML model on a microcontroller
tbh I don't know much about any of this so if anyone has articles or videos they know of please link 
whats the maximum offset I should accept when handling 2fa codes?
currently I have it at 5min
i dont know if im allowed to discuss this topic
fuck it
depends on your language id use something like tensorflow lite but theres probably libraries which can do stuff like this for you and abstract it more
its optimised to run on limited hardware like risc arm (theres probably also a fork which is specifically optimised for your microcontroller)
Why would you not be allowed to?
digitalocean
i just get very enthusiastic when talking about stuff like this 😳
but its ok
There's absolutely nothing wrong with that :^)
digitalocean
i am having a problem with using slash command for my bot anyone can help or guide me please?
i am not able to see my bots pfp when i type "/"
reload client
happens to me sometimes too
Ok
Hm?
Definitely an interesting snippet but nothing is functionally wrong with it, which is a plus
enthusiasts are the best
const configuration = {
type: 'line',
data: {
labels: dataSort.map((d) => moment(d.unix_timestamp * 1000).format('DD/MM/YYYY')),
datasets: [{
label: 'Guilds',
data: dataSort.map((d) => d.server_count),
backgroundColor: 'rgba(54, 162, 235, 0.6)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 2,
borderRaduis: 5,
borderSkipped: false
}]
},
options: {
scales: {
y: {
beginAtZero: false
}
}
}
}```
I find this graph quite "ugly" is it possible to make the max number higher so that the lines go down a little?
chart.js
so like, you want the graph to go from 0 to 100? so it looks smaller?
there is a method in chartjs in your config or plugins called xAxis, which allows you to set a max value
setting that will expand the chart till that point, doesn't matter the values you have in it
yeah
Open source HTML5 Charts for your website
seems old, sec
Open source HTML5 Charts for your website
that one
not working 
using suggested, or min/max directly?
oh wait
i'm using an old version because I couldn't get it to work on one of the new versions
which version are you using
could check how that was in that version back then
still good to update nonetheless
I'm just looking to update but I don't know what caused the problem.
well nothing I see, everything is up to date and it works haha thank you
Anyone knows where can I get a year hosting for postgressqll?
I mean if there are free options also pls suggest
most web hosts support postgres
so you can probably pick up some dirt cheap hosting
that would give you a panel to access it too
Hostinger?
Then?
i think https://railway.app does cheap postgres
What's the cost?
Hello! I'm new with webhooks so do bear with me, I've set up a Flask app in Python and created a tunneling service(?) i'm not sure what it's called using ngrok. I'm using the forwarding url as the webhook url to pass through the test data and my Flask app is receiving it.
How do I trigger the event on my bot whenever I send the test data? Do I need to setup webhooks as well on my discord bot or is there a way that the topgg api can send that data directly to my bot without setting up webhooks on my bot?
@spark flint where the option
Aaaaa
there's a library for that otherwise, https://docs.top.gg/libraries/python/
your retirement savings
I'm not entirely sure how to use the python library in this case, I already have installed the library on my discord bot. I copied the example on webhooks and changed .dbl_webhook("/dblwebhook", "password") to .dbl_webhook("/") because I don't have an authorization set on my bot's webhooks settings, and the route on my Flask app is set to it's root (hence only "/"). But I don't see the print(f"Received a vote:\n{data}") on my discord bot console
you need to set the authorization on the dbl_webhook
have you also set your publicly accessible url on your bot page webhook settings
yep, i can receive the test data on my python app that handles the webhook
so that should work then?
I'm not sure why it's not working, I'm still not receiving any prints on my console
how can you tell the test data is actually received by your bot
also, can you show your whole function that has the print statement in it
because theres 2 types of functions that handle voting, one is the one that handles the actual votes, and then theres one that handles test votes coming in, which you need a separate case for
@bot.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")```
yeah on test, seems fine
I'm not sure how to see this, but I do know my webhook is receiving the test data since it's printing out the json object
where is it printing it out? do you have a separate route set on flask?
yes I have a different terminal running flask
are the routes the same or what have you done
from flask import Flask, request
app = Flask(__name__)
@app.route("/", methods=["POST"])
def hook():
print(request.data)
return "Data received"
if __name__ == "__main__":
from waitress import serve
serve(app, host="127.0.0.1", port=5000)
This is my whole flask app
is that running along with the library?
with my discord bot? no
thank you tho
Do i need to place the token somewhere too?
nah
could it be because I have my client setup like this?
bot = commands.AutoShardedBot(shard=2,command_prefix="!", intents=discord.Intents.all())```
what do you think is a better format for recording match results.
Option 1
#1 @player1 @player2 #2 @player3 @player4
Option 2
@player1 and @player2 placed first, @player3 and @player4 placed second
does it have to be in the same line?
lmao
should i have different commands for recording 1v1, 2v2 etc?
how about ```js
First Place:
@player1 @player2
Second Place:
@player3 @player4
and then optional third and forth and so on
ye
First Place:
@player1
Second Place:
@player3 @player4
that's a 1v2
or ```js
First Place:
@player1 @player2
Third Place:
@player3
how does it know if it's a team or people are drawing?
can you have 1v2 teams?
can players score individually even if they belong to the same team?
i have 5 different rating types. one is an individual player rating
Combined Team
Combined Player
Distinct Team
Distinct Player
Overall Player
so when you score players individually, the team doesnt need to be factored in:
First Place (tie):
@player1 (team X)
@player2 (team Y)
Third Place:
@player3 (team X)
First Place:
@player1 (team X)
Second Place (tie):
@player3 (team X)
@player5 (team Y)
First Place (tie):
team X (@player1, @player2)
team Y (@player3)
Third Place:
team Z (@player9)
i always score players individually, but i only score them as a team if they are a team
I see, never thought about something like that
a 1v1v1 is different than a 1v2
or you prefer something more like this? ```js
team 1
#1 @player1
#4 @player2
#2 @player3
team 2
#3 @player4
#6 @player5
#5 @player6
is this saying people on the same team came in different placement?
i dont let that happen. same team gets the same placement
then the third option from the previous ones
parens around the teams?
maybe have like 5 team inputs and 5 placement inputs. might be a bit more cumbersome for 1v1 gametypes though
team 1: @player1
team 2: @player2
placement 1st: team 1
placement 2nd: team 2
maybe the bot could ask if the user is recording an ffa match, or a team match first and then follow up
2v2
First Place:
(@player1, @player2)
Second Place:
(@player3, @player4)
2v2 tie
First Place:
(@player1, @player2) (@player3, @player4)
ffa with 2 ties
First Place:
@player1, @player2
Third Place:
@player3, @player4
but yeah really just depends
but you should avoid using machine learning or try to get whatever you want processed done on another machine like through internet or something
although it is very fast but you need to pretrain the model on a desktop first
Well with my project I can't really avoid ML
I'll likely just use websockets or something to relay data back and forth between the client (being the microcontroller) and the server.
Idk how well that would work performance wise
with what you're building I don't see how you would do that given the issue of an internet connection
plus sending visual data like that is really expensive
you'd probably want to try to do the processing onboard, but idk much about this
Yea that is what I was thinking to, but idk much about it myself either
its an option, one I don't want to take
Running into such an odd issue, spent a day or so trying to find the issue however I am clueless;
name: Could not interpret "{'name': 'axodouble-21', 'type': 'GUILD_TEXT', 'topic': 'ticket|244173330431737866', 'parent': '985654630652469318', 'permissionOverwrites': [{'id': {'guild': '750209335841390642', 'icon': None, 'unicodeEmoji': None, 'id': '750209335841390642', 'name': '@everyone', 'color': 0, 'hoist': False, 'rawPosition': 0, 'permissions': '109951162777600', 'managed': False, 'mentionable': False, 'tags': {}, 'createdTimestamp': 1598934243880}, 'deny': ['VIEW_CHANNEL']}, {'id': '818499512410701845', 'allow': ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'ATTACH_FILES']}, {'id': '244173330431737866', 'allow': ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'ATTACH_FILES']}]}" as string.
{'name': 'axodouble-21', 'type': 'GUILD_TEXT', 'topic': 'ticket|244173330431737866', 'parent': '985654630652469318', 'permissionOverwrites': [{'id': {'guild': '750209335841390642', 'icon': None, 'unicodeEmoji': None, 'id': '750209335841390642', 'name': '@everyone', 'color': 0, 'hoist': False, 'rawPosition': 0, 'permissions': '109951162777600', 'managed': False, 'mentionable': False, 'tags': {}, 'createdTimestamp': 1598934243880}, 'deny': ['VIEW_CHANNEL']}, {'id': '818499512410701845', 'allow': ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'ATTACH_FILES']}, {'id': '244173330431737866', 'allow': ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'ATTACH_FILES']}]}
And I have checked through, but only issue I have is that it cannot interpret the channel as a string, I am confused and honestly just lost.
well
it says it cannot interpret the channel as a string
like, thats the full channel object
if you want the channel name, get the name from the object, dont pass the full channel object
i have a command with a subcommand with an autocomplete string option but for some reason interaction.isAutocomplete is never becomes true in my interactionCreate file, i see there has been quite a few updates since last time i worked on djs so might be just some simple changes but cant seem to find out what
@sharp geyser what microcontroller are you planning to run it on?
i heard tensorflow lite runs very well on raspberry pi/arduino (full ones) and can do video processing like classification and object detection
but really depends on hardware and capabilities like vector processing instructions
rpi and arduino are basically mini pcs tho so it kinda doesnt count
Heya guys so what am i supposed to use on node to mess around with images like add watermarks etc etc
canvas?
lel
i mean, for simple image compositing, you can try sharp
It's not gonna be too simple i guess
i have to make sure the watermark is dynamic etc
canvas is only really needed if you need full drawing capabilities
ah then yeah i guess you need it
it's gonna be a pain
you should try writing your own image processing code bc there isnt a library for me then come back to me 💀
canvas is finnicky but its okay
real
i used it back in 2019
when i knew none about coding
it took like 40 seconds for a little processing
do you need to do anymore processing other than a watermark?
So basically i wanna fit the watermark in the four corners and in the middle
without the watermark cutting off
cutting off?
like only half of the image
yes
in the corners or in the bottom
and basically i want it very dynamic no matter the size of the pic
is the watermark an image or text?
image
by pic you mean the image youre watermarking?
yes
and you want the watermark to adjust its size based on the image size or something like that?
yep
fully dynamic
first you probably need to work out the size of the watermark image, probably can just do some multiplication and then resize the length and height based off that
but to make it fit you need to calculate the pixels used by the watermark and offset it at one of the corners so it never cuts off
sounds more complicated but easier in practise
something like watermarkStartOffset = rightBottomCornerX - watermarkLengthInPixels - someValueSoTheresSomeSpaceBetweenTheEdge
getting pixel length of image tho uhhhhhhhh brb
okay
you literally just do imgElement.width / imgElement.height and id imagine canvas recognises the width and height as pixels
assuming youre using browser js
This will be done through a bot
so you're using node canvas and stuff like that?
I haven't fully started it yst
But prolly something using node
I will start it tomorrow
Which npm do u suggest
yeah it's the same image.width / height
node-canvas is the only one I know and probably the only one
it's annoying to install sometimes because it uses hardware acceleration and c++ stuffs so the build can fail sometimes and you may need to do some debugging (if you're unlucky)
sure please do!
Lets hope i am in the lucky side
Either a rpi or arduino
I’ll also need to find a camera module to use
yeah you'll be absolutely fine using tf lite
20 different libraries which wrap around doing this sort of thing
what kind of rpi board do you recommend?
honestly depends what you'll be doing and what kind of video processing you're doing
but I'd say at the very least one of the computer ones that have like proper cpus and not one of the microcontroller ones
because for video processing I don't think you even have enough ram for that
I’d prefer something small as they will be attached to glasses
bro what are you cooking lmao
Don’t worry about it 
even the microcontroller ones are pretty big you'd really need like a custom designed circuit board for stuff like that
Yea well time to just make my own board

honestly your best bet is to have a tiny microcontroller board like the nordic and have it connect to a central controller that does the actual processing wordlessly
wireless delays might be an issue tho
Won’t there be latency issues
With the thing I’m doing it’s quite literally a matter of life and death
yeah esp since these tiny boards have limited computing power so they can't push as many bytes over a network as a computer cpu
Don’t want deaths because of my project
It’d have to be something capable of doing it onboard to limit latency to a minuscule amounts
what kind of ml are you planning to do on video anyways and what kind of resolution of the video camera
Mostly object detection and text to speech to start out with
what I would do is get as small of a powerful controller as I could and maybe for the time being having a cable run off it into your pocket or something so you can get your inputs or something from the glasses
maybe later try to improve and get it more integrated
I see
that's heavy computationally, tts can probably have a bit of a delay so you should get Google cloud or something like that to do speech recognition over a network so you have as many resources as possible for ml
ram is also a concern
but honestly it's just playing around and see what works
After a ml model is trained it isn't that expensive computationally to get a prediction but that all depends on size of data
I mean the stuff would be done in real time at a constant rate
Or that’s the plan anyway
The plan is to be able to identify everything in frame and if the frame moves to then identify everything in that frame
you're going to at least need a very generous delay between predictions but you'll need to test it in action to see how much it can push
machine learning jargon wise you'll need to have a model optimised for limited hardware
ones that have less layers and neurons and faster activation functions at a trade off on a little worse prediction accuracy
but it's usually not a deal breaker
As long as it doesn’t mistake a fence for a dog I’m fine

Anyways thanks for this information I’m heading to bed now
If I ever get around to it I’ll look at my options
well anyways you can always ping me and I can help if I have time :)
Tyty
im not that strong on machine learning but I have experience with limited hardware and environments like that
this might be interesting and may actually let you do this kinda thing on a powerful enough microcontroller https://github.com/tensorflow/tflite-micro
I'd try getting it working on desktop and normal tensorflow and getting comfortable with it before moving to more embedded and fit for purpose stuff like this
Oh yea for sure
I have a webcam idk if I can use that temporarily
To attempt object detection
yeah definitely you can feed input from that into your program
Bet
hey guys i have the trainer.py, i am trying to access the model.py however my fucking math isn't found when i use Model/model.py.
i know it is because it's in the resource folder, and that i need to use my whole path file.
however, i don't want to do this, as i want my teacher to be able to run it as well, and else the file path will be coded to my own pc's absolute path
the opposite
<class>.getResource("path/relative/to/current/file") or <class>.getClassLoader().getResource("path/relative/to/root")
the "whole path" wont exist once you create a jar, as it'll be packed inside it
using resource accessors is the correct way of interacting with that folder
(Also trying to dynamically read metadata about directories inside of a jar is like fucking impossible, so make sure you’re not trying to get file names dynamically unless you’re down to beat yourself up)
Got back to developing my bot from 2 years ago, first launch gives me this:
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Missing Access
Any idea why?
what is this error?
/home/container/node_modules/discord.js/src/util/Util.js:361
const matches = url.match(
^
TypeError: Cannot read properties of undefined (reading 'match')
at parseWebhookURL (/home/container/node_modules/discord.js/src/util/Util.js:361:23)
at new WebhookClient (/home/container/node_modules/discord.js/src/client/WebhookClient.js:49:22)
at Object.<anonymous> (/home/container/src/index.js:74:21)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
I'm only getting it on linux, not mac
could've not deleted it the first time
url is undefined
thought i could fix it, but then realized its only happening on vps. on local, the same code is fine
show where ur defining url
if (global.config.webhooks.error_logs.enabled) {
const logs_hook = new WebhookClient({url: global.config.webhooks.error_logs.webhook});
const embed = new EmbedBuilder()
.setTimestamp();
process.on('uncaughtExceptionMonitor', (err, origin) => {
embed.setTitle("Uncaught Exception Monitor")
embed.setDescription(`\`\`\`${err}\`\`\``)
embed.setColor(`#FF0000`);
logs_hook.send({embeds: [embed]});
})
process.on('unhandledRejection', (reason, promise) => {
embed.setTitle("Unhandled Rejection")
embed.setDescription(`\`\`\`${reason}\`\`\``)
embed.setColor(`#FF0000`);
logs_hook.send({embeds: [embed]});
});
process.on('uncaughtException', (err) => {
embed.setTitle("Uncaught Exception")
embed.setDescription(`\`\`\`${err}\`\`\``)
embed.setColor(`#FF0000`);
logs_hook.send({embeds: [embed]});
});
}
it's not there
I get this now: A private-application can't make us of a default authorization link
oh wait, it's inside webhook client
Oh, you have a private app. Yeah.
mhm
His error is inside of djs itself
global.config.webhooks.error_logs print this
also, wouldn't recommend the usage of global
Try updating your djs version
How do I solve?
it is updated. What happened is I decided to update some npm packages, and then restarted my vps and the whole thing broke
Exact same code working on my local mac though
which is weird
what are u trying to do? login the bot?
did u update djs?
got no clue haha
nvm 14.11 is latest ;-;
ye I just did cuz I forgot my token
but I replaced it
so no worries
that shouldnt be the issue
its not a wrong token
hm, show how ur instantiating the client
private setup(): void {
console.log(chalk.keyword("orange")("INFO") + " | Setting up the bot...");
// Variables
this.ready = false;
this.database = new Keyv(this.topazOptions.database);
this.profileHandler = new ProfileHandler(this);
this.dropHandler = new DropHandler(this);
this.experienceHandler = new ExperienceHandler(this);
// Setup the base events for the client
this.setupBaseEvents();
// Setup the commands
this.setupCommands();
// Setup the contextmenus
this.setupContextMenus()
// Setup the events
this.setupEvents();
// Login!
this.login(this.topazOptions.token);
// Load all item files.
this.loadItems();
console.log(chalk.keyword("orange")("INFO") + " | Logging in...");
}
this this this this
ye it's old code
I'm gonna redo the whole thing
but I need to get this to work first
put login before everything else
none of the interactions will work if the bot is offline
at least above this
same error
but preferrably, before anything else
are u running it locally?
ye
does the error show the line where it ocurred?
C:\Users\Yarne\Desktop\Topaz\Topaz\node_modules\discord.js\src\rest\RequestHandler.js:350
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Missing Access
at RequestHandler.execute (C:\Users\Yarne\Desktop\Topaz\Topaz\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at RequestHandler.push (C:\Users\Yarne\Desktop\Topaz\Topaz\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at GuildApplicationCommandManager.fetch (C:\Users\Yarne\Desktop\Topaz\Topaz\node_modules\discord.js\src\managers\ApplicationCommandManager.js:108:18)
[nodemon] app crashed - waiting for file changes before starting...
Whole error
hm
run the app in debug mode, put a breakpoint in your entrypoint
step line by line until the error happens
see if it's really happening at login
alr
oh wait
yeah it's happening during slash registration
it must happen after client login
put await before login
so it waits for bot to come up
and put the login line in the start of the function
ye its not happening during login
yes, because it's not waiting for login
login is an async operation, without await it'll simply keep going before login has finished
didn't fix it
show current code
private async setup(): Promise<void> {
console.log(chalk.keyword("orange")("INFO") + " | Setting up the bot...");
// Login!
await this.login(this.topazOptions.token);
// Variables
this.ready = false;
this.database = new Keyv(this.topazOptions.database);
this.profileHandler = new ProfileHandler(this);
this.dropHandler = new DropHandler(this);
this.experienceHandler = new ExperienceHandler(this);
// Setup the base events for the client
this.setupBaseEvents();
// Setup the commands
this.setupCommands();
// Setup the contextmenus
this.setupContextMenus()
// Setup the events
this.setupEvents();
// Load all item files.
this.loadItems();
console.log(chalk.keyword("orange")("INFO") + " | Logging in...");
}
do u have anything in the outer scope?
ye it's a 500 line file with different things to set up stuff
events, contextmenus, etc
see if anything is running before setup
but it shouldn't cuz it's the first thing that's called
it's an async function, are u awaiting it?
oh 🤦♂️
yk, part of the reason I dislike js async
ye well
it's kind of annoying to make it await
cuz it's called in the constructor
constructor(options: TopazClientOptions) {
super({
intents: new Intents(["GUILD_MESSAGES", "GUILDS"])
});
if (!options.commandsDir) options.commandsDir = "commands";
if (!options.eventsDir) options.eventsDir = "events";
if (!options.development) options.development = false;
// if (!options.development && !options.database) throw new Error("Database not found while in production!");
// else if (options.development) options.database = "mysql://topazdev:NKw1rb8A17zf3VK@144.172.75.142:3306/topazdev";
this.topazOptions = options;
this.inDevelopment = options.development;
// Setup the client
this.setup();
}
but then again
it's the only thing called
so nothing else should run
let client = new TopazClient({
token: process.env.BOT_TOKEN,
commandsDir: "./commands",
eventsDir: "./events",
contextMenuDir: "./contextMenus",
database: process.env.DATABASE || undefined,
development: process.argv.includes("--dev"),
devGuildId: "867781117126115328"
});
In my bot.ts
which is what runs when I run the bot
remove setup from the constructor, call it after constructing
make bot.ts an async scope
u mean make the whole bot.ts async?
async () => {
let client = new TopazClient({
token: process.env.BOT_TOKEN,
commandsDir: "./commands",
eventsDir: "./events",
contextMenuDir: "./contextMenus",
database: process.env.DATABASE || undefined,
development: process.argv.includes("--dev"),
devGuildId: "867781117126115328"
});
await client.setup();
like this?
ig so
ye it doesn't work
make sure there's nothing outside that scope
no
btw
hm
u should be able to await in the outermost scope without using an async function
but well, it isn't ran because u never called it (u made it a function)
()
() => { ... }()
lemme check how people are making their bots in djs
try making a barebones starter, to see if it even logins
start putting the methods again one by one after that
yw
the trick is making anything else only happen after login
u can use something like client.login(token).then(() => doeverythingelse())
you got a repo of a handler someone made with new discordjs by any chance?
so u dont need an async outer scope
nope
cuz I only have knowledge from 2-3 years ago
by handler do u mean command handler?
yeah and events and stuff
ah I thought I forgot something
I hate how most langs are adhering to that async shit
ye still missing access
people bash java for java try { asyncFunction().get(); } catch (InterruptedException e) { ... } but are fine with having to change the entire upstream for a single await
yeah it has to do with the slashcommands
the handler is very likely trying to use the client for registering commands, but it cant yet as it's not logged in
but the handler for registering slash commands called in my ready event
hm
you wanna see the handler?
did u add the slash scope?
it sais A private application cant make use of a default authorization link
no no
go to url generator instead
default url is for this
which makes no sense for priv bots
select bot and application.commands
access the url even if the bot is already in ur server, to update the scopes
same error
now give slash permission to ur bot in the server
and check if the handler isn't trying to register slashes to the wrong server
those guilds also need to update the scope
ye I don't know which guilds these are
make it leave them then
I just make it leave all the guilds?
or filter all where the id is not yours
ye same error
I'm getting annoyed
if (typeof devGuildId === "undefined") existingCommands = await this.application.commands.fetch();
else existingCommands = await this.guilds.cache.get(devGuildId).commands.fetch();
this is the line where it errors btw
is that in your code?
yes
log what devGuildId is
I changed it to this existingCommands = await this.application.commands.fetch();
and it still errors
but devguildid is my guild's id
867781117126115328
it's not allowed to fetch the commands
I'll need to defer this to someone else, if you added the scope and permission I dont see why it'd error
is it weird that the bot does not appear on the integrations tab in the server?
did u select the correct server when adding the scope?
ye
just for removing all doubt do it again
see if the server still appears in the dropdown
same code, different tokens?
Pfff, maybe tupperbox is just good, maybe it doesn't need more functionnalities. So i'm ending the work of my bot Better Roleplay. Ask me in DM if you want to see the code/reuse
kick the bot and reinvite
not my private application?
it's not under this tab on my dev panel
but thanks for the help
kick the bot and reinvite, maybe it's discord caching getting in the way
this will force a full refresh
alr ty now it's time to figure out why none of the commands are being loaded...
it worked?
the kicking
havent tried yet
hold up
nope
it really is the bot
if I use a different token it works
you could go deeper to see what's the difference between both bots
that way it'd at least not be a total waste
ye well I should've started studying for my math exam 45 mins ago
so maybe I should go do that first
eh
I'm just confused rn why my commands aren't getting registered
they're being loaded
but not registered
if they're being registered globally it might take a while for them to appear
added scope and permission?
really have no idea in this case
oh nvm I found the issue I think
if you have an error in your comand if it gets called it doesn't get registered right?
idk, but probably
ye thats probably the issue cuz I don't have a db connected to it rn
but ty for the help
time to study maths now
is discord.js v15 gonna release or be a thing?
there's usually a website similar to this https://discordjs.guide/additional-info/changes-in-v14.html#before-you-start but for v15 but i cant find it
likely
simply because of this warning
istg bro if youre using discordjs you better be developing your bot 24/7 because you cant just forget about the bot and update it every once a while bc discord js has to break something with a new update
kinda discords fault too
where are the changes' docs
there's usually a website to view the changes they've made
migration docs only appear when they're about to release an official version
this is also in core not in discord.js
wait so what's the difference between:
my bet is that they'll modularize d.js
in a way that you can choose what u get
stupid design as they already dumped 2 major breaks this year alone
poor bot devs having to migrate for a third time 
What is this? I've never seen this interaction failure before. 😂
https://cdn.hamoodihajjiri.com/iJIAcIw0Xo
Just greys out everything with no failed or something.
I have no idea, I've just never seen an interaction return blank and grey out.
And only you can see this response
Shh, it's a secret! Ephemeral Messages are a new way for Discord bots to send you a private message without having to send you a DM. You may have received this kind of message before from Clyde, an...
Yes.
They've been on discord for a good year now 
👀 is that your bot?
Nope.
I see nothing in the discord api changelog about it
Well, I have no clue what that interaction return is in the first place. 😂
I'm not sure if it means the interaction failed or what.
I wouldn't think that's what it means, super weird
Ah, just tried the same command from an alternative account, it's an ephemeral message.
However, it's not displaying its contents for me.
an ephemeral failure
no no, I was joking
lmao
Never heard of that. 😂
Like I wonder if they just put a zero width space or something?
Honestly, poke the bot dev and ask 👀
failed to show the error I guess?
Yikes, it doesn't even return the ephemeral message on browser as well.
It had to have responded then right?
Since that was less than three seconds
Yes, but it didn't.
do you know what it looks like? a discord issue
LMAO, unfortunately. 😂
all commands are ephemeral (nobody can see the command message, only the result of it), so I think something gone really bad in their response endpoints
basically got stuck between "command answered" and "render to clients"
try opening discord in the browser and seeing if any error pops in the console
why is postgres doing this? its a float btw
Nope, no errors.
dont use floating points for currency
what should I use
integer
I need 2 decimal precision
round it
u don't, simply multiply by 100 and do whatever u want to do
39.99 can be represented as 3999
if u buy an item for $ 1.65 for example, and have a balance of $ 100.00, u can simply 10000 - 165
floating points are not only slower but also much more prone to rounding errors
Maybe you'll find this helpful.
hm, that means it's failing to delete the command message probably
POPOUT_CLOSE is likely the event related to hiding eph messages
what about the built in money type?
that's an option too
personally I'd just use int as it's supported by all databases
yeah, I dont really want to process any data before sending it to the user, I do all of it in the query
it's not really processing, all you'll do is balance / 100 for adding the 2 decimals
yeah, but then id add like 10 lines for each time I send user infos
???
im passing the query result directly to the user
yes, but it's literally changing 'Balance: ${balance}' to 'Balance: ${balance / 100}'
internally you'd just use integers
Im not in a discord bot
regardless
you can use money type sure, but it's needlessly adding more database processing to your queries
alr, found a neat way of doing that int stuff but is it any faster than money?
I got this db query:
SELECT
'key'
FROM
keyv
WHERE
\`key\` LIKE 'keyv_user-%'
Querrying this into the db itself using mysql workbench works like it should but when I make my bot query this it gives me error:
const localErr = new Error();
^
Error: Unknown column 'key' in 'where clause'
at PromisePool.execute (C:\Users\Yarne\Desktop\Topaz\Topaz\node_modules\mysql2\promise.js:369:22)
at C:\Users\Yarne\Desktop\Topaz\Topaz\node_modules\@keyv\mysql\src\index.js:32:42
at C:\Users\Yarne\Desktop\Topaz\Topaz\node_modules\@keyv\mysql\src\index.js:45:19
it could be reading as key LIKE 'keyv_user-%'
but I got these `
it could be the column doesn't exist, idk
idk much, sorry
money is internally a bigint iirc, with additional processing for converting to 2-precision before returning result
almost nothing will be faster than INT
It exists tho cuz it just fucks up if I query through code
money is also less space-efficient as it has a bigger ceiling
League of legends player mindsets be like
that's your average DPS mage main
see if the produced query is different from test query
it could also be possibly the db engine interpreting it differently, or some query pre-processing is in the way
0/10
mathematicians: clearly 0
programmers: can be optimized to 0
statisticians: impossible odds
league players: jUnGlE dIfF
tf since when was that a datatype
always has been
in SQL
actually data type is "Currency"
in postgres it's unironically called money
hi development
im going to try postgre today
wish me luck
also guys I have another question
are we supposed to guess your question 🤔
I don't have my magic ball on me at the moment
look
I sent
^^^^^^
@pale vessel
This number type turns 3 today
https://www.crockford.com/dec64.html
what number type
unsigned decimal floating point looks like
I am using framer motion for an animation but the exit animation is not working only enter animation is working i don't know why
<AnimatePresence initial={false} mode='wait'>
<div className='notification-container'>
{notification && (
<Notification
data={notification}
/>
)}
</div>
</AnimatePresence>
------------------------------------
<motion.div
className='notification'
data-locked={false}
initial={{ opacity: 0, y: -50 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -50 }}
drag='y'
dragConstraints={constrained && { top: 0, bottom: 0 }}
dragElastic={{ top: 0.2, bottom: 0.0 }}
dragMomentum={false}
onDragEnd={(e, info) => {
if (info.offset.y < -50) {
setConstrained(false);
Func.remove();
}
}}
Which language?
Well… seeing as framer motion is designed for react, I’d probably say javascript/typescript…
you mean hosting a websocket or using a one
the exit doesn't work?
that might require the motion component to be a direct child of AnimationPresence for it to work
so why don't you try
<div className='notification-container'>
<AnimatePresence initial={false} mode='wait'>
{notification && (
<Notification
data={notification}
/>
)}
</AnimatePresence>
</div>
AnimatePresence itself doesn't render into actual dom elements so don't be afraid of layout changes
yeah that was the problem tysm :)
does somebody know why im getting this error with this
const Discord = require('discord.js');
const Canvas = require('canvas')
exports.run = async (bot,message,args) => {
const canvas = Canvas.createCanvas(540, 500)
const ctx = canvas.getContext("2d")
const target = message.mentions.users.first()
if(!target) return message.channel.send("Please mention someone.")
const bg = await Canvas.loadImage("https://i.imgur.com/zb20YGY.jpeg")
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height)
const avatar = await Canvas.loadImage(target.displayAvatarURL({ extension: 'png' }))
ctx.drawImage(avatar, 100, 100, 200, 200)
let atta = new Discord.AttachmentBuilder(await canvas.toBuffer(), { name: 'gayshark.png' })
let embed = new Discord.EmbedBuilder()
.setImage(`attachment://${atta.name}`)
.setColor("#B468FF")
message.channel.send({ embeds: [embed], files: [atta] });
}
exports.help = {
name: 'gayshark'
}
its image manipulation
looks like imgur is rate limiting you for sending too many requests for the image
const bg = await Canvas.loadImage("https://i.imgur.com/zb20YGY.jpeg")
what i would do is download the image then reference the file so you dont have to contact imgur servers for it each time
besides you should load the image outside of the command anyways its a waste loading it each time a command is ran if the background is always the same
You can also clone the canvas
Ideally you would download it, but you can also just use ctx.save and ctx.restore too.
ie;
// at the top of the file
const canvas = Canvas.createCanvas(540, 500);
const ctx = canvas.getContext("2d");
const bg = await Canvas.loadImage("https://i.imgur.com/zb20YGY.jpeg");
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
ctx.save();
function run(ctx) {
ctx.restore(); // this will restore ctx to the saved state
const avatar = await Canvas.loadImage(target.displayAvatarURL({ extension: 'png' }))
ctx.drawImage(avatar, 100, 100, 200, 200);
//use the image as normal
}
imgur ratelimits are a bit strict iirc
12,500 per day if you're using an api token it seems, which they are not using
very generous and graceous of imgur 🙏
can ip ratelimits even be relied on anymore
i think they can be changed and masked so easily now automatically
id have to ask some colleagues at work
noted on my agenda
imgur rejects datacenter IPs now
returns 429 even if not ratelimited
its annoying asf
💀
Why not use cloudflare?
for what
the world if rate limits did not exist and everyone was abiding in harmony and respecting limits
Without ratelimits, there'd be no internet
They're necessary so everyone gets their fair share, if ur hitting yours you're doing something very wrong
For images for example, you're supposed to cache 'em
that's why the world would look like the above if everyone lived in harmony
bot.topggpy = topgg.DBLClient(bot, toptoken, autopost=True, post_shard_count=True)
Give me this error
TypeError: DBLClient.__init__() takes 2 positional arguments but 3 were given
Am I doing something wrong? this is what the pypi page porvides as an example
You're passing 3 arguments to something that's expecting 2
Press ctrl space to see what's wrong
@lyric mountain is there any way to get Intellij to format a file with a quick shortcut (kind of like a VSC formatter when you save a file)?
Ctrl alt L
I think, tbh it's mostly muscle memory at this point
Press shift twice and type format, see what shortcut is it bound to
👍 thanks
U can set it to autoformat ig, see settings
Type format in the searchbox (settings), see the results that pop
how do i use an api if cloudflare keeps denying me
Depends, what's the reason for your block?
If u received the 24h ban, trying again will only make it worse
it's cus it's not suppose to be public
but i wanna use it
Then you simply don't
why
Because you're not the main character of the world
If someone doesn't want you to use something, you don't
Do note cloudflare bans are ip-bound
it's not a ban
Yet
😮💨
You need to learn when to take the L and abide to the rules
but i see other people doing it
and they openly share it in their Discord server
and mods don't do anything
so i think it's fine tbh
What api is it
🙃
why is puppeteer taking forever to install
Yk, I saw a ton of "most rewarding" streaming platforms
kick is pretty big tbh
None survived very long, or are long forgotten in a moist corner
considering the ass changes Twitch is making it might overtake them
Doubt
😵💫
Buddy, I heard that countless times already
Don't even remember their names
I long stopped livestreaming
btw
do you know if it's normal for puppeteer to take a long time to install
usually packages don't take this long
Puppeteer uses a whole browser internally
When you install Puppeteer, it automatically downloads a recent version of Chrome for Testing (~170MB macOS, ~282MB Linux, ~280MB Windows) that is guaranteed to work with Puppeteer. The browser is downloaded to the $HOME/.cache/puppeteer folder by default (starting with Puppeteer v19.0.0).
is this why
As I said, a whole browser
Wait until you see the ram usage
i wanna use it to access the api
Because scrapping is impossible without a browser
You will need to cope with the ram usage
how much is it
i'll be doing a lot of stuff
You're paranoid about 100mb, expect at least 5 times as much depending on your usage
That's lowballing tbh
Especially if you access many pages quickly
is that with a lot of stuff?
Browsers cache pages and assets
Chrome regularly go into gigabytes of ram, headless will be smaller but not much smaller
ok wow
it works
i can now access the api
const puppeteer = require('puppeteer');
const url = 'https://kick.com/api/v1/channels/';
const fetchUserStats = async (user) => {
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
await page.goto(url + user);
const stats = await page.content();
browser.close();
return stats;
};
(async() => {
console.log(await fetchUserStats('adinross'));
})();```
@hushed robin you can actually make puppeteer use an existing browser
you don't have to use the one it provides
wot
Remembered it, nimo tv
One of the supposed "most profitable gaming livestream platforms"
Dead 3 months later
Nimo was also different
All the 94667 twitch killers were different
In the end of the day twitch remains
Except you barely started using it
Usage accumulates over time, it won't be high from the get-go
ok
do i need to access different pages everytime to see the full ram usage
or can i just access the same one
Just let it work for a few days
I don't care, you want to see peak ram usage you're gonna wait
Like your brain in its own echo
This is why I never believe in "X is the new killer of Y"
He doesn't know what cache is
and Mixer tried taking over Twitch in it's peak
Twitch is literally being clowned on rn
🤑
i do
stop capping
i learned a few weeks ago
Buddy if clowning was a reason of a platform death reddit, discord, youtube, facebook, instagram, tiktok, etc would be all dead
what is this conversation bro 💀
The docs say it takes more than that
i think its something to do with positional args and keyword args
but im only passing 2 positionals?
Can anyone please tell me how can I display nitro badge if a user has nitro, and also if he has booster badge how can I display that also. And, how can I display only nitro badge if the user is not a booster but have nitro?
(in my bot's user info command)?
Please tell!
there's no way to check for a user's nitro state using a bot token
for boosting level, you could find a property for that under guild member
though it wouldn't match the one shown on your client since that would be their longest boost
dang it
dont just start using keyword-based arguments
you'd need to do the same with bot, toptoken too
python is weird
actually it makes sense just only if the error was clearer
dont mix keyword and positional
Python trying to be special by being one of the very few programming languages that allow keyword arguments
Mostly slow because it’s a stack based VM which requires a lot of memory shuffling shenanigans in the bytecode instructions. It also doesn’t JIT afaik
Currently looking to restructure my files for discord bot any suggestions to make this more organized?
├── Delete.js
├── LICENSE
├── README.md
├── app.js
├── bot.js
├── checkOptions.js
├── commands
│ ├── count.js
│ ├── help.js
│ ├── ping.js
│ ├── play.js
│ ├── setinvitechannel.js
│ ├── setjoinmessagechannel.js
│ ├── setleavemessagechannel.js
│ └── voteSkip.js
├── config.js
├── database.js
├── features
│ ├── countingGame.js
│ ├── inviteTracker.js
│ └── musicPlayer.js
├── index.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ └── styles.css
├── secret-key.json
├── slashCommands.js
└── views
├── about.html
├── dashboard.html
├── index.html
└── login.html
- use a consistent naming convention (
Delete.jsshould be nameddelete.js,setinvitechannel.jsshould be namedsetInviteChannel.js,secret-key.jsonshould be namedsecretKey.json, etc.) - I personally do this since it'll look much more organized: move all your code to the
srcfolder to make your project root not cluttered (an example: https://github.com/cheeriojs/cheerio)
src is the way
I love src so much
one of reasons why I'm not a fan of golang
src folder is not really a convention for go
I particularly like java's default structure of src/java and src/resources, I use it for everything I do when I can
if I have more langs in a single project, src/<lang>
having all assets inside a dedicate folder makes everything much cleaner
java feeling the need to make projects start with com. or net. or whatever for no fucking reason
It’s convention
java is just bad 
It’s a legacy thing, it doesn’t really matter a ton but it’s definitely conventional
Java is great until you try to do graphics
My dude that’s an optimization mod for minecraft
Doing graphics from the ground up in Java sucks
only ever made guis with swing 
OpenGL is difficult to do with Java efficiently because of the garbage collector, there’s a ton of memory fuckery you have to do with it, LWJGL makes it a bit easier but still
hey
i had a hosting related question..
so how do you all host your bot's 24/7 rather than Heroku, idk cuz i dont have a credit card with me
well, most of us have credit cards
i tried install it
i'll test later
idk
they do, it redirects to .com
lel
ask to use your parents
using an extension likely
vscode does not have it built in
ok
swipes parents on the card reader


