#development
1 messages · Page 2016 of 1
put both in the same div


err....did u remember to set a maximum height?
💀
honestly its just easier
instead i have to scan the whole string for a "end of data" character or whatever
because it may be clamped
like, it's probably stretching to whole page
u need to define a maximum size for it
there are two ways to solve the problem, either use delimiters, or use a length prefix
both
server adds a length header to the beginning of each packet, client reads the length header, then reads length data
im using c++ as the server and js as the client
you see im making a server based database from scratch for my programming project
im using c++
my condolences
i was gonna use c originally until i realised there are no namespaces or built in map headers
lel
not sure i can exactly do that
to receive data on the c++ server im using recv
hold on
it takes in a buffer and the "maximum length" i presume parameters
then the buffer gets populated
i can settle for a delimiter but i want to avoid that
tho there comes up another issue
what if transmitted data accidentally contains the delimiter
dont know how i would do that
especially since my tcp knowledge isnt 100%
is there a nodejs example somewhere
is there really not a protocol or at least a flag which allows TCP not to be a "streaming" protocol
its a pretty demanded feature
i mean
you literally add something to the data itself
for example, if you have a buffer of length 200
you send buffer([200]) + buffer
like
define how many bytes you want to reserve for the header
do you mean prefix the data with the size
yeah
lets say your header is always 4 bytes
so you write the data size in those 4 bytes as a unit32
then follow it with the actual data
same thing to read it, read the first 4 bytes as uint32, then read X length
sounds good
and to add a terminator for each data (for example when printing a string) i can pretty much separate the data by 0 and add a check like if (buffer[end_of_data] == 0 && buffer[end_of_data + 1] != 0)
oh no
well i kind of do
a lot of functions dont accept the length of data
they rely on the terminator
and if you dont have one it will just keep reading
are you using null terminated C strings?
then read X length and add a null terminator yourself
yeah but i might overwrite a clamped packet by doing that
which is why its probably a good idea to end each transmission with an explicit 0 from the client
you want to avoid buffer copies?
then yeah i guess
i can also use the length of all the data transmitted to determine if theres a clamped packet
so i dont have to rely on checking the buffer for additional data since it contains data from previous transmissions
and i also dont want to clean the buffer each time
yeah i can but meh
you need to treat the incoming data as a stream
while data is available check if available length >=4, if yes X = read uint32, check if available length is >= 4 + X, read from offset 4, set offset to 4 + X, while data from offset 4+x is available, repeat...
the lengths will tell you about the sizes of the messages, there is no need to check the buffer contents
yeah figured
worst case scenario to simplify things I'll just malloc packet sizes and use memcpy
with safety checks of course:)
don't want any buffer overflows
use pointers
and move them through the stream
well i've never done this with c++ so idk how it works exactly
but i did it in js
yeah no worries I have everything planned in my head
I've manipulated raw data many times before (dont ask how)
xD
out of curiosity how does c++ give you the data?
does it give you pieces of malloced buffers?
or pointers to stack arrays?
you create a buffer of your own size somewhere (I chose 1kb) - you then provide the buffer pointer and size of buffer to a function which blocks until data is available
not sure what happens when packets exceed that buffer size (will try tomorrow)
ah i see
they should be throttled
if no more buffer is available, the stream will pause until space becomes available
ie download speed drops
if a single message is bigger than the entire buffer, then you probably need to copy + free until you assemble the entire thing
not sure if two clamped packets will still be clamped if the buffer size is exceeded
if not I can just return an "exceeded size" error
is clamping sending side or receiving side
actually I'd imagine the receive function would return an error status code if that happens
tcp has no knowledge of your packets, it only knows the tcp protocol packets, which are set by the MTU or some shit, so it can give you 1 packet, 2 packets, or 1.5 packets, or 0.5 packets at a time
The absolute limitation on TCP packet size is 64K (65535 bytes), but in practicality this is far larger than the size of any packet you will see, because the lower layers (e.g. ethernet) have lower packet sizes.
The MTU (Maximum Transmission Unit) for Ethernet, for instance, is 1500 bytes. Some types of networks (like Token Ring) have larger MTUs, and some types have smaller MTUs, but the values are fixed for each physical technology.
great no clear answer 💀
I hate the low level world
so I should generally set the buffer size to 64kb just to be safe?
well I don't know what happens yet when the function size is exceeded
TCP deals with segments instead of packets. Each TCP segment has a sequence number which is contained inside a TCP header. The actual data sent in a TCP segment is variable.
There is a value for getsockopt that is supported on some OS that you can use called TCP_MAXSEG which retrieves the maximum TCP segment size (MSS). It is not supported on all OS though.
tis why I love him
interesting
I can use the size from that function to malloc a nice buffer
generally its better to have a larger buffer
if your buffer is too small, you will need lots of copies to rebuild the message, and the low level api needs lots of additional book keeping
in theory, the more memory you can reserve for it, the less work it needs to do
also, im pretty sure it uses circular buffers, so for example if you give it a buffer of size 500, and you receive 3 messages of size 200, on the third message it will need to clear the first 100 bytes from the buffer to continue writing
if you give it a buffer of 8mb, you can write a lot more before it will start overwriting the beginning
we'll find out tomorrow 
and I don't think so in this case
the function is way too simple to support that
unless it requires you to call it multiple times
goodbye for now 🙏
see ya
8.5.0 Wth
because data[0] is undefined, not logo1
well if there isnt logo1 to begin with, it shouldnt continue with the rest of the code
but there is logo1
logo1 is undefined
and there is logo1.data
well thats not what the error says
one sec
oh bruh it just returns empty data
k ill just make it return if there is no logo.data.data[0].imageUrl
log in?
Already solved it by removing the command and node module xd.
how to make your bot record when someone joins a vc? discord.js
Record?
Tos moment
privacy moment 😑
why dont you do that with any recording software and get arrested that way instead
no? what person would do that
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
sounds like a pain in the ass
One message removed from a suspended account.
One message removed from a suspended account.
I mean I made I whole thing to stop my bot from crash and send to a channel
I think I can do this
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
thats quite easy
One message removed from a suspended account.
One message removed from a suspended account.
not really I didn't want to use the npm called discord-error-handler
what?
almost every npm package meant for discord is either crap or really easy to do
One message removed from a suspended account.
idk bored
yeah, why not a dicksword bot
good idea
why not a betterdiscord plugin
- these are extremely different concepts
- that is VERY easy in comparison to retrieving voice data and outputting it into something that humans can understand
but if you're up to the challenge, go for it
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
and probably nobody can help
One message removed from a suspended account.
Ok so i dont know if this will make sense but on my site i changed the background, it wouldnt change so i made a new folder and it worked. Whenever i try to switch the name of the folder back to the original name it dosnt work/stays the old background even tho that link isnt in the code at all
what
join vc if you can its really hard to explain
<link rel="stylesheet" href="style.css" />
or you can look in the background specifically and search for its selector throughout your projrct to see how it's defined
there might be multiple stylesheets
i already did all that when i move all the files from one folder to another one it works like normal
ok
quick question, my bot is updated to v13 with slash commands but im getting discord api error missing access when bot trys register commands and i dont know if there is any solution to fix this ?
give it access
bot has on every server permissions
https://fuckfuckgoogle.com
easy search
i check it already it says that bot need to have applications.commands scope, so that means bot need to rejoin every server and there is no other solution??
yes
intresting
so how other big bots have already implemented slash commands without that scope.. like mee6 etc?
unsure but i had to have my bot rejoin all the servers
🤔
anyone else do crap like that? randomly name every day items to be more informative? 😄
Discord has already run a script giving all bots who have posted commands application.commands scope in all guilds a while back
EnvironmentProcessorSingleton
AbstractEngine
Visuals
Motors
Main
fr 💀
yea the stack overflow filters are not good.
holyshit so ugly
Probably an April Fool's thing...
wait if i see that with 3d glasses, will it become normal?
The pain will expand into the third dimension
Yeah technically it should
I've made 3D stuff like that before it's pretty simple
@quartz kindle yeah it just spreads the message across multiple packets
Oh
dont use .map
@quartz kindle hlep
js aint low level so
how would i add a 16 bit number to the start
im using something like await client.write("test");
client.write(Buffer.from([byte1, byte2]))
byte1 = number >> 8
byte2 = number & 255
you can do Buffer.concat(Buffer.from([byte1, byte2]), Buffer.from("test"))
concat accepts a uint8 array
ye
but this isn't a uint array :(
you're using browser js?
actually yeah i'll use a uint array its easier
i'll make a fixed size uint array
but how would you convert the string to that format
instead of iterating manually
TextEncoder
but Buffer.from is much faster
ah right i can use that
thought so thank you:)
whats up gamers 😘
How do you use mongodb for economy system data saving.
give your mongodb user objects some properties like this
use some methods like this:
then save.
How could I make a string of characters with the same length? Ex.
// Given the following:
let name1 = "I exist."
let name2 = "hello."
let wins1 = 2654;
let wins2 = 13;
// Format the text to be the same length:
let leaderboard =
"1. I exist | 2654" +
"2. hello | 13"
;
// My goal is this:
let leaderboard2 =
`1. ${name1} | ${wins1}` +
`2. ${name2} | ${wins2}`
;
// Returns the format of leaderboard.
${name1.padEnd(10)} | ${wins1.padStart(10)}
setTimeout(() => {
function alert(message) {
var wrapper = document.createElement('div')
wrapper.innerHTML = '<div class="alert alert-pink text-white' + ' alert-dismissible" role="alert">' + message + '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>'
alertPlaceholder.append(wrapper)
}
if (alertTrigger) {
alertTrigger.addEventListener('click', function () {
alert('Dashboard is under construction')
})
}
}, 2000);
timeeout not working
🥲
anyone can help
heyhey could anýone help me with a unban command i really ran out of ideas how i could do it :')
show code
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.send(f"*Unbanned*: {member.mention}")```
I tried this code from the internet because mine was a bit yk messy
and it shows me an error like
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: not enough values to unpack (expected 2, got 1)
you shouldnt be doing this with username and discriminator
you should be using user id
Why does discord.js rename something with every update?
welcome to djs

I've been using discord.js since v11 and had to rewrite my bot with every new update lmao
they wanted to separate an incoming embed object from an outgoing embed
thats why i quit using djs lol
I saw a video on youtube called now switch from discord.js to eris and I think I'm convinced lol
thank you very much this helped me a lot
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
lmao
One message removed from a suspended account.
do slash commands then
One message removed from a suspended account.
switch to raw api. Managed libs suck. Change my mind
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
https://cdn.discordapp.com/attachments/751966421101182996/959499575708745808/4.PNG so what do you think about it lmao
One message removed from a suspended account.
this one is just dumb, no defense possible
:^)
if you can, move to webhook interactions and get rid of the websocket altogether
and use a raw http server
that way you wont ever need to update again
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I still have a need for my websocket, so I pipe all my interactions down the socket instead of needing to scale and load balance the http server handler
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
penis
One message removed from a suspended account.
your dockerfile is super out of date
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
ahh ok lol
weird coding
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
more message listeners
One message removed from a suspended account.
did you ever receive a message by chance? 😄
more more more
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
idk i think the first one you linked
One message removed from a suspended account.
One message removed from a suspended account.
it should remember users first random guess
so it will always quote that size
then people could use it to flex if they had a big one 😂
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
yea thats what i mean, just save which user id has which size 😄
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
why did you rewrite things in c#?
i love mongodb, but ive been toying with the idea of using sqlite and sequelize for a db solution in the concept idea im building for my next app 😛
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
fair enough. i've been learning a bit of c# in a class ive been doing, seems decent enough to write
One message removed from a suspended account.
not terribly ugly to write with i mean 😛
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
be in awe of my nub c#
wrote that after my first c# class, lecturer still hasnt caught up with the concepts i used there. learning is way too slow in classes lol
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
no
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
if it was 'should' then the compiler would enforce it
it is an option, that is widely used, to be fair
One message removed from a suspended account.
One message removed from a suspended account.
i've never had any warnings for it 0o
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
oh yea I know it says that in the conventions, but its still optional
its just thats what the creators/maintainers of the language would preffer
unless the language explicitly enforces it, its optional
granted, if your writing some code thats being submitted to a well used package, you should conform to that packages standards/conventions as each may be different
but if your writing code for your own personal projects, that may never be seen by anyone, write it the way you want. as long as the language allows for it, and its not incredibly ridiculous spaghetti
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i've seen very little js conforming to those standards
One message removed from a suspended account.
2 space indentation? what? lol
One message removed from a suspended account.
One message removed from a suspended account.
yea fair enough, some ide/extensions will enforce standards on you
html
There is no “easiest” language
And html is not really a programming language :p
If you’re a beginner, start with javascript or python
How do you know he’s speaking about programming languages?

got ya ass
Fair
Also isn’t it better to check for null with the is operator?
Or is that just syntactic sugar
no idea on that one lol, it could very well be better
hey, what're your thoughts on this and how can it be improved?
how's it confusing
Why is the user who "joined" repeated three times and features in the title? Assuming the invite is scoped to the guild, why state the guild? Was the invite provided as an option (if so, is the link necessary)? Assuming the footer time is the time the command was run, why bother stating that when Discord implicitly tells the user?
There are other things I think are unnecessary but purely for ascetics/style so don't have much of an issue with, such as stating the bot in the footer.
Was the invite provided as an option (if so, is the link necessary)?
i was told that having the link there would be better
better?
BTS bot? 🗿
using djs? or just making a request to it?
You can store the webhook’s id in a database so you know which webhook you want to use when you fetch the webhooks in a channel
can i ask about mongoosedb here?
sure
how can i do this but so i can have as many user arrays as i want and rename have user as any name i want? js const breederSchema = new mongoose.Schema({ _id: mongoose.Schema.Types.ObjectId, guildId: String, user: Array });so the object ends up looking something like this { "randomname1": [ "wyv", "giga", "pt" ], "randomname2": [ "rex", "owl" ] }
One message removed from a suspended account.
is that understaneble?
One message removed from a suspended account.
it is?
One message removed from a suspended account.
how
oh dear
One message removed from a suspended account.
I don’t think storing previous names is against ToS as long as the user has a way to delete it or opt into it
i want my database to look like the second codeblock
One message removed from a suspended account.
One message removed from a suspended account.
Unfortunately I don’t believe so
and i want to have the option to have any amount of users
You could probably use autofill to give suggestions on IDs
I’ll look at the docs rq, but I don’t believe there’s an option for slash commands
.addChannelOption(option => option.setName('channel').setDescription('Select a channel'))
that?
Oh there is I just saw in the docs
Interesting
Must be relatively new, can’t remember seeing that the last time I worked on bots
Need help
const puppeteer = require('autocode-puppeteer');
const url = context.params.event.content?.split(' ').slice(1).join(' ').trim();
if (!url)
return lib.discord.channels['@0.2.2'].messages.create({
content: Please provide url of the website, \.getweb <url>`,
channel_id: context.params.event.channel_id,
});
let browser = await puppeteer.launch();
let page = await browser.newPage();
await page.goto(url, {
waitUntil: 'networkidle0',
});
let screenshot = await page.screenshot();
await browser.close();
return lib.discord.channels['@0.2.2'].messages.create({
content: `,
channel_id: context.params.event.channel_id,
file: screenshot,
filename: 'screenshot.png',
});```
Need to make this ckmmand
Just Fri nsfw
Plz hel0
Help
What
ik, it just makes it a bit more compact and im used to seeing it like that now so its fine
I need this command to be sent just in nsfw channels
Then check if the channel is nsfw before running your command
What library is that?
What library
Oh
Ya
That explains it
?
Not sure how to help you then, never used auto code and I never plan to :p
I’m gonna have to stay far away from sites like that
But yeah
Not to mention the top.gg scraping incident
Yes
Much easier
And you actually learn useful things
Without autocode
wtf is autocode
you live under a rock
the future of discord bots
the new glitch
the new botghost you mean
hi can someone help me in HTML / CSS code for top gg ?
inspect element
i write a code and its fine in editor but when i save it, it doesnt show it and the problem is from my code so i dono
how ?
if it doesnt work then its your code issue
i know so i need some help to fix my code 😅 cause i dont know where is the problem
i dont know the code either
i can send it in your dm
Collecting discord.py
Using cached discord.py-1.7.2-py3-none-any.whl (786 kB)
Using cached discord.py-1.7.1-py3-none-any.whl (786 kB)
Using cached discord.py-1.7.0-py3-none-any.whl (786 kB)
Using cached discord.py-1.6.0-py3-none-any.whl (779 kB)
Using cached discord.py-1.5.1-py3-none-any.whl (701 kB)
Using cached discord.py-1.5.0-py3-none-any.whl (699 kB)
Using cached discord.py-1.4.2-py3-none-any.whl (692 kB)
Using cached discord.py-1.4.1-py3-none-any.whl (692 kB)
Using cached discord.py-1.4.0-py3-none-any.whl (692 kB)
Using cached discord.py-1.3.4-py3-none-any.whl (676 kB)
Using cached discord.py-1.3.3-py3-none-any.whl (676 kB)
Using cached discord.py-1.3.2-py3-none-any.whl (676 kB)
Using cached discord.py-1.3.1-py3-none-any.whl (676 kB)
Using cached discord.py-1.3.0-py3-none-any.whl (676 kB)
Using cached discord.py-1.2.5-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.4-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.3-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.2-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.1-py3-none-any.whl (655 kB)
Using cached discord.py-1.2.0-py3-none-any.whl (654 kB)
Using cached discord.py-1.1.1-py3-none-any.whl (649 kB)
Using cached discord.py-1.1.0-py3-none-any.whl (648 kB)
Using cached discord.py-1.0.1-py3-none-any.whl (648 kB)
Using cached discord.py-1.0.0-py3-none-any.whl (648 kB)
Using cached discord.py-0.16.12.tar.gz (414 kB)
Using cached discord.py-0.16.11.tar.gz (412 kB)
Using cached discord.py-0.16.10.tar.gz (412 kB)
Using cached discord.py-0.16.9.tar.gz (412 kB)
Using cached discord.py-0.16.8.tar.gz (412 kB)
Using cached discord.py-0.16.7.tar.gz (411 kB)
Using cached discord.py-0.16.6.tar.gz (409 kB)
Using cached discord.py-0.16.5.tar.gz (408 kB)
Using cached discord.py-0.16.4.tar.gz (408 kB)
this happens when using topggpy==1.4.0
bros spamming 💀
and?
it breaks
sry
wdym "break"?
whats the error?
bot.topggpy = topgg.DBLClient(bot, dbl_token)
TypeError: __init__() takes 2 positional arguments but 3 were given```
Ignoring exception in command 'play2':
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
return await self._callback(self.binding, interaction, **values) # type: ignore
File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 524, in play2
await interaction.response.send_message(embed=[song])
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\interactions.py", line 595, in send_message
params = interaction_message_response_params(
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\webhook\async_.py", line 485, in interaction_message_response_params
data['embeds'] = [embed.to_dict()]
AttributeError: 'list' object has no attribute 'to_dict'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'play2' raised an exception: AttributeError: 'list' object has no attribute 'to_dict'
``` I'm struggling to figure out how to fix this I'm currently using Discord.py version 2.0a
can you show the part of the code that is erroring?
a message just below urs
await interaction.response.send_message(embeds=[song])```
what does [song] contain?
a embed
can you print it?
embed = (discord.Embed(
title='Now playing',
description=css\n{0.source.title}\n'.format(self),
color=0x02020).add_field(
name='Duration', value=self.source.duration)
set_thumbnail(url=self.source.thumbnail))
return embed```
That's not the entire embed
so that is [song] (discord.Embed(
title='Now playing',
description=css\n{0.source.title}\n'.format(self),
color=0x02020).add_field(
name='Duration', value=self.source.duration)
set_thumbnail(url=self.source.thumbnail))
Ya most of it at least
i feel that this is not a list
So what do I need to do?
no idea
class Song:
__slots__ = ('source', 'requester')
def __init__(self, source: YTDLSource):
self.source = source
self.requester = source.requester
def create_embed(self):
embed = (discord.Embed(
title='Now playing',
description='css\n{0.source.title}\n'.format(self),
color=0x02020).add_field(
name='Duration', value=self.source.duration).add_field(
name='Requested by',
value=self.requester.mention).add_field(
name='Music By:',
value='[{0.source.uploader}]({0.source.uploader_url})'.
format(self)).add_field(
name='URL',
value='[Click]({0.source.url})'.format(self)).
set_thumbnail(url=self.source.thumbnail))
return embed```
There you are that is the full class
what makes the list
?
🤔
thats a class
like try printing [song]
just do it after you have declared [song]
you can put it just before this
def create_embed(self):
embed = (discord.Embed(
title='Now playing',
description='css\n{0.source.title}\n'.format(self),
color=0x02020).add_field(
name='Duration', value=self.source.duration).add_field(
name='Requested by',
value=self.requester.mention).add_field(
name='Music By:',
value='[{0.source.uploader}]({0.source.uploader_url})'.
format(self)).add_field(
name='URL',
value='[Click]({0.source.url})'.format(self)).
set_thumbnail(url=self.source.thumbnail))
return embed
print(song)```
Oop sorry
[<cogs.testmusic.Song object at 0x000001EFD57C64C0>]
Kk
how do i make it ome
await interaction.response.send_message(embeds=embed)
you dont need a list
what lang?
js
How is that going to go and get the embed from that class though
its too late here for that
noidea
u should figure that
Then this ain't going to work LOL
its an object you dont need to give it a list
test with it
Yeah I just get embed is not defined
Anyone else got any ideas
if you returned embed correctly there should not be any problem
This is what I get when printing it
also, if its only 1 embed use embed not embeds
But it's not returning the embed it's returning that string of stuff above
its not a string.....
Okay that's not what I meant
do you print or do you send the message?
Send
send the send message line
await interaction.response.send_message(embed=[song])
can you not put a list....
I understand this is the way I need to do it but I don't see how this is going to go and get the class with it embed is located await interaction.response.send_message(embed=embed)
you need to fetch the embed that is returned
show me the function that contains the send message line
How can i?
send the function
Entire class
What
not the embed class
So do you want the command?
@app_commands.command(name='play2')
async def play2(self, interaction: discord.Interaction, search: str):
server = interaction.guild
voice_channel = server.voice_client
async with interaction.channel.typing():
song = Song(source)
print([song])
await interaction.response.send_message(embed=embed)
await interaction.response.send_message(embed=discord.Embed(
title="Added to queue",
description='Enqueued {}'.format(str(source)),
color=0x02020
))```
does that send the embed?
No
Source has to do with some other stuff and nothing to do with the embed though
So now what?
I want to get the test element
'1': teste {
...
},
'2': teste {
...
}
I tried with [1] but it only gives me one but I want to get them all
Object.values({ 1: {}, 2: {} }) = [{}, {}]
Can anyone else help me?
from what i see, you send embed twice?
saying that it's interaction, you cant send embed twice unless you edit the first send
get the embed by accessing song class and calling create_embed function
i got it
Hi
https://sourceb.in/KM24SdLZEA how do i multiply the current balance for the user?
check code
you didnt change the value
data.wallet = data.wallet * 2
import {
chain
} from 'mathjs'
data.wallet = chain(data.wallet)
.add(data.wallet)
.add(data.wallet)
.done()
no no no no
ew packages
I've been scrolling through YouTube for the best discord.js tutorial via typescript, any playlist you guys found useful?
I can't find the documentation for it, too.
Watching videos for coding tutorials isn't very helpful if all you're doing is copying the code. Some people do explain, but they don't and can't wait for people to finish so they're paying attention to why their code is the way it is
people would be better off with someone who knows what beginners should know personally explaining entry level code
Honestly, I've copied code my entire life and that's how I understood the learning of Javascript.
People have their own way of understanding something.
If you're looking for more yt tutorials, then can you say you understand it?
I understand each tutorial before getting to copy it.
Again, people have their own way of understanding a particular subject.
Do you know what types are
I'm sorry?
Why are you testing whether I know or not?
Because that's fundamental knowledge you should have
Do you know how ruby got originated?
why do I care about ruby?
People do have their own ways of understanding specific things, doesn't mean all of them are best practice, copy pasting is rather the worst practice in this case
I'm not blindly copy pasting, that's what I said?
Because you're not learning if you don't apply concepts
The core of every language is types
Understand the code ---> Know what you're doing ---> Copy paste ---> Do your end by configuring the code, etc.
That's not applying concepts. how long have you been doing this?
When I want to know the basics of a language, that's what I do.
Any reason mysql goes to a new line instead of executing the query when the query is 100% terminated... https://i.callumdev.xyz/fatef.png
It doesn't really matter, you're still looking at other people write code with poor explanations rather than looking at guides and documentations written by people who have spent hundreds of hours doing so instead of someone trying to simplify it in a few minutes or hours, which is from what I've seen is not very helpful
^^^
???
discord.js do have docs
Does typescript not have a seperate documentation, or is that not how it works.
Aware, and I'll take that as a no.
Reminder that discord.js is not solely a TypeScript project, it's not supposed to tell you how to write it in TypeScript way, you're supposed to know how TypeScript works before jumping into the bandwagon
ts and js are supposed to go hand in hand either way
If I want to make a bot with typescript, what packages are required? ts-node, discord.js, nodemon, and what more?
ts-node is not required
Why so?
you compile to js first and then run the dist folder
Isn't it node for typescript.
all ts-node is doing is that
typescript compiles down to javascript to a dist folder. You run that js
Fair enough.
ts-node just keeps the transpiled javascript in-memory
instead of storing it in the file system
I thought it wrote to temp
Now, in the past few days, I've checked this open-source verified bot, Activities. It follows the same procedure, true?
https://github.com/advaith1/activities
you can use the typescript compiler API to transpile the code and then do whatever you want with it

guys, what is the best way to avoid hitting 1 request / 1 second rate-limit 
Does it?
By not making those api calls in the first place
it uses typescript and there's only so many ways to actually use it, so idk what your question is
I tried Promise with Settimeout but that shit was blocking my process
Am I able to use typescript on a javascript file?
no
No. Typescript expressions are only valid in .ts files
Fair enough.
Setting up ts is very simple idk what you're having issues with
I'm asking questions, that's it. (From a beginner POV).
i get u pal
You cannot make more than 200 application commands in a day.
So wait until tomorrow
Does somebody know about express and cookies?
I know about express and cookies.
import js in python
module.exports.updateUser = async (req, res, next) => {
try {
const key = res.cookies.get('key');
if (key)
res.locals.user = await authClient.getUser(key);
} finally {
next();
}
};``` I,m getting this error ``` const key = res.cookies.get('key');
^
TypeError: Cannot read properties of undefined (reading 'get')```
that means either res.cookies is undefined or cookies property key doesn't exists on res
man read the error
it tells you what's wrong most of the time
yes but is defined
have you read res data struct?
then it wouldn't raise this error
in which it did
so res.cookies is undefined
sec
check the cookie before getting
But in tutorial is work
if (res.cookies && res.cookies.has(key))
assume res.cookies is of type Map
i told you, read the data struct of res
not following the tutorial
depends on runtime, libraries and how it got set up, things may be different
a request can have no cookies at all
but this set cookise ```const express = require('express')
require('dotenv').config();
const authClient = require('../auth-client');
const router = express.Router();
router.get('/login', (req, res) =>
res.redirect(https://discord.com/api/oauth2/authorize?client_id=${process.env.ID}&redirect_uri=${process.env.DASHBOARD_URL}/auth&response_type=code&scope=identify guilds));
router.get('/auth', async (req, res) => {
try {
const code = req.query.code;
const key = await authClient.getAccess(code);
res.cookies.set('key', key)
res.redirect('/dashboard');
} catch {
res.redirect('/');
}
});
router.get('/logout', (req, res) => {
res.cookies.set('key', '');
res.redirect('/');
})
module.exports = router;```
yep 🙂
I jusst realized, can you not store information in cookies and get them via requesst?
Idk haha i,m following tutorail on youtube and for him is work fine
youtube tutorials are not ideal, they often contain wrong or outdated information
I want to use them to potentially create an user count
meaning currently online users
Ik, but i,m trying to make discord bot dashboard
and he use cookies
how hahaha
it can be something like
interface Request {
cookies?: CookieList; // CookieList or undefined
...
}
Ctrl + Click
const processActiveUsers = function () {
Active += 1;
}
I'd store them and then update active count
On link they use cookie not cookies?
actually that will not work nevermind
should i use that too
okay
get cookie, check for "Active" keys
if exists, get value else = 0
update value
set cookie
sec
@raven holly check if there exists any "cookie" fields
but i import it ```const express = require('express')
const cookies = require('cookies')
const middleware = require('./middleware')
require('dotenv').config();
const rootRoutes = require('./routes/root-routes')
const dashboardRoutes = require('./routes/dashboard-routes')
const authRoutes = require('./routes/auth-routes')
const app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'pug')
app.use('/',
middleware.updateUser, rootRoutes,
authRoutes
);
app.use('/dashboard', dashboardRoutes)
app.use(cookies.express('a', 'b', 'c'));
app.get('*', (req, res) => res.render('errors/404.pug'));
const port = process.env.PORT;
app.listen(port, () => console.log(Server is live on ${port}))```
this ```const express = require('express');
const router = express.Router();
router.get('/', (req, res) => res.render('index'));
module.exports = router;```
yes
auth-client which?
xD
const client = require('../src');
require('dotenv').config();
const Client = new OAuthClient(process.env.ID, process.env.SECRET);
Client.setRedirect(`${process.env.DASHBOARD_URL}/auth`);
Client.setScopes('identify', 'guilds');
module.exports = Client;```
so it's not a default install for node.js
fron the user's browser in which doesn't have your code
ou so how to fix it

is it??
i told you, check for cookies
if it doesn't have, set a new one and respond with it
But there are no cookies 😭
but this should create one```const express = require('express')
require('dotenv').config();
const authClient = require('../auth-client');
const router = express.Router();
router.get('/login', (req, res) =>
res.redirect(https://discord.com/api/oauth2/authorize?client_id=${process.env.ID}&redirect_uri=${process.env.DASHBOARD_URL}/auth&response_type=code&scope=identify guilds));
router.get('/auth', async (req, res) => {
try {
const code = req.query.code;
const key = await authClient.getAccess(code);
res.cookies.set('key', key)
res.redirect('/dashboard');
} catch {
res.redirect('/');
}
});
router.get('/logout', (req, res) => {
res.cookies.set('key', '');
res.redirect('/');
})
module.exports = router;```
but here is createone part
what if that part doesn't trigger in prior to the errored one
you didn't check the origin to verify its source
but is trigger
because if i go /login it redirect me to /auth
what xD
did you actually assign the key there
run the debugger
sec
and insert the breakpoint at that line
hey @civic scroll
to see if it actually hits
hahaha
but with this i got error
make sure that comes along with every request
but it comes
this is very confusing
why are all the top.gg staff and server icon etc still upside down?
wasnt that for april fools?
they think they're funny but they're not
const options = {
hostname: 'http://myVPSIPAddress:somePort/somePath',
method: 'GET'
}
const req = http.request(options, res => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data', (parsed) => {
v = parsed.version;
message.channel.send("Version: " + v)
})
})
req.on('error', error => {
console.error(error)
})
req.end()
when running this i get an ENOTFOUND error, but when i do a patch request to the same ip, same port, same path it works
and also get requests to that url work via postman, but not this
critics aren't allowed in here, ban, now!
fix my os
still trying to move forward with my frontend, I'm working on for weeks now, so no
use a real os?
did you know css can have variables?!
~ i only just found this out 😭
Yeah they can also have vars with a default value if the var isn't defined
Which isn't supported on most mobile browsers
Which is why I'm not using them
Not that I would need anyways
oh interesting, but regular css variables work on mobile browsers fine?
they're part of the first releases of css3 iirc
so most browsers nowadays support them, yeah
I'm enforcing them in my site but I don't use them

I've only been using them to define theme color type things, then when a user select their theme i just change the href of the stylesheet link element
works like a charm
poor IE
yeah that's how I'm loading my themes in, too
lol, ie gets all the hate, but where would we be now without it?!
still on netscape
i did notice, if the newly loaded theme.css has some @fontface type definitions and overwrites the font, the page has a slight period where the default fonts are used, which isnt an issue unless you want multi font support 😄
how do you handle multi language support?
just load the 'vocabulary' from some relative json or something?
By loading the user selected language file and if it doesn't exist yet, fall back to the default one (en)
No ini files are way better as language files
nope
dang, this weeks full of learning 😄
ahh ok so you just opted for that file type but really its irrelevant cause your parsing it using a custom parser?
aye
anything is already integrated in php
imagine it like it is the entire npmjs collection of libs, with crap but mostly useful prebuilt stuff for u
anyone know of a color pallet generator that can give me 6 colors that work well together, as well as giving shades of that color in steps going dark and also light?
i can either find generators that do one or the other 😭
Hi
I'm usually scrolling through demo themes and if I ever find a collection I like, I take a color picker and use the colors
Guys do you know how to get cookise npm cookies
Because i know how to save cookise is just res.cookie('key')
But how to get it
var http = require('http')
var Cookies = require('cookies')
// Optionally define keys to sign cookie values
// to prevent client tampering
var keys = ['keyboard cat']
var server = http.createServer(function (req, res) {
// Create a cookies object
var cookies = new Cookies(req, res, { keys: keys })
// Get a cookie
var lastVisit = cookies.get('LastVisit', { signed: true })
// Set the cookie to a value
cookies.set('LastVisit', new Date().toISOString(), { signed: true })
if (!lastVisit) {
res.setHeader('Content-Type', 'text/plain')
res.end('Welcome, first time visitor!')
} else {
res.setHeader('Content-Type', 'text/plain')
res.end('Welcome back! Nothing much changed since your last visit at ' + lastVisit + '.')
}
})
server.listen(3000, function () {
console.log('Visit us at http://127.0.0.1:3000/ !')
})
^ thats their example from the npm page
so i just need to change in server.js i need to add var cookise...
idk the module, but it seems easy enough. you create a new cookies object using the request and response and give it the cookies as an object
can you come dm please
i preffer not to dm sorry
again, idk the module, i've always used 'cookie-parser' module
const cookies = require('cookies')
const middleware = require('./middleware')
require('dotenv').config();
const rootRoutes = require('./routes/root-routes')
const dashboardRoutes = require('./routes/dashboard-routes')
const authRoutes = require('./routes/auth-routes')
const app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'pug')
app.use(express.static(`${__dirname}/assets`));
app.locals.basedir = `${__dirname}/assets`;
app.use('/',
middleware.updateUser, rootRoutes,
authRoutes
);
app.use('/dashboard', middleware.validateUser, dashboardRoutes)
app.use(cookies.express('a', 'b', 'c'));
app.get('*', (req, res) => res.render('errors/404.pug'));
const port = process.env.PORT;
app.listen(port, () => console.log(`Server is live on ${port}`))```
cookie-parser is better?
but what is it your trying to do?
in this ``` router.get('/auth', async (req, res) => {
try {
const code = req.query.code;
const key = await authClient.getAccess(code);
res.cookies.set('key', key);
res.redirect('/dashboard');
} catch {
res.redirect('/');
}
});``` is gonna save cookie
and here module.exports.updateUser = async (req, res, next) => { try { const key = res.cookies.get('key'); if (key) res.locals.user = await authClient.getUser(key); } finally { next(); } }; get it
is better cookie-parser?
oh, i use passport module for handling login/auth 😄
but cookie-parser can do that also yea?
if all your wanting to do is get/set cookies then yea
and cookies module should also be able to
most documentations give examples with setting up using express too
I just want to make dashboard and do with cookies to save login you know
likely because res.cookies is undefined
every else is with db
but if i try res.cookie is work but i can't get cookie
const cookieParser = require('cookie-parser');
const express = require('express');
const app = express();
app.use(cookieParser());
app.get('/', function(req, res){
res.cookie('name', 'express').send('cookie set'); //Sets name = express
console.log('Cookies: ', req.cookies); // prints cookies
});
app.listen(3000);
^ sets/prints cookies
'name' is whatever your cookie name/id is
ik that but i ask is this correct way to get it
https://www.tutorialspoint.com/expressjs/expressjs_sessions.htm
^ a guide on how to setup sessions using express and cookies, which i think is what your trying to achieve
How do I remove global slash commands?
update your commands to discord api using an empty array
ohh. tysm idk why i didnt think of that
i try do to that
no worries. good luck 🙂
I get this error
but i want to get it
then req.cookies
it is not a function
i k that but why
because it is not a function.
it is a property
you cannot call a property
unless it is also a function (to be fair)
but this one isnt 😄
do console.log(req.cookies)
you will see, it is an object with its own properties
for example: req.cookies.key
idk, there must be some flaw in the logic to load/set/get the cookies
req.signedCookies?
Is a counting game enough of a reason to ask for the message content intent
Cuz according to discord it can be solved using / commands
And like technically they're right but it's really worsening the user experience
So is there any good way to go about it
if it can be solved with slash commands you're unlikely to get the intent
and even if something can't (e.g. message logging) they're still aggressive on pushing people away from using it, even if it leads to less features
Damn that sucks



