#development
1 messages · Page 1736 of 1
maybe
hm, so there's no bias being added by internal optimizations
seems like what tim said
nothing can win against raw loops
nice
guess it's being biased by previous calls
const Iterator = new FIter<number>().filter(num => num % 2 === 0).map(num => num * 2).join("\\n").compile();
const suite = new Benchmark.Suite();
suite.add('FIters#filter#map#join', () => {
Iterator(data);
});
suite.add('Array#filter#map#join', () => {
data.filter(num => num % 2 === 0).map(num => num * 2).join("\n");
})
suite.add('for loop', () => {
let res = "";
const len = data.length;
for (let i=0; i < len; i++) {
const item = data[i];
if (!(item % 2 === 0)) continue;
res += item + (i === len - 1 ? '':`\n`);
}
})
suite.add("only reduce", () => {
const len = data.length;
data.reduce((acc, item, i) => {
if (item % 2 === 0) {
acc.concat(item + (i === len - 1 ? '' : '\n'));
}
return acc;
}, '');
})
(which is why you never benchmark something sequentially)
The compiled code:
const l=arr.length;let ce0='';for(let i=0;i<l;i++){let _=arr[i];if(!(_%2===0))continue;ce0+=(_=_*2)+(i===l-1?'':'\n')};return ce0;
I have a feeling reduce really is the clear winner here though
he did it, and it biased toward the latter execution
though perhaps concat helps
just... btw
I'm not 100% sure. but maybe string.concat is faster than string += more string
reduce cant possibly be the winner here, something is wrong
array.concat is very slow
no no
yeah it is 😄
string.concat is probably the same as java's stringbuilder
lol
faster inside loops but slower in single uses
Also go back to += since clearly it can be faster
huh interesting
weird
let me use concat for everything else too
so it seems like it's cause of reduce
im guessing its some v8 shenanigan again
it's execution biasing
and probably depends on the specific node version too
it optimizes stuff on the run
¯_(ツ)_/¯
Every time, about performance. https://cdn.discordapp.com/attachments/106126169627181056/231117241892995072/unknown.png
Okay, new suite, on a different process, filter#reduce vs the compiled function. How can reduce be so slow here
bias bias bias
But this is, indeed, a problem with testing performance with benchmarks.
- They're not consistent between testing methods
- They're not consistent between versions and environment
- They're not consistent depending on the data they're processing
- They're not consistent sometimes randomly just to fuck with you
You're trying to optimise a language that's optimised by the V8 engine.
your optimisation can literally be counter-productive
// let a = 'x'; return a += 'z';
26 S> 0000009DFD26E51E @ 0 : 12 00 LdaConstant [0]
0000009DFD26E520 @ 2 : c6 Star0
31 S> 0000009DFD26E521 @ 3 : 12 01 LdaConstant [1]
0000009DFD26E523 @ 5 : 35 fa 00 Add r0, [0]
0000009DFD26E526 @ 8 : 27 fa f9 Mov r0, r1
0000009DFD26E529 @ 11 : c6 Star0
46 S> 0000009DFD26E52A @ 12 : ab Return
// let a = 'x'; return a.concat('z');
26 S> 000002D4EC86E526 @ 0 : 12 00 LdaConstant [0]
000002D4EC86E528 @ 2 : c6 Star0
40 S> 000002D4EC86E529 @ 3 : 28 fa 01 00 LdaNamedProperty r0, [1], [0]
000002D4EC86E52D @ 7 : c5 Star1
000002D4EC86E52E @ 8 : 12 02 LdaConstant [2]
000002D4EC86E530 @ 10 : c3 Star3
40 E> 000002D4EC86E531 @ 11 : 5a f9 fa f7 02 CallProperty1 r1, r0, r3, [2]
51 S> 000002D4EC86E536 @ 16 : ab Return
``` thats the bytecode for each variant
v8 bytecode
oh, also
has someone used workers in a good fashion?
need some really optimal code for this one 
and im afraid of retrying the thing i did for the twitch bot
cuz erwinCode™️
let's make a new sorting algorithm, erwinsort
jsut write the shittiest thing you can, that'd be it
performance testing is not unit testing 
exdee
ErwinTheLoliSort
But instead of sorting, it bites you
atMods talking about lolis in chat

okay but like...this is slower
data.reduce((acc, num) => {
if (num % 2 !== 0) acc += num;
return acc;
}, 0)
Than the compiled function AND the for loop in the filter reduce benchmark...
compiled: const l=arr.length;let wp2=0;for(let i=0;i<l;i++){let _=arr[i];if(!(_%2!==0))continue;wp2=wp2+_};return wp2;
The compiled is the fastest here
the difference is so big that it just can't be the benchmarks screwing with us
now just for the fuck of it do it in inverse order: for loop first, then filter/reduce, then reduce only
I made this code for redeeming codes, and the person must be in Support Server to redeem a code. When I try using the command no message is sent, no data is updated, and no errors shows up in my console
const Discord = require(`discord.js`)
const db = require(`../database.js`)
module.exports.run = async (bot, message, args) => {
let user = message.author;
let server = bot.guilds.cache.get("774041271655333928").members.fetch(`${user.id}`)
{
let Embed = new Discord.MessageEmbed()
.setColor(`#1eb346`)
.setDescription(`You must be in [Support Server](https://discord.gg/hHwXDmQabp) to redeem a code.`)
.setFooter(`pb!help for support`)
if (server === undefined) return message.channel.send(Embed)
} if (server === true) {
if(args[0] === `DF4SABS`) {
db.fetch(`money-${user.id}`)
db.add(`money-${user.id}`, 10000)
db.set(`DF4SABS-${user.id}`, true)
await message.channel.send(`Succefully redeemed this code. 10.000 BulbaCoins were added to your bank.`)
} else {
message.channel.send(`Incorrect code.`)
}
}
}```
alright well clearly still the same difference
looks like I was wrong
I mean, I didn't say it was faster, I asked if you'd tried it.
¯_(ツ)_/¯
reduce is weird
it biased toward for loop now
before it was fiters#filter#reduce
those two are almost the same anyways, ones compiled other is manually written
ah
but the compiled is so slow in the first one tho tf😭
anyone help me pls .-.
your formatting is terrible
😔
- and you should be ashamed of it
dont cut the diss in half
You're comparing a promise with a boolean

Resolve the promise and remember to handle the error since <Guild>.members.fetch() will throw an error if the member isn't in that guild, you can handle it with <Promise>.catch()
node:1338) UnhandledPromiseRejectionWarning: TypeError: (intermediate value)(intermediate value)(intermediate value) is not a function```
let commandString = category.map(c => `\`${c.config.disabled ? ':x:' : ''}``${client.config.prefix}${c.name}${c.config.usage ? ` ${c.config.usage}` : ''}\` - ${c.config.description} - ${c.config.disabled ? ':x:' : ''}`).join('\n');
embed.addField(`${categoryName}`, `${commandString}`);```
im trying to make it so it prints a ❌ next to a command if its disabled
it worksat the end
but not the beginning
i assume its formatting issues but idk how to fix it
i just needed a + nvm
wellnvm that messed up my formatting
ugh
ok i used\`\which fixed it
Does anyone know what code to write to post photos (jpg) from replit to discord?
at this point wouldn't it be better to use string.format?
ah nvm, js doesn't have a string.format
just get the file and send it
or use imgur actually
then setImage(file.link)
I want to use it as a command
send the file and use attachments://name.ext
https://i.callumdev.xyz/i5htw.png
how can I have the dropdown stay while my mouse is in the red area?
Quick question just wanted to clear the air, once my bot is verified will Luca DM me or @ me in this server?
both
👌 thanks
Oh? Site said Luca but if it's watcher that works too
hai, can you fetch all column values in asyncpg?
i have a column ive queried but idk how to fetch it
I've never used asyncpg, but the fetch method seems to return all rows. If you want to return all values from a specific column, you can restrict the return type as you would in SQL (SELECT id, name FROM person;)
This helped me so much lol
I would’ve probably gave up if u hadn’t helped me
Now my bot is in over 4.6k servers
Thank you so much lol
👍
Can someone teach me how to use databases in py?
https://www.fullstackpython.com/databases.html seems useful
Lol you helped too
f
what language
?


what is it that you want to do once a reaction is clicked?
Like this
discord.js
(or discord js)
ㅇㅅㅇ
Ok
const user = await client.users.fetch(newState.id).catch(() => {})
setInterval(async () => {
if(newState.channelID === undefined) clearInterval(0)
var memberUser = await client.getUser(user)
let xpNeeded;
xpNeeded = await client.getNeededXP(memberUser.levelVoice)
let xpAmount = Math.floor(Math.random() * (25 - 10) + 10);
console.log(`${xpAmount} ajoutée à ${user.username}`)
client.updateUser(user, {
xpVoice: memberUser.xpVoice + xpAmount,
currentXPVoice: memberUser.currentXPVoice + xpAmount
})
}, 5000)
I want to add xp to user every 5s but that way still adding xp when i leave the channel, and i define the interval then clear it when someone leave, it would clear the interval for everyone so idk how i can do that
What does: (node:8130) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body limit: int value should be greater than or equal to 1.
Mean?
Code:
message.delete();
if (!message.member.hasPermission("MANAGE_MESSAGES"))
return message.reply("You don't have premssions to do that!");
let reason = args.join(" ").slice(1);
if (!reason) return message.channel.send("`Enter a valid amount.`")
message.channel.bulkDelete(reason, true).then(() => {
message.channel.send(`**Cleared \`${reason}/${reason}\` Messages!**`).then(msg => msg.delete(reason));
});
}}```
I feel stupid when I ask my questions lol, there usually such simple things, but my brain today lol.
hm......
What
Wait, so what would I fix/change?
message.content.slice(1) idk
...
That’s obviously an API error as the error says, meaning something you send is wrongly formatted
And that’s bulkDelete()
Take a look into the docs which arguments it needs
@earnest phoenix
And intergers can have a negative value as well
I figured it out, thanks tho.
Int can't reach that value
It's 2.7 billion something
Of course it can. We don’t live in 1990 anymore and aren’t limited to 32 bit.
Per definition any whole non-decimal number is an integer no matter it’s size.

Ha got you! Shame on you 
Per definition int is int long is long
God damn which fucking language calls a big int long
Java and c# are the only two I can mention
time to sleep
Warning: sleep on main thread might cause deadlock issues
Oof
discordjs has an embed builder, just use that.
https://discord.js.org/#/docs/main/stable/class/MessageEmbed
oh you mean pageated?
reaction collectors https://discord.js.org/#/docs/main/stable/class/ReactionCollector
there's also an npm package for that but it's kinda slow, so if you want fast embed pages, i would recommend writing one yourself
thx
Can we add aubscription to our discord bot?
I feel like Discord.js' ReactionCollectors and MessageCollectors are jank and can throw an EventEmitter possible memory leak detected error because they impose a separate listener on relevant client events instead of routing through already existing handlers for processing Gateway events
:/ i think i have to create database and then website with payment api and interact it to database with discord bot interact to database that automatically add user to database but how i disallow usage of premium commands that dont have premium means i know how to add database but i dont know how to reject user to use some commands without adding that user in database , again i means if user for ex. I am not in that database i can use all premium commands can i disallow user that not in database from using specific commands
does anyone use galaxygate for hosting? if so, how is it?
I Need to interact database with my bot can i use google sheets insteed of mysql?
you can use google sheets, but it won't be as fast
Ok Thanks
also has horrible security
why would you use that lol
i didn't say to use it
But you said you can which is very easily interpreted as you saying you should
ig that's true
Next time to avoid , add the precision "You really shouldn't do that"
otherwise we have idiots that keep using JSON because
"You can use JSON as a database but it's slow"

lmao
Tim does
Tim, are you there
ah, i see you went for the passive route and choose not to anger him by pinging @quartz kindle without an actual valid reason, which might put him into a bad mood 
I don't like pinging ppl
I like pinging people.
yeah i can see that, as you cleraly didnt ping @quartz kindle
lmao
My bot has the link block feature and when I open it, it throws a special tick emoji, but that emoji only appears on the server where the emoji is located. Also my bot has all the necessary permissions
So, its a custom emoji?
My very first Bot actually had JSON as DB
after 2 days my data was corrupted 
What you can do is use, <:emoji_name:emoji_id> . Mind the emoji must be in the server where the bot is. And this allows the bot to use the emoji everywhere
Yes
When i use this i have same problam
?
But i am sure about id
I will check it again
Yeah.
Not working @clear marlin
I have a question can we set Interval in timeout?
setTimeout(()=>{
}, 1000) // interval in milliseconds
😁
Check intents
What should be intents
Rn I'm making a SQL db to store info on servers and users of my bot where the user info is specific to servers. The organization of the code is somewhat like this:
class server:
class user:
def __init__(self, id):
self.id = id
self.serverSpecificStuff0 = 0
self.serverSpecificStuff1 = 1
def __init__(self, id):
self.id = id
self.users = {}
I assume you get the gist, how should I store this stuff in a SQL table? SQL tables don't really like nested stuff after all
@clear marlin should i open any intent?
this
it's the invite link that matters
probably relational tables with a server ref
ow hi
thanks
though you could also use schemas technically, but relations will be better
ok, thank you for your help
Hey guys, So I recently made a lyrics command, it works but it returns this error when I type gibberish although I've already made an error handler for it, The error :
An error occurred: Command raised an exception: KeyError: 'lyrics'
Code :
@commands.command()
async def lyrics(self, ctx,*, title):
url = f"https://some-random-api.ml/lyrics?title={title}"
response = requests.get(url)
json_data = json.loads(response.content)
lyrics = json_data['lyrics']
if len(lyrics) > 2048:
em = discord.Embed(title=title,description = f"I wasn't able to send the lyrics for that song since it exceeds 2000 characters. However, here's the file for the lyrics!",color=0xa3a3ff)
await ctx.send(embed=em)
file = open("lyrics.txt", "w")
file.write(lyrics)
file.close()
return await ctx.send(file=discord.File("lyrics.txt"))
try:
em = discord.Embed(title=title,description=lyrics,color=0xa3a3ff)
await ctx.send(embed=em)
except KeyError:
em = discord.Embed(title="Aw Snap!",description="I wasn't able to find the lyrics of that song.",color = 0xa3a3ff)
em.set_thumbnail(url='https://cdn.discordapp.com/attachments/830818408550629407/839555682436251698/aw_snap_large.png')
await ctx.send(embed=em)```
@opal plank @_@
it cnt work in other server
which language
Dude its pretty damn clear that its python
i cnt know python
how i say

Technically speaking, I could take the result from a canvas function and store that in a database for use later on right? Just hesitating if I should do that or make an API.
Just the API would involve storing images
hi timmote
you can store it as a file or in a database as binary/blob/base64
only do that if the full image is doing to be reused multiple times
Yeah that's right
gotta love message spikes absolutely wrecking it
It's for images that are supposed to be reused for 12h. I thought it would be simpler to just store the base64 result in the db and call that instead. Currently my bot attaches the image to the message and then fetches the discord cdn url which is not ideal. On very rare occasions it can't read the message.
is it too big to be kept in memory?
raids :^)
ngl, looks like it
Well it generates multiple different images for each user and gets thousands of calls a day so that's probably not a great solution in this case. That would mean storing thousands of these images in memory.
They're not big files or anything but I just didn't want to be storing the image files.
are the images completely different from each other?
or do they share some parts like background
It's for a ship command so it's basically 2 pfp and the ship result in the middle so they're all different
Image manipulation?
Right now I'm just storing the Discord CDN urls in the database with the timestamp and ids. It works fine but there's this super rare glitch that happens maybe once or twice a month where the bot can't read the embed from the message it just sent.
I mean, it's a really minor problem but still 😂
well you could always upload them to an external cdn
and if it cant read the embed just dont store it in the db and it should force it to regenerate in the next command
Yeah I thought about that but I also thought just storing the base64 in the db since I'm already making a db request is more efficient?
not exactly
you still have the cost of data transfer to and from the db, the cost of the query and the cost of copying the pixels into a canvas object
or a format discord can receive
and you're still uploading it to discord again which costs bandwidth
But using an external CDN will require also making another request to that too right?
yes, but it would replace sending the attachment to discord
Hmm true
i think what you're doing is already the most efficient you can get
your issue shouldnt be an issue at all
like, if it fails to read, just dont save anything, and it should cause the next command to act like it was the first run
It's not really an issue. It throws an error like 0.001% of the time
I'm just being picky 😂
it shouldnt be causing an error tho
I get a Discord error saying it can't read the embeds object of the message it just sent
It's weird
Not a perms problem because it checks for correct perms in the channel before doing anything
show code
I'm not at home right now so I can't unfortunately
But since it's super rare it sounds almost like the results message is getting deleted before it can read it
are you fetching the message after sending it?
It does something like
message.channel.send(embed).then("reads response here")
Can't remember exactly tbh
That's probably wrong
the response to sending is basically a discord api response wrapped as an api event by the library
if for some reason the api response doesnt include it in neither embed nor attachment fields, you can try to refetch it
and if that also fails, then dont save to db
so its just a matter of error handling i guess
Yeah it honestly sounds like a problem with the API since it barely ever happens
Guys, how can I add api_key based rate limit on my ip?
hey tim! Do you know why my code is still showing 50k users only?
the bot presence*
let z = client.guilds.cache.reduce((a, g) => a + g.memberCount, 0) client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${z} users`); this is what i have
"only"? How many do you think it's supposed to show?
it's in one guild that alone has 96k users, then it still has 92 guilds it's in apart from this big one.
I'm tryna make a swear filter, does anyone have a list of words I should add to it?
If you do send me them through dms xd
you have a npm package for it
oh
it's not that simple btw
Is there on mongoose a property/option or function, which will ignore choosen field on .save() , something like read-only
this is the one i used
call this, and assign it to a variable. It would return an array with bad words. googleProfanityWords.list();
Don't think so, you have to remove those properties before modifying the data
https://stackoverflow.com/questions/52669676/make-a-mongoose-schema-field-read-only
will this solve my problem?
good, It saved a lot of work lol
${info.type1}\nType 2: ${info.type2}\nQuick Moves: ${info.moves.quick[0]}```i have all these arrays here
how do i check efficiently if one of those returns null?
Is there another way to find channels by name instead of client.channels.cache.find?
No
Ok
you need to access the cache
you can use [...collection.values()].find() though
but it's not any different
@exotic wind
@exotic wind
how do i see what guild an invite someone sent leads to (java)
make a request to https://discord.com/api/invites/<code/vanity>
k
btw after i got this verification process, my bot cannot login discord
is this normal?
it didn't happen for me tbh, but it might be normal. Not sure.
how long did your verification process take?
2 weeks
its verification for 100+ server right?
anyone experience with bot whitelisting?
yeah
i am having problems with this trivia npm package
so in the runkit, it logs all the questions, but in vsc it shows: results 0
eventhough i do exactly what i did in the runkit
that would be bad if i cant login my bot in 2 weeks just wait for verification
Can I give rpc code in repl/glitch?
it show result fine for me
RPC is deprecated, its now SDK btw
But my friend have
but its deprecated
So how to use sdk now
@earnest phoenix read the red text https://discord.com/developers/docs/rich-presence/how-to
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
How do I make it so that voting for the guild gives you rewards?
hey! js .addField(`Choices: \n**A: ${easy.results[0].incorrect_answers[0]}\nB: ${easy.results[0].incorrect_answers[2]}\nC: ${easy.results[0].incorrect_answers[1]}\nD: ${easy.results[0].correct_answer}**`, "Type ``!answer (your answer) to answer this trivia!``")how can i for example bind the Letters to the answers?
So if i type !answe C, it would say that it is wrong
because right now i have an array.sort function that randomizes the places of the answers.
use if else?
@eternal osprey no, it's 2 weeks for top.gg verification
for discord it takes around 1 month
and how can't your bot login?
what error are you getting?
use a map
it took me 2 weeks?
for discord verification?
damn it looks strange
you were lucky then, discord takes about 1 month (2 for intent approval)
It's now 4 or 5 months for intents approval
geez
ww3 noises
huh wait really?
It took me 2 weeks to get bot verified + intents that were automatically approved alongside my bot.
if you request intents in the verification request it's faster
it's slower if you request them separately
Hi
aha got m
no error, script just stuck at login, if i use other bot token it worked fine
Hey guys,
can someone tell me why my bot is not reading the commands ? https://github.com/latra/Serve-Bot/blob/master/src/bot/bot.py
added this to my lib last night...
https://dpp.brainbox.cc/a00020.html
support for discord buttons... just gotta wait for discord to roll it out to everyone now 😄
https://srcb.in/fkbTvc3jqw
How can I move the avatar down?
the actual result is this: https://cdn.discordapp.com/attachments/833688191345098782/839850353062969354/welcome-image.png
I'm using canvas
there's no limitation whether you can login or not while not verified
must be some code error
or cloudflare ratelimit
drawImage and arc
it worked using other bot token
add pixels to Y position
still
There is ... 1000 per 24h
my bot get rate limit ban maybe??
did you restart your bot too many times?
read the last 3 words
then shush
that could be the case, i just turned off intent, then realize all my code error
its mean 24h ban right?
you turned off the intent at the site?
yes, because its annoying to answer verify
did u also turn it off on the code?
nope, guild.owner.id is error, i just fixed it with guild.ownerID
then you ARE getting an error in the console
since pm2 is auto restart, the bot must be login too many times when error
if you disable intents on the dashboard you MUST also disable on the code
yes, but not error login
no :^)
tl;dr: if you disable intents on the site you need to disable on the code, else it'll not login
when disable intent, i didnt know which code use it, some still worked, some are not so i just realized to fix it right now using other bot token for example
other bot token works because you didn't disable the intent
djs stable is still on api v7, so intents are not mandatory
so he probably doesnt even set intents in the code
i disable intent for other bot token, and find the error, and fixed it just now
but realized my main bot token already banned
its too late
i dont set any intent, its default usage
when code gone wrong, then i just realized intent are not enabled
if u wanna make a command in a cog then it shld be @commands.command
just realized i can do this
const myIntents = new Intents();
myIntents.add('GUILD_PRESENCES', 'GUILD_MEMBERS');
const client = new Client({ ws: { intents: myIntents } });
but i didnt use the code lol
mine are just like
const client = new Discord.Client();
await client.login(token);
you can't
not without them enabled on the site
who doth ping me 3 times here 
of course
uhu but i tried this: \u1F170
but it logs as a strange character
not as this emoji
visit the emoji url, then use copy button emoji, then paste your text
you cannot use that for bot i think
you can
but those characters have surrogate pairs
note that the unicode contains 5 digits not 4
to grab the unicode (not utf8) of them use 🅰️
\emoji
copy that character and paste on the code
you'll get something like \u1234\u5678
Appreciate any help
ask in #topgg-api
Gotcha, thanls
uhhh
\🅰️
what
where do i paste it
read the last 4 words
yeah i am but my brain is dead or something
cool now move along
first fix your grammar.
Lol
Whats wrong?
\🅰️
Umm
okay so now i have the unicode
"i've" was technically right
Yea
what "in a cog" means? D:
yeah, but i didn't like how it looked.
tho, i still don't understand what you just told me
how didn't u understand?
i don't know what to do
do what?
What
you asked for the emoji's unicode
yeah
now you have it
no the uft8 code
there's no utf8 code
the \25sfsg
it doesn't have to be in \u1234 notation
yeah but i do want it in that type of notation
as this is what my console says
Unhandled Rejection:
DiscordAPIError: Unknown Emoji
show code
const reactionEmoji1 = "\u0041";
await s.react(reactionEmoji1) // this is where it called the error
;```
that's not what I told u to copy
the "self" thingy that u were trying to use is generally used in a cog and please read the docs
no but this is what i had done before you told me to do
"rtfm" 😛
i also tried copying the uncidoe but my vps just strangely doesn't support it
\u0041 is not an emoji
happened to me like 3x
lol
bro, look, you're mixing things up
haha thanks sage
yeah i figured it's a character.
if I ask you, what Pi represents?
3.21
that's wrong af but anyway
wahahhaha
yeah but my vps strangely doesn't support it
🅰️ is the same as \uD83C\uDD70
it gives me the same unknown emoji error till i give it \ codes
no
i know
I doubt it is giving an error
holy shit i am going to give you an example right now okay
sure
i will reset my code and run the error
paste 🅰️
yeah
const reactionEmoji4 = "??";
this is what it returns me after a winscp restart
alrght one sec
| Unhandled Rejection: 3|index | DiscordAPIError: Unknown Emoji 3|index | at RequestHandler.execute (/root/AwsomeModeration/node_modules/discord.js/src/rest/RequestHandler.js:154:13) 3|index | at runMicrotasks (<anonymous>) 3|index | at processTicksAndRejections (internal/process/task_queues.js:97:5) 3|index | at async RequestHandler.push (/root/AwsomeModeration/node_modules/discord.js/src/rest/RequestHandler.js:39:14) 3|index | at async Object.exports.run (/root/AwsomeModeration/commands/trivia.js:63:5)
your winscp is corrupting the emoji
const reactionEmoji1 = "???";
const reactionEmoji2 = "???";
const reactionEmoji3 = "??";
const reactionEmoji4 = "??";
await s.react(reactionEmoji1); // this is where it errors
await s.react(reactionEmoji2);
await s.react(reactionEmoji3);
await s.react(reactionEmoji4);
yeah i know it is
that is why i want to use \ codes
then the error isn't in the code
fix winscp then
\ codes of an emoji
what is that for help?
yeah but my emoji doesn't turn the \ codes into strange ??
if you fix winscp it'll not try to encode what it shouldn't
it doesn't corrupt it in \ form
no it doesn't this happened to me 3 times and i fixed it by \
bruh
is cry here
use git not winscp
yeah, but now i just want the \ codes of an emoji
do you know how to get those?
"but now" that's where your issue is
\🅰️
its literally \🅰️
you'll never be able to work with surrogate pairs if you don't fix that
winscp corrupts those, which is why i want the \ codes.
WinSCP is a free SFTP, SCP, Amazon S3, WebDAV, and FTP client for Windows.
this for example
read that link I sent
WinSCP is a free SFTP, SCP, Amazon S3, WebDAV, and FTP client for Windows.
that one is for info regarding winscp issues with utf-16 chars
which surrogate pairs are
unless you specifically need to use winscp, consider using filezilla or git
preferrably git
without git, if something ever happens with your code there's no going back
also git doesn't touch in your code like ftp does
you send abc you get abc
with ftp you send abc you get 123
i got this error when i try to execute npm init
i already re-installed nodejs, i open cmd as admin and i get the same error
you're running npm init in the wrong place
where i can run it?
ENOENT means npm can't find a file or a directory
Are there any free easy to learn databases to use with discord.py?
why specifically "free easy"?
can't get more free than using google
atleast free
does the directory have any other files?
yep
welp, does it have a package.json?
is it your root directory where your executing the command?
root?
no
Documents/
Create a new folder in documents
i already did it
i get the same error
npm -v?
7.11.2
well
Host an own database.
Can’t be cheaper than free. 
kinda confusing why its not working
How tho
Get a server and install and manage your own database.
im confussed too
do you have yarn?
I don't have any idea what you are talking about so i am just gonna store everything in a .txt file
i already restarted my pc
nope
that shouldn't be a problem tbh
how would i make a command that anyone can run that would kick one certain user(js)
but take a try
link?
I would recommend not using a text file, if you aren't gonna use a DB you might wanna use json or pickle
Are you sure you even need a database?
to?
yarn
oooh
error Could not write file "C:\\Users\\rzsty\\Documents\\FD\\project\\yarn-error.log": "ENOENT: no such file or directory, open 'C:\\Users\\rzsty\\Documents\\FD\\project\\yarn-error.log'"
error An unexpected error occurred: "ENOENT: no such file or directory, open 'C:\\Users\\rzsty\\Documents\\FD\\project\\package.json'".
info Visit https://yarnpkg.com/en/docs/cli/init for documentation about this command.
where r u coding? I mean is it vsc?
yea
then
but i am using cmd
It really looks as if your working with npm on a root
oh
not terminal of vsc
sometime it doesnt works so use vsc terminal
Can i make a button on a website that kicks a specific user
vsc terminal is windows terminal
its powershell
that doesn't make sense lmfao
I mean the cd <folder>
whatever you use it does the came thing
but vanilla is cmd
Sure if you got his ID or name or any other identifier
ik
yeah that's what I'm telling you
in cmd sometimes that cd <folder > one doesnt works
thats why I asked him to use vsc terminal xd nvm
i dont know how to do it. i can make it send messages i just dont know how to make it kick.
is your current directory a folder or a root?
ummm idk if I said that correctly rip
probably not lul
i will try in
is there a site that helps with that
C:\Users\my user\testFolder
hope it works
nvm
Using the Discord API to receive the client list and then kick the client you want via. the API again.
ggs
documents/desktop is not even a thing
its the root of your files
npm doesnt work in roots
BTW Wasn't code related, I was just trying to invoke the command with something like "!serve help" (with the space) 🤦♀️ 🤦♀️ 🤦♀️ Thanks a lot for your time, dude
it works in a current working directory
np
np
Is it possible to use collector message inside collector message? nvm if it is like weird
I already have 1 day trying to solve this problem
😂 why not aksed sooner then?
ah
oh u got that
store them in a variable
like?
I am kinda beginner with message collector (its like I dont understand it correctly)
discord.js does have a message collector function if I'm right?
if you feel like you need to use one inside another you should consider reviewing your code's logic
yesh
so basically you collect the first message
First I looked for it by google I thought it was any common error, and then I tried to solve it in a thousand ways and it did not work, then I went to a community where previously they had already helped me with other things, sadly nobody helped me then I decided to leave the project there and put myself to do other things, then today I realized this server, I joined this server about 10 minutes ago
yea
and then store it in a variable
collect another message
and then store it in a variable and do whatever you feel right
but I want it to continue till one of the player's hp gets 0 or smth like this...
its so ez to get premium bots for free, ruining the concept of "premium"
discord needs to do smthg abt this
they shouldn't
why?
😂 lmao
no one saw this
Hm
because there're literally 0 solutions for that problem
take this link as an example https://discord.com/oauth2/authorize?client_id=567703512763334685&permissions=8&scope=bot
go to any premium bot
support
server
ping the premium version
copy the client id
oh ic
that's the dev's fault, not discord's
and in this link after it says client_id= till &permissions paste the client id
@oak nymph #bigbrain
for example, I'll send my premium bot's ID to you in pv, try to add it in your server
sure, feel free to try any way you want
that generates random tokens for discord bots
hey @trail finch try this if possible https://www.npmjs.com/package/discord.js-collector-utils
whaat
oh ty
just for message collecting
how do i get the user's avatar from a slash command
You need to fetch the user using the bot via ID
They might have changed it, I dunno
Barely used slash commands
Anyone anime lover
const embed = new Discord.MessageEmbed()
embed.setTitle('Error')
embed.setDescription('You must be verified to use this command!'); embed.setColor(client.config.colors.error);
embed.setAuthor(interaction.member.user.username)```
if(linkedUser) {
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
content: await createAPIMessage(interaction, embed)
}
}
});
} else {
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
content: "Hello World!"
}
}
});
}```
how come this doesnt work
apiMessage:
async function createAPIMessage(interaction, content) {
const apiMessage = await Discord.APIMessage.create(client.channels.resolve(interaction.channel_id), content)
.resolveData()
.resolveFiles();
return { ...apiMessage.data, files: apiMessage.files };
}```
the error returns 'Invalid form body'
idk y
node:774) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
data.content: Could not interpret "{'tts': False, 'embed': ...... as string```
the ..... is just the embed printing
oh
its data not content
oop
how do i get
the user's avatar URL
and set it as the thumbnail ?
i fetched the ID
hmm
wait lemme test smth
You can use the fetched user's avatar hash
how do i get the user's discriminator

i ran console.log(interaction.member)
its labelled as discriminator
i tried interaction.member.discriminator
doesn't work for some reason
but interaction.member.id works
member.user.discriminator
Unless that's a raw member object from the API
.setThumbnail(<User>.displayAvatarURL({options}))
Then you need to fetch it as user first
Unless (again) the raw object also provides the user object
Context: I'm making my own lib and trying to be as memory efficient as possible.
Do you guys think it would be more efficient to have a fast temporary cache where resources are stored with a small expire time and said cache is swept in short intervals so that I can reference back to that cache to avoid constructing new instances of the same resource as often as possible or should I continue to just have no caching
if your only goal is memory efficiency, no cache at all.
[ { value: 'hi', type: 3, name: 'text' } ]```
The first option as to caching them for a short period of time or based on intervals is kind of better idea, since you don't have to make requests to get the said for example channel object to reference it to access their properties
this is what prints when i console.log interaction.data.options
how would i only get the value of it
assuming <>.data.value?
well, get the first thing in the array first
[] means its in an array, with only one thing in it, { value: 'hi', type: 3, name: 'text' }
so just the first thing, then .value
const args = interaction.data.options;
args.value doesn't work
not making requests. The general idea it to make the data very partial like how the gateway sends, but some data may be duplicated such in the case of MESSAGE_CREATE
Message.author is equivalent to Message?.member.user, but are two separate instances of User
could just [0] to get the first thing in the array 👀
args.find(arg => arg.name.toLowerCase() == "text")?.value
for safety
whats the ? for
optional chaining
if the property doesn't exist, then the value of the property only returns undefined instead of throwing a cannot read property of undefined error
Well yea, however; the duplicated partial payloads should not be that big of a problem since some data revolving around this has the same issue even if they're not partial, it shouldn't be much of a threat to memory and mallocs and similar stuff, in the case of different instances replicating the same interface and properties as you mentioned at the end, that might be a little bit of a problem towards memory but it should be fine since you're just making them partial
Alright. That was the main concern. If you believe the impact is negligible, then perhaps I shouldn't have to worry
let lembed = new Discord.MessageEmbed()
lembed.setTitle(' Sending suggestion..')
lembed.setDescription("Please wait while I send your suggestion.")
lembed.setFooter('Suggestions')
lembed.setColor(client.config.colors.info)
message.channel.send(lembed).then(async msg =>{```
i want to do this but in a slash command form
please send help. I've been at this for 3 days
so essentially, send a msg, and once its done posting to trello, edit the msg
May god help you
Thamk
Best of luck
seems fun
is it possible to edit a msg after its posted in a slash cmd
yes, you can edit interaction responses
any docs for it ?
Literally the Discord API documentation
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
i forgot how to do this, how do you fetch the all the current slash commands +id w/ discord.js
console.log(client.api.applications(client.user.id).guilds('guildid').commands.get())```
doesnt work
also tried
client.api.applications(client.user.id).commands.get()
doesnt work
😔
NVM got it :D
How can I write msg in box in canvas ?
message in box?
Whenever the msg was long then it sends it in next line
manually calculate string width
In canvas?
yes
How?
there's no text-wrap for such stuff
you need to split the text into words, then write it while it's smaller than the max width
await client.api.applications(client.user.id).guilds('485652668371566603').commands('839876045959331901').delete()```
UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown application command
at RequestHandler.execute (/home/runner/HanaleiNew-Final-1/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
when it surpasses the max, move down in the Y axis and repeat
^^
You're probably entering the incorrect ID, check if its actually the right one
Of if you didn't forget any digits of the ID
id: '839895817929097227',
application_id: '760967685776343050',
name: 'suggest',
description: 'Suggest something for Hanalei!',
version: '839895817929097228',
default_permission: true,
guild_id: '485652668371566603',
options: [ [Object] ]```
i supply the id right
i supplied id
didnt work
text font size * length of text > limit basically
I want like this
You're supposed to enter the id not application_id, if that doesn't work then
¯\_(ツ)_/¯
yeah i entered both
id worked
it just needed to be ran two times for some reason
That's an iframe
how can i add it but
The HTML Inline Frame element () represents a nested browsing context, embedding another HTML page into the current one.
where is not erwin
not here
really left?
no just not currently here
ah okay bc i need help with custom caching on detritus
Just ask detritus support server
@opal plank not rake not needs not help not with not custom not caching not on detritus
also, i did not ping you
Not Tim pinging Not Erwin for help on Not Detritus
not exactly
Like this
70px * msg.length > 10
?
Remove px
in quick.db, i use db.add to add items to user's inventories, how can i make that they could get more than one of the item's and that in the inventory it wont just be true or false, but the number of items
also the expression will always be true, the right number is also in pixels
anyone?
no idea what you're asking tbh
then again quick.db just stores what you tell it, so... change the data you're storing I guess?
so im currently trying to make like a voice chatbot for discord, and in order for speech recognition to work, i need to write raw PCM data to a exsisting WAV file in order for the speech recognition to understand it as the speech recognition is real time, and I dont know how to do that, is that even possible? If so, how?
deal
@earnest phoenix what custom caching?
I have a dashboard for my bot but i only need this properties
guild:{
id:
name:
icon
}
channel{
id:
name:
type:
}
role{
id:
name:
hex:
}```
oh THAT sort of custom caching, i dont know if you can do that tbh
better ask in their server since idk, but i really doubt you can customize it like that
you can customise WHAT it caches, i dont think you can customise the SHAPE of the objects
no that is the properties i need
so a api connected to my bot?
well yeah, for a dashbord you would need the bot to be connected to do that
oterhwise you cannot get roles
you can get guilds via oauth
yea ik it .
but im not sure about channels nor roles
so make a basic api inside your bot
whenever you use it, it returns the stuff you want
yea i will do it since it will sink the ram usage for dash
express would do the trick
express.on('/getUser', (res, req) => {
res({guild: client.guilds.get('id'), channel: client.channels.get('id'), role: client.guilds.get('id').roles.get('id')})
})
thats all you need
something like that
just makle the commandClient available
or your clusterClient/ShardClient
depending if you sharding or not
i use internal sharding
oh I like the background
that is from a video ik
Yes
then you good to go
so on the top.gg site I saw I can use css on my bot description how do I go about adding my css? do i just throw it in there? in the description box
like here is my custom css
.btn {
position: relative;
text-align: center;
cursor: pointer;
span {
position: relative;
display: inline-block;
color: #fff;
font-size: 1.2em;
font-weight: 500;
text-decoration: none;
width: 240px;
padding: 18px 0;
margin: 35px;
border-radius: 8px;
box-shadow: 0 5px 25px rgba(1, 1, 1, 0.55%);
transition: transform 0.15s linear;
}
.color-01 span {
background: linear-gradient(0deg, #ec5c1a, #f6ce61);
}
.color-02 span {
background: linear-gradient(0deg, #0165cd, #55e6fb);
}
or does it mean I have to use a basic css scheme?
What was the css to add animation?
well there is a <script> with it but thats in the html did it on codepen
i used it on my website is it against server rules for me to post my code link to show you?
this css is not going to do anything to your bot page lol none of these are valid selectors
I have the indicators this is just the css classes
i was just wondering how to get css to work since im used to web design and normally there is a folder named css xD
although we might consider doing that in the future it's not super expensive to do so
depends on the demand, go make an issue for it if you want it
hey since your one of the team members question would you mind if I sent him the link to my codepen to Jaguar since he was wondering on the animation?
unsure if sending links to something kinda random was against this server's policy
why would sending a codepen link be against the rules
just wanted to make sure haha
yeah we remove <script> tags so that button hover thing won't work but everything else is fine
yeha i figured you'd probably remove that
so i was gonna rewrite without hover (which is fine) I built the hover just for my site side once I commit the huge update for my site eventually
just wanted to steal my button looks and paste them on the top.gg description haha
fyi if that background is from the artist I think it is, she doesn't want you using her work without permission

it is currently since the site is up but unfunctional its a placeholder having a graphic designer atm working on a piece of animated art
Use the CSS hover
oh maybe it's not the person I'm thinking of https://1041uuu.tumblr.com/
alright then
yeah I wish she replied to me on twitter lol
a way more refined pixel type
oof
I wanted to use one of her gifs as the background on my portfolio
I would love to use her work xD if only she would check her DMs as well xD
getting ghosted by girls as usual
xD shii I have a wife and still get ghosted lmao
sounds pog
thats probably a mercy more than anything lol
lol
Yay for double repeating runtimes 
although I do need more pixel art gifs anyone know anywhere to find fair use ones?
good wallpaper :+1:
I need some help, why isnt this working? (startevent is supposed to wait for 2 people to run &joinevent)
Can you throw the wallpaper there :d
Define "not working". Are there any errors?
was wondering the same thing
@earnest phoenix



actually no
