#development
1 messages ยท Page 1786 of 1
How could someone make such a thing
thats what that reminds me of
this dude used to work at discord
clearly a discord dev
probably*
how is the type as bad as that code?
so wheres the line where an expert can create a massive derp in terms of code
I think I used that once or twice
at that point just use [key;string]
import an interface then
export type Language = {
[key in Array<keyof typeof lang>[number]]: string | LanguageFunction
}
ah yes
that shit
also that tilts me a bit
ive been taught to use interfaces for objects , and types for primitive derivates
no I do use it pog
so when someone uses a type for what should be an interface, i tilt a bit
const languages = {
auto: 'Automatic',
af: 'Afrikaans',
sq: 'Albanian',
am: 'Amharic',
ar: 'Arabic',
hy: 'Armenian',
az: 'Azerbaijani',
eu: 'Basque',
be: 'Belarusian',
bn: 'Bengali',
bs: 'Bosnian',
bg: 'Bulgarian'
}```
```js
const m = await message.channel.send('**Translating.........**');
const translated = translate(q, { to: lang }).catch(e => {
message.channel.send({
embed: {
title: 'error!',
description: e.message
}
});
});
console.log(translated)
const l = translated.from.language.iso
const resEmbed = new Discord.MessageEmbed()
.setAuthor(
'Translator',
client.user.displayAvatarURL({
size: 512,
dynamic: true,
format: 'png'
})
)
.setTitle(`Detected lang : ${languages.l}`)
.addField('your text!', '```' + q + '```')
.addField(lang, '```' + translated.text + '```')
.setColor('RANDOM')
.setFooter(message.author.username, message.author.displayAvatarURL());
m.edit('', resEmbed);
Itz showing me detected language undefined
i cannot being to tell you how much this triggers me
not because of how bad it is, but its inconsistency

message.channel.send({
embed: {
title: 'error!',
description: e.message
}
});```
you send raw payloads here
const resEmbed = new Discord.MessageEmbed()```
but then use builders here
I mean its working fine
you also send a new message without returning an error
which would in turn continue ur code
But Detected lang is undefined
const translated = await translate
.catch(() => undefined)
if(!translated) return send(error)
that should get you the gist of what i mean
also the indentation
PLEASE use a linter/formatter
.setTitle(`Detected lang : ${languages.l}`)
I mean this
How can I get language from isolated code
im going to start sending code with fucked up formatting because of this comment
From languages
const m = await message.channel.send('**Translating.........**');
const translated = translate(q, { to: lang }).catch(e => {
message.channel.send({
embed: {
title: 'error!',
description: e.message,
},
});
});
console.log(translated);
const l = translated.from.language.iso;
const resEmbed = new Discord.MessageEmbed()
.setAuthor(
'Translator',
client.user.displayAvatarURL({
size: 512,
dynamic: true,
format: 'png',
}),
)
.setTitle(`Detected lang : ${languages.l}`)
.addField('your text!', ' + q + ')
.addField(lang, ' + translated.text + ')
.setColor('RANDOM')
.setFooter(message.author.username, message.author.displayAvatarURL());
m.edit('', resEmbed);```
.catch(() => null) gang wya
there, now its redable
translated must be awaited
#development message exactly
await it and check if its there afterwards
that catch block will just run on its own and let the rest of the code continue
you must add a return clause or another scope on an if()
if(translated) { rest}
we just told you how
undefined
you should read our answers
multiple times
^^
the fastest you can go is every 12s
if you want it to be fast, you should probably do every 15-20s
otherwise do whatever
Heyo.
const message = `Hello, the ID is ${}.`;
const id = message.id;
Could I send the ID of the message in the same string itself?
const message2 = `Hello, the ID is ${message.id}.`; ?
๐ค Not sure what you mean? Do you want to store the ID in the string?
15*
Something like this, yes.
That's possible?
yes
Works for embeds as well right?
at least for custom_status. Anything lower than 15 seconds will start to backlog
i assume the ratelimit is shared for the other status types
wait with const
Oh.. alright!
PRESENCE_UPDATE has a 5/60s gw ratelimit
divide 60 by 5 and you'll get the fastest period possible without getting ratelimited
12s
realistically, they dont really care
you shouldnt do it
but its not like they dont have other issues to attend to
I don't for the sake of safety..
pedos, baiters, hackers, scammers, nitro servers, all taht shit
in regards to priority, i assume bots that are just changing their status is quite low
in regards to priority, everything is low
you have to make a deal with the devil himself in order to talk to an actual human in the support team
that is, if the ticket gets answered to in the first place
let bugChannel = new MessageEmbed()
.setFooter(`Message ID: ${bugChannel.id}`)
(node:8996) UnhandledPromiseRejectionWarning: ReferenceError: Cannot access 'bugChannel' before initialization
Bruh, I thought it would work... ๐
.. or is it while sending. ๐
you clearly cant do that
bugChannel is not even a channel? its an embed
unless you have another variable called it, which then you'd be obfuscating
which is a really bad idea
like this
only works in c++ ๐
nah, you can obfuscate shit in js too
its a bliss /s
client.on('message', message => {
setTimeout(() => {
let message = message.content;
})
})
shit like that
now you cant access the original message anymore
you want to get the id from the message, or you want to put an id inside the message?
what?
const m = await message.channel.send(new MessageEmbed()
.setFooter(`Message ID: ${m.id}`)
);
I think this would work.
no
doesnt work like that
What?
it wont work
you cant use a variable before you define it
you cannot use a variable you are declaring in its own declaration
i dont think its resonably possible to send a message and know its ID beforehand,. you'd have to do some insane stuff to do that
Oh.. how can I make it send the message id in the footer?
message ids are created AFTER you dispatch it(aka u create it)
you need to create/send the message first, then you get its id
^^
Damn..
the only way is to send the message then edit
now i wanna see if its fesible to guess a message id before snding it


pretty much impossible
const m = await message.channel.send("Loading bug details");
await m.edit(embed);
.. can I do that?
yes
yes
ids have 3 components, timestamp, instance id and sequence id. good luck:
a. guessing which discord worker will generate it
b. guessing which sequence number it will be by guessing how many other ids were generated in that worker before
c. guessing the exact timestamp that your request will actually reach the worker and be generated
That is the final now.
const m = bot.channels.cache.get("758978182807420938").send(`${bughunteremoji} Loading Bug Details...`);
let bugChannel = new MessageEmbed()
.setFooter(`Message ID: ${m.id}`)
await m.edit(bugChannel)
lmao
Damn..
yeah, i'd pretty much have to try and error it


idea: discord lottery bot
why do you even need the message id in an embed lol
bet on which message id will be generated
Can be many reasons.
fair question
but why do you need the embed message's OWN id in the embed itself
seems completely meaningless
const canvacord = require("canvacord");
module.exports = {
name: 'wanted',
description: 'wanted',
execute(client, message, args, database){
let user = message.mentions.users.first() || message.author;
let image = canvacord.Canvas.trigger(user.displayAvatarURL({dynamic: false,format: "png"}));
let newAttachement = new Discord.MessageAttachment(image,"trigger.png")
message.channel.send(newAttachement)
}
};```
why this canvacord not working?
Send the error.
people really do need to learn how to handle promises tho
Can I get the message id by replying to someone msg?
Ah.. handle the promise in let image = ...
no, handle the promise as in catch blocks
its a promise
and it can fail / return errors
otherwise you'd have an unhandled rejection
I mean they could do that too.
Unhandled Rejection..
I have this function as to when it is clicked, the text will be deleted:
htag.onclick = function() {
document.getElementById("subtags").value = x.toString().replace(`,${htag.id}`, "");
this.remove();
But I want to know exactly what the user has inputted and I'm storing this data in an hidden input:
<input type="hidden" id="subtags" name="subtags">
When the user inputs something, the data is added to this input's value.
So, if I input "Hello", it should look like this:
<input type="hidden" id="subtags" name="subtags" value=",Hello">
And if I type "Bye" afterwards, it should look like this:
<input type="hidden" id="subtags" name="subtags" value=",Hello,Bye">
So my div is looking something like this:
<div>
<h4 id="Hello">Hello</h4>
<h4 id="Bye">Bye</h4>
</div>
If I click "Bye", the input's value goes to
<input type="hidden" id="subtags" name="subtags" value=",Hello">
as expected.
But if I click "Hello" instead, the entire value field is deleted when it should be:
<input type="hidden" id="subtags" name="subtags" value=",Bye">
Does anyone know why?
I gtg rn, so if you have an answer pls ping
idk what canvacord.Canvas.trigger is, but the avatar url needs to be downloaded, so it requires async, which requires awaiting a promise
hum k
I see.
Did I do it wrong? It doesn't edit but sends both. ๐
const m = await bot.channels.cache.get("758978182807420938").send(`${bughunteremoji} Loading Bug Details...`);
let bugChannel = new MessageEmbed()
.setFooter(`Message ID: ${m.id}`)
await m.edit(bugChannel)
execute: async(client, message, args, db) => {
//code
}```
@silk ridge
ok
Can anyone help? ๐
Do
m.edit("", bugChannel)
Why 2?
What's the difference between await m.edit(bugChannel) and m.edit("", bugChannel), docs is killing me.
wrror bruh........
I will try, but I want to understand how that is a difference.
m.edit(oof) edits it to the value oof
.. but m.edit("", bugChannel) puts an empty string and an embed?
See
First you send the msg
Then you want to send embed
So.....
That's why I think..
If you send embed then just that
ok but my error.......
not enough code, from what you shared it should work?
im assuming the code you shared is not the actual code, but an example of it, but from first glance it should be ```js
document.getElementById("subtags").value = document.getElementById("subtags").value.replace(,${htag.id}, "");
(node:315) UnhandledPromiseRejectionWarning: TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.
at Function.resolveFile (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/util/DataResolver.js:135:11)
at Function.resolveFile (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:309:41)
at /home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:241:72
at Array.map (<anonymous>)
Fontconfig error: Cannot load default config file
Promise { <pending> }
Hint: hit control+c anytime to enter REPL.
Listening on 3003
Init Complete, Crowny Bot is online
Bot came online on 19|06|2021 16:49
(node:529) UnhandledPromiseRejectionWarning: TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.
at Function.resolveFile (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/util/DataResolver.js:135:11)
at Function.resolveFile (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:309:41)
at /home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:241:72
at Array.map (<anonymous>)
at APIMessage.resolveFiles (/home/runner/HandmadeWetProfile/node_modules/discord.js/src/structures/APIMessage.js:241:46)
at ExtendedTextChannel.send (/home/runner/HandmadeWetProfile/node_modules/discord-buttons/src/v12/Classes/TextChannel.js:26:50)
at Object.execute (/home/runner/HandmadeWetProfile/Commands/Fun/wanter.js:15:23)
at /home/runner/HandmadeWetProfile/index.js:87:32
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:529) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:529) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
you're trying to send invalid data
๐
Code?
const canvacord = require("canvacord");
module.exports = {
name: 'wanted',
description: 'wanted',
run: async (client, message, args, database) => {
let user = message.mentions.users.first() || message.author;
let image = canvacord.Canvas.trigger(user.displayAvatarURL({dynamic: false,format: "png"}));
let newAttachement = new Discord.MessageAttachment(image,"trigger.png")
message.channel.send(newAttachement)
}
};```
use await
let image = await canvacord.canvas.trigger(user.displayAvatarURL())```
const canvacord = require("canvacord");
module.exports = {
name: 'wanted',
description: 'wanted',
run: async (client, message, args, database) => {
let user = message.mentions.users.first() || message.author;
let image = await canvacord.Canvas.trigger(user.displayAvatarURL({dynamic: false,format: "png"}));
let newAttachement = new Discord.MessageAttachment(image,"trigger.png")
message.channel.send(newAttachement)
}
};```
Now try?
Use execute
Not run
const Discord = require('discord.js');
const canvacord = require("canvacord");
module.exports = {
name: 'wanted',
description: 'wanted',
execute: async (client, message, args, database) => {
let user = message.mentions.users.first() || message.author;
let image = await canvacord.Canvas.trigger(user.displayAvatarURL({dynamic: false,format: "png"}));
let newAttachement = new Discord.MessageAttachment(image,"trigger.png")
message.channel.send(newAttachement)
}
};
that does not wrks
Try
This one
ok ill try this
tho
the variables ive set
is already to document.getElementById("subtags").value
And one more thing
Command is wanted and u creating trigger gif?
nvm i fixed !
yes this execute fixed
Working?
yes
can someone help me with this code: https://mcpaste.io/f630c66841f5343b
and error: https://mcpaste.io/63d36618f2eef3cc
A easy to use Paste site for Minecraft Server logs.
A easy to use Paste site for Minecraft Server logs.
i am trying to make music bot
but something went wrong
just read the error fam
have you defined args[1]
log that first
above the ytld.find
can you explain more please
Help me please for HTML
Actually I had made this script for the description in the bots lists I used on top.gg it worked correctly I wanted to put it in the description in other bot list and it does not work anymore
This is script
if this is for another bot list, you'll have to ask there
I have a message ID.. and I want to use that message ID to edit the message that is in there.. is that possible?
const m = await message.channel.send(`This is a message`);
const ID = m.id;
// Using ID to get the message and edit that, is that possible?
.. maybe fetch()?
is there a simple way to use hex codes for the embeds color in python?
i swear there was but I can't remember
You can convert the hex string (e.g. FFFFFF) to an int with int(hex, 16).
It seems like there's no set_color/add_field method on an discord.Embed instance, so you'll need to construct the embed manually.
e.g.
embed = discord.Embed(color=int(hex, 16))
@hot sage
Channel#messages.cache.get(id)
It's a messageID not channelID
F... edited
bot.channel.messages.cache.get(id)?
.. in a normal command.
Although you already have a message instance in that sample, I assume that's an example, and all you have is a message ID. You can fetch a message from a channel and edit it (<Guild>.channels.cache.get(...).messages.cache.get(...).edit(...)).
If you want to fetch if the channel or message isn't in the cache, use fetch instead of get and resolve the promises beforehand.
It represents a guild instance (e.g. message.guild). If you already have the channel instance, you won't need to get/fetch the channel (e.g. message.channel.messages.cache.get(...).edit(...))
Ah. Let me try..
message.guild.channels.cache.get("...").messages.cache.get("...").edit()
can anyone help me with - <coroutine object Command.call at 0x7f13adf6e5c0>
You probably forgot to await a coroutine.
@client.command()
async def sum(ctx, x: float, y: float):
#plus = sum(x , y)
embed = discord.Embed(title='Sum', description = sum(x,y) , color = (0xF85252))
await ctx.send(embed = embed) #new 2
code
Why are you calling the sum command again?
If you want to add two numbers together, just use the + operator.
i am confused as to why i am getting a syntax error here
i know that but i made .py for some math operation
Hover over it and it'll tell you.
So you have a sum function defined elsewhere and want to call it?
invalid syntax*
yes'
- That's not a string. You just made a comment resulting in your syntax error.
- You shouldn't have
#in your input, so it should just be2555AC(but as a string)
i did call all the function on main but it's not working on embed
That's because you have a name conflict. You want to call a sum function defined elsewhere but the command has the same function name. You could either have the sum function defined in another file and add its namespace before it, or you could rename your sum function while explicitly setting the command name.
# Second approach
@client.command(name="sum")
async def _sum(ctx, x: float, y: float):
pass # Call `sum` function since it doesn't conflict
@pulsar spade
ok ty, im dumb lmao
Yes, so use one of the solutions as it will still work.
Someone knows how to do reaction menu?
I've been searching for it for days but couldnt find any guide
Hi, hello.. for documentation purpose, how can I document this? url,title.. are still saying any
You're expecting an object with all those fields/methods.
You could use @typedef then document the properties (https://stackoverflow.com/a/31573441/14695788)
At least, that's how I do it. I don't know if the top solution will work (https://stackoverflow.com/a/6460748/14695788)
I'm literally not sure why you would re-define built-in sum with a function that literally does the same thing
why is this an invalid syntax? am i this dumb?
missing comma
where
try looking for it
i am blind wtf
idk how you dont see it
await message.guild.channels.cache.get("758978182807420938").messages.cache.get(bughunter.bugs.find(key => key.id === bugID - 1).messageID).edit(embed);
(node:5388) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'edit' of undefined
// bughunter.bugs.find(key => key.id === bugID - 1).messageID is equal to the message ID.
Not sure why it's not working.
the message wasn't found in the cache
neither do i
That's a shame for my bot. ๐
if you know the message should exist use fetch instead
it'll look in the cache first and send an http request if it wasn't found
Could you show me an example on how I can use it, no spoonfeeding.
Suppose I have a message ID as 855811790218068009
.. which is the message ID of the message I replied to.
let channel = message.guild.channels.cache.get("123456789");
let messageID = bughunter.bugs.find(key => key.id === bugID - 1).messageID;
let message = await channel.messages.fetch(messageID); // Will throw if it still wasn't found.
Hm..
await message.guild.channels.cache.get("758978182807420938").messages.fetch(bughunter.bugs.find(key => key.id === bugID - 1).messageID).edit()
Let me try that.
won't work since fetch returns a promise
im an idiot
did you find it?
Oof.
Nah, that's just more reason to learn
how did it take me ~10 minutes to find that
Why should I make a variable for this change, though?
How can I get msg id by replying to the user?
You just need to resolve the promise before you try using it. You could do (await ...).edit(...), but promises can throw, so I don't recommend this practice unless you know it won't throw (which you don't).
I'd rather have a variable, wrap it in a try catch block, and have my message instance from there
Ahh.. alright, let me try.
Bruh, I fix something and get another error, I fix the other error, AND ANOTHER ERROR.
Tf does this even mean.
(node:3724) UnhandledPromiseRejectionWarning: TypeError: (intermediate value).setColor(...).setAuthor(...).setAuthor(...).setTitle(...).addField(...).addField(...).addField(...).addField(...).setFooter(...).setTimestamp(...) is not a function
I literally just fixed my issue.. but that shows up.
means you tried calling a function that doesn't exist
(await message.guild.channels.cache.get("758978182807420938").messages.fetch(bughunter.bugs.find(key => key.id === bugID - 1).messageID)).edit("", embed);
I did this.. got the channel.. fetched for the message ID to edit it.
this looks extremely messy, and kinda hard to read. How can i change it to seem less like i copied a list and pasted it in?
What do you mean?
the values (lists of tanks) looks like it was just thrown in and is messy
Make each value a value.
ok
Maybe put the words in an array and map them with the .join(", "), not sure how you do it in python.
@feral aspen attitude is your bot?
Yes.
Ooo
I saw that in WBL
I wanna good host for discord.js
check pins
nvm
there isnt a pinned list i dont think
oh wait
yes
I wanna free host
this
free doesnt exist, you pay in some way
If you now one exist tell me
This is not really working for me..
rip using github as IDE
there's also google cloud shell
Dor edit i use spck editor just for host I'll put it in github
github is mostly a Versioning system and code sharing platform
Can you install an editor like Visual Studio Code in your environment?
if you want to have the proper experience get a decent Code editor like Visual studio code and get git
so you can write the code in a proper code editor, and just upload it to github
No iam coding in mobile
thats a big RIP
I now
Noice
I need to practice more on documenting my codes
JSDoc sucks anyway
hi
does anyone know
if its possible to make a command, which is used to make custom commands
with their own name, description, functionality and stuff
custom command per guild, it possible with the new slash command
no i mean
like a command, which allows the creation of new commands
ive seen it on a bot before
but ive never seen the feature on any tutorials, github repos or anything
use your imagination and knowledge there isn't a tutorial for everything
it is possible yeah if that's all you need to know
if you need some hints, there is a bot that does it on github
Inb4 they do a simple devโข trick called CTRL + C, CTRL + V 
wont work bcs the bot uses a lib that maybe 8 people on this planet use
Detritus? 
ye

the docs will become better soon, so more people eventually adopt it, since it allows much more flexible scaling than d.js
If erwin was paid to talk about detritus and shit on d.js, he would be a billionaire now

well he just tells the truth tbh
yea
after using it for like 3 weeks i can say it does way much stuff so much better than d.js
sure there are still missing important features, but the lib overall is relatively new
Honestly the only thing its missing is a d.js-like documentation
and some small stuff like a debug event and better errors for certain stuff
If I give the clientID of my bot can be hacked?
no, clientid is a public number
this is @gilded plank's id 264811613708746752
?
only the token is risky (also badly secured servers, databases)
anyone can get your bots id, as its public
so if I give my client ID for a bot website I dont risk anything
2 risky things: client token, client secret
yep, you don't risk anything
I mean the invite url for your bot has to contain the client id. every bot ever has to share its id.
I have another question, I want to do commands in private messages. Where I found it in the docs?
You mean ephemeral messages?
If so you gotta use slash-commands
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
oof
One message removed from a suspended account.
One message removed from a suspended account.
why would you even 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.
are we trying to bring twitter cancel culture logic to Discord bot communities now?
what is that flow
One message removed from a suspended account.
that's not even the concern
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
it's a horrible idea
and it'd also make you a shitty person to be petty and denounce people for making a bot similar to yours in concept
you don't see Mee6 devs trying to denounce Miki for copying their similarity?
One message removed from a suspended account.
or really any bot dev
One message removed from a suspended account.
they still share similarity
One message removed from a suspended account.
it doesn't matter how similar they are
it really doesn't
i could denounce someone for copying the idea of my bot
that's what is being suggested here
@slender thistle i've got a good amount of the source code of my bot rewritten
i can share it with you today
Do you still need help with it btw 
can I denounce all those music bot? 
thats cuz mee6 is already really popular
it might be annoying when a beginner has a really good idea
One message removed from a suspended account.
who has never made bots
Oh bot fights?
it is lol
One message removed from a suspended account.
Stand down I'm a bot Dev too now
One message removed from a suspended account.

thats another point
but the first one is true as well
also mee6 is pretty mundane and normal lol
it doesnt have any unique features
I agree
They are popular just cuz of their dashboard I guess
most (90-95%) bots don't have unique features
yea
I fall in those 90-95%
lol
One message removed from a suspended account.
Then sure
bots probably just slap on mit/apache license anyway
copyrights are expensive af tho, iirc its like 300-1kโฌ/month here
And no doubt this guy @slender thistle helped me a lot whenever I do silly syntax errors
Better I let it get copied instead of getting broke
i found this when looking for how i can make an array in python. I wanted to know how I could use/implement this into an added field, as a value. So, I want an array, for a value, but I dont know how I can do this/if i can use this
I'm just dumb enough I don't understand the question you asked
It's a slash command I'm using
i want, an array in a field of a discord embed
and i didn't know if i could use something like the above ss
Update Discord
You can
Or u can decorate it with string formatting
how do i make the logo of my bot hover on the page? could i have an example please
What do you have and how do you want it to output in your embed
i had a list of things in the value, and i want it to print like this under the section
the code to the above is this
See: str.join
>>> timeit.timeit('""')
0.009867799999998539
>>> timeit.timeit('str()')
0.08838610000000102
huh
Like this ?
cars = ['Ford', 'Volvo', 'BMW']
print('\n'.join(cars))
yes
Well that's fully updated
then you should go see an eye Doctor
If you live near me I can make an appointment
lmao
One message removed from a suspended account.
~~Guyz, I want to convert the type Awesome to MoreAwesome. ~~
Basically I just want to remove the first parameter.
type Awesome = {
fun1: (a: A, b: B) => void
fun2: (a: A, b?: B) => void
fun3: (a: A) => void
}
type MoreAwesome = {
fun1: (b: B) => void
fun2: (b?: B) => void
fun3: () => void
}
nvm, I accomplished that by doing,
type MoreAwesome = {
[Key in keyof Awesome]: (payload: Parameters<Awesome[Key]>[1]) => void
}
hi
@earnest phoenix don't advertise please
where can i
No where!
google ads maybe
@slender thistle are you busy rn?
Err.... yes and no
I see you
Just working on random stuff
can you join general vc
im streaming the new source code for the bot
i wanna show you how i currently got it set up
ngl if you don't know how to proceed from there then it's probably not a great project for you to attempt
DICT() MMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMM.
JUST HAVE PYCHARM CONVERT THEM TO DICT LITERALS
BRO
aye fuck you too :D
One message removed from a suspended account.
LMFAO
We do talk about dict method
ok but why save the command data in a json file
Why not move to bot dev vc bro
oh well
that works too
The way speedian does it is store commands in a CommandHandler
which seems cleaner to me
@rustic nova scam link
Ok but like
Why in a file specifically?
Ah
noice
Neat
Now, about the dict functions...
it looks UGLY BROOOOO
oh yeah true
#UseMongo
speak of the devil
I forgot to reinstall it
lazy ass smh
lmfao
sorta
Pain of reading rST format instead of Numpy
it's okay
__init__ shouldn't even return anything
Line
Nice 
shame on you
Just unmute ez
nah
Skill issue
Laziness
Could give it a try since it doesn't seem all that bad unlike speedian's codebase

kekw
bless your soul
heh

aye
heck is thi
yes
How the fuck am I getting tuples as dict keys
oi
Turns out I was creating another unnecessary list

How to check if someone actually voted for my bot?
webhook
Post that on TikTok and gain yourself a nice audience
wish the sidebar was on the trailing edge
What should my webhook url be??
Wdym by the trailing edge
aka the right edge
Meh
Seems a little small
Even if I moved it over it just seems just up to preference
Imo it looks better on larger screens
Guys please any help?????
The app is a fixed size, and itโs not designed for fullscreen anyways
But it's still pretty big. It's not even centered or aligned with anything!
The app just looks big because of the way I took the screenshot, I believe itโs 640x920, so not very big at all
still big
Anything you want
Huh?
Iโve been pinged
Ye, by unicode
Accidentally
Ok so now that the webhook url is set... what do i do?
Cuz i literally dont know anythin
How do i check if the user voted
Like does anyone have examples?
wtf
client.login just isn't working?
anyone have any idea why? client.login should be the most basic thing of djs but its not working even though this script has been unchanged for 1 day and just now is acting up...
im so fucking confused
maybe it has to do with repl
@unkempt wedge show your code and the error you're getting?
the problem is im getting no errors
const Discord = require("discord.js");
const client = new Discord.Client();
const WOKCommands = require('wokcommands');
const mongo = require("./mongo")
const mongoose = require('mongoose')
require('dotenv').config()
// Hopefully REPL Stuff
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`));
// End of REPL stuff
botVersion = "1.0.0"
mode = "normal"
module.exports = botVersion, mode
client.on('ready', async () => {
console.log('ready')
mongoose.set('useFindAndModify', false);
client.user.setActivity("S.A.M.! stonks?setup\n Need help? there was an inivte here i removed", { type: "PLAYING"});
new WOKCommands(client, {
commandsDir: 'commands',
featureDir: 'features'
}).setDefaultPrefix('stonks?').setMongoPath(process.env['mongoPath'])
await mongo().then(mongoose => {
try{
console.log("Connected to mongo!")
}
finally{
mongoose.connection.close()
}
})
})
client.login(process.env.token)```
Do Bots have the 4000 character limit, or does it still only have the 2000 character limit?
FUCK I PUT A STATUS WITH AN INVITE


thats why you dont copy code without looking through it kids
Ikr.
I think they bypass it.
I tried writing a long suggestion today and I think I went over the 2k limit but the bot was able to image it. Sent it in an embed as 2010 characters; unsure
embeds have 4k limit I believe
It's 2048
I'm so happy my discord bot got approved!
congrats
hey
how to get total stats of all shard ( like users in shard 1 + users in shard 2 = total users)
run a loop over the shards, get the users per shard and just add up the users
can you show me a example
clearly
i am noob at this
if (shardCount === client.config.shards - 1) {
let guildCount = 0;
let userCount = 0;
let memberCount = 0;
let totalUsers = 0;
let channelCount = 0;
for (const shard of (client.client as ClusterClient).shards.values()) {
guildCount += shard.guilds.size;
userCount += shard.users.size;
for (const guild of shard.guilds.values()) {
memberCount += guild.members.size;
totalUsers += guild.memberCount;
}
channelCount += shard.channels.size;
}
console.log(
'Bot is ready!\n' +
'Loaded with:\n' +
`cached users: ${userCount}\n` +
`total users: ${totalUsers}\n` +
`cached channels: ${channelCount}\n` +
`cached members: ${memberCount}\n` +
`cached guilds: ${guildCount}`,
);
} else shardCount++;
},
``` one way to do it
will not work with d.js tho
why ?
bcs its not d.js
ahhhhh
you didnt specified anything so i just pick a random lib and language and give a example
how to do with discord.js i mean
sorry
i mean in discord.js
its almost the same in d.js tho
ShardingManager.shards gives you a collection of shards, just loop over them and get the member count per guild
thanks
my sister will be happy =)))
i'm code the bot with her
that seems awfully long
im pretty sure there's an alternative

for one thing, broadcastEval exists and im pretty sure its for this exact reason
fetchClientValues as well
in Detritus broadcastEval is not a thing
this is discord.js
since he doesnt specify anything i usually just grab a random lib and give examples
he did specify discord.js
who tf uses detritus except ERwin

so use this ?
im not sure how to use it exactly but i'd at least give it a shot before writing a big messy thing like that
it would do the job, yes, but there's an easier way
hi
lo wtf is detritus
The "other" discord lib
js?
One message removed from a suspended account.
One message removed from a suspended account.
oh kk
oh damn
i just checked it out
it seems a lot better than discord.s
*js
anyways i use py so im not gonna be switching to it anytime soon
joined the campaing to advertise? 
fu
@opal plank
i saw, they already saw its a js/ts lib and figured by themselves that its better than discord.js

its the way

also found the example faster than for Selenium
im gonna be VERY honest, it can have some nice optimizations
my code isnt as pristine as it should
but thats mainly for the sake of readability
i could shave off some startup time with some preset configs
but thats not that big of a deal, the main point of the repo is just to show how to do a decent bot
having some fancy logging is nice, sure no one will see it, but it can sort of help in certain situations
What is the latest version of djs
13 beta
12 fully released
So button is available in 12 right?
d.js? no will be with V13, but there is a other npm package for it
Ooo
actually no
but technically yes
Erwin being Erwin
atleast they have sort of out of the box Button support, even tho its made by someone else
imagine a lib that depends on other packages to run as it should

also funfact, lib devs have access to those new things months before they are released, d.js legit had about 3 months to add buttons, and yet hasnt done shit. Every single major lib out there already had buttons before or within the first week
shamefull
but they have a easy way for buttons. and you dont need to reinvent the wheel to do so
still kinky that they havent added it while they had so much time to do so
Hi, I have a little problem. I'm trying to pull the user's servers from discord.com/api/users/@me/guilds, but I'm getting a 401 unauthorized error, I'm using the access token from passport-discord as an access token and I've tried a lot but still can't succeed. Can you explain step by step or tell me the problem?
have you converted ur token?
idk how passport does it
How can I convert the token? Isn't it the code that discord sent in the callback you call token?
did you use oAuth?
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
I did it with passport-discord. I didn't do a direct API transaction.
what you receive from the oauth needs to be autehnticated first
so you get the actual "usable" token, per se
the path is the following
you get 2 tokens iirc, one for authentification and one for refreshing the token
just make sure you send the correct one
oauth => get token => exchange token for access_token => use the access_token for whatever you need
class InteractionMessage {
constructor (client, interaction, readonly){
this._client = client;
this._interaction = interaction;
if(!readonly){
this._message = { data: {
type: 4,
data: {
content: "",
embeds: [],
components: []
}
}}
} else {
this._message = { data: {
type: 4,
data: {
flags: 64,
content: "",
embeds: [],
components: []
}
}}
}
}
send(){
this._client.api.interactions(this._interaction.id, this._interaction.token).callback.post(this._message);
}
setContent(messageString){
this._message.data.data.content = messageString;
}
addEmbed(embed){
this._message.data.data.embeds.push(embed);
}
addButton(buttonObj){
let a = 0;
while(true){
if(!this._message.data.data.components[a]){
this._message.data.data.components.push({
type: 1,
components: []
});
}
if(this._message.data.data.components[a].components.length >= 5){
a ++;
}else{
break;
}
}
if(a >= 5){
console.log("maximum number of buttons reached");
}else{
this._message.data.data.components[a].components.push(buttonObj);
}
}
}
and
const Button = (name, id, style) => {
if(!style){
style = 1;
}
let _buttonObj;
if(style !== 5){
_buttonObj = {
type: 2,
label: name,
style: style,
custom_id: id
}
}else {
_buttonObj = {
type: 2,
label: name,
style: 5,
url: id
}
}
return(_buttonObj);
}
Do I have to post the code I received to https://discord.com/api/v8 ?
what the flying fuck is this
guys, I would like to do a command in the bot DM, but I dont find anything in docs, anyone that can help me? at least the docs page link
check if the channel type is DM
yeah, in the grant
but be aware DMs are annoying to handle
why?
since you dont have direct access to stuff like guilds
Oh thanks, I was going crazy since yesterday
A way to use buttons using djs raw api
@opal plank one more question
sup
Do I need to do oauth2 again and again. Does this accesstoken I get have a validity period?
the other option is to do a command that creates a chat, do the command and then delete the channel
3 months ?
djs13 is taking like 3 years now
you have to refresh the token with the refresh token
like i said you get 2
nah, let me explain how this works a bit better
okay i'm listening
its possible in DMs, but only in some really hacky ways
you get the token with the code
save it to db
then keep using it again and again
i know
so I do the command and then I check if channel === 'DM'
a new user auths => you get sent a code in the headers => you use that code in the /authorize endpoint, that'll give you both a refresh token and the token you'll be using
remember, it has an expiry amount of time
lowecase
unless d.js is retarded, which it might be uppercased
I'm confused, lowercase or uppercase?
Hmmm I see, do I need to send the refresh token in the next request?
lowecase most likely
no
once you got the token, you're good
but dont mistake the 2 things you'll use
forget about refresh token
thats just to regenerate a new token for you
you likely wont be using it
your only 2 concerns are not mistaking the code you receive from oauth with the token you get from the /authorize endpoint
How do I get new tokens with Refresh token?
Did I get right
you don't need the refresh token
it's pretty much useless most of the time
do a POST at /token endpoint
Ok, I'll check them out and try again, thank you very much.
I asked a question but realized it was in the docs๐
oh, aight
https://puu.sh/HQk8Y/0d9ab7858d.mp4 what's up with the borders here 
Dash is making me go crazy istg
fetch("https://discord.com/api/v8/oauth2/token", {
method: "POST",
body: {
'client_id': process.env.CLIENT_ID,
'client_secret': process.env.CLIENT_SECRET,
'grant_type': 'refresh_token',
'refresh_token': "my_refresh_token"
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(res => res.json())
.then(json => console.log(json));
{
error: 'unsupported_grant_type',
error_description: 'Grant type None is not supported'
}
Why is this happening? @opal plank
I use this
await fetch('https://discord.com/api/oauth2/token', {
method: 'POST',
body: new URLSearchParams({
client_id: clientID,
client_secret: clientSecret,
code: code,
grant_type: 'authorization_code',
redirect_uri: URL,
scope: 'identify guilds',
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(r => r.json())
and it works somehow
if(!channel.type === 'DM') return
like this for checking if this is a direct message?
because channel is not defined
Messages have a guild_id property that you can check. If it isn't set, then it's a DM.
how I can implement It in the code?
If you are using discord.js then I can't help you :)
ty same
What library are you using then?
i legit told you 5 times to use lowercase

ops 
client.on('ready',() => {
//client.shard.fetchClientValues('guilds.cache.size')
const promises = [
client.shard.broadcastEval('this.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)'),
client.shard.fetchClientValues('guilds.cache.size'),
//client.shard.broadcastEval('this.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)','this.guilds.cache.reduce((acc, guild) => acc + guild.guildCount, 0)')
//client.shard.broadcastEval('this.guilds.cache.reduce((acc, guild) => acc + guild.GuildCount, 0)')
];
return Promise.all(promises)
.then(results => {
//console.log(`Total member count: ${results.reduce((acc, memberCount) => acc + memberCount, 0)}`);
//console.log(`stats ${client.users.cache.size}Users(turnoffdata),${client.channels.cache.size}Channels,${client.guilds.cache.size} Servers!`);//
console.log(`This SHARD is running with
${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)} Users
${client.channels.cache.size} Channels
${client.guilds.cache.size} Servers
---------------------------------------------
`)
console.log(`TOTAL (current):
${results[1].reduce((acc, guildCount) => acc + guildCount, 0)} total guilds
${results[0].reduce((acc, memberCount) => acc + memberCount, 0)} total members `)
})
.catch(console.error);
Launched shard 1
Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
at ShardingManager.fetchClientValues (C:\Users\Win10\Desktop\bot3 - Copy\node_modules\discord.js\src\sharding\ShardingManager.js:248:75)
at Shard._handleMessage (C:\Users\Win10\Desktop\bot3 - Copy\node_modules\discord.js\src\sharding\Shard.js:326:22)
at ChildProcess.emit (events.js:387:35)
at emit (internal/child_process.js:910:12)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
Launched shard 2
This SHARD is running with
8 Users
14 Channels
2 Servers
TOTAL (current):
5 total guilds
36 total members
???
why error
2021-06-20T08:42:25.632393+00:00 app[Worker.1]: (node:4) UnhandledPromiseRejectionWarning: ReferenceError: channel is not defined
you do know what that means, right?
I know that I have to define channel, but in this case I dont know how
read both
but I already know how to define an object or a variable
if you dont know how to fix this, you seriously lack knownledge about the foundations of javascript
which is why i sent you those 3 docs
help
Typescript would have saved you here lol.
Where's your code?
lol why no one help me =)))
you know ?
hmmm
it's so not important
i use detritusjs, not discordjs
because this is console log
already solved, I'mm only stupid
or noone gives a f

broadcastEval? What a scary sounding monster. What has discord.js done?
wait does my bot need to get approved to get the Bot dev role
ok
why ?
i never understood why their cluster manager doesnt have access to the children
for example, rather than ts Manager.broadcastEval('return this.guilds.cache.size')
do
<Manager>.shards.map(s => s.guilds.cache.size)```
Fine fine. You are getting this error because you are trying to access shards before they have spawned. Good luck fixing it ๐
i am quit up
=))))
It would depend if they are in a different process.
a normal person would use a worker, which has built in IPC pipes
shards are not created all at the same time, they have a 5 second delay
your code is running twice, once in each shard
the first time it runs, only the first shard is ready, the second is not
thats why the error
fixed
oh but still thank to you Tim
Thanks!
i know it =))
but
oh what ever this is not important
oke
catch the error is better
client.on('ready', () => {
//console.log(stats ${client.users.cache.size}Users(turnoffdata),${client.channels.cache.size}Channels,${client.guilds.cache.size} Servers!);//
console.log(This SHARD (${shard.id +1}) is running with ${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)} Users ${client.guilds.cache.size} Servers ${client.channels.cache.size} Channels ${client.emojis.cache.size} Emojis ---------------------------------------------)
const promises = [
client.shard.broadcastEval('this.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)'),
client.shard.fetchClientValues('guilds.cache.size'),
client.shard.fetchClientValues('channels.cache.size'),
client.shard.fetchClientValues('emojis.cache.size'),
];
Promise.all(promises)
.then(results => {
console.log(Total (current) ${results[0].reduce((acc, memberCount) => acc + memberCount, 0)} Users ${results[1].reduce((acc, guildCount) => acc + guildCount, 0)} Servers ${results[2].reduce((acc, channelCount) => acc + channelCount, 0)} Channels ${results[3].reduce((acc, emojiCount) => acc + emojiCount, 0)} Emojis );
})
how to put ${shard.id+1} into a code without error
i quit up
and replace with
This SHARD (1/2 or 2/2) is running with
for easy =))
haha
anyway no body can see my console.log
just add a catch in Promise.all
guildupstatus-object-promise ahhh
why after i create a shard
and run it
a server is add bot in
and the total guild is not update
you didnt resolve the promise
client.on(`guildCreate`, async guild => {
if (guild.id === `538361750651797504`) {
//blacklist server
return;
}
await guild.members.fetch(guild.ownerID)
client.shard.fetchClientValues('guilds.cache.size');
then(results => {
const create = new Discord.MessageEmbed()
.setColor("#2bda00")
.setTitle(`New guild add loli bot yeah!`)
.addField(`Current guild now`, `${results.reduce((acc, guildCount) => acc + guildCount, 0)}`, false)
.addField(`Guild Name`, guild.name, false)
.addField(`Guild ID`, guild.id, false)
.addField(`Member Count`, guild.memberCount, true)
.addField("Humans", `${guild.members.cache.filter(member => !member.user.bot).size} `, true)
.addField("Bots", `${guild.members.cache.filter(member => member.user.bot).size}`, true)
.addField(`Owner`, guild.owner.user.tag + `[` + guild.owner.id + `]`, false);
client.channels.cache.get(`688393107821428766`).send(create);
let myGuild = client.guilds.cache.get(`629882029562920980`);
let guildCount = `${results.reduce((acc, guildCount) => acc + guildCount, 0)}`;
let guildCountChannel = myGuild.channels.cache.get(`700002993054941224`);
guildCountChannel.setName(`GuildUpStatus: ` + guildCount).catch(error => send.processes(client, error));
});
also
just a friendly reminder that addFIELDS with an S works
you can only change channel name 2x every 10 minutes
and your human and bot count requires fetching all members
client.on(`guildCreate`, async guild => {
if (guild.id === `538361750651797504`) {
//blacklist server
return;
}
await guild.members.fetch(guild.ownerID)
client.shard.fetchClientValues('guilds.cache.size').then(results => {
const create = new Discord.MessageEmbed()
.setColor("#2bda00")
.setTitle(`New guild add loli bot yeah!`)
.addField(`Current guild now`, `${results.reduce((acc, guildCount) => acc + guildCount, 0)}`, false)
.addField(`Guild Name`, guild.name, false)
.addField(`Guild ID`, guild.id, false)
.addField(`Member Count`, guild.memberCount, true)
.addField("Humans", `${guild.members.cache.filter(member => !member.user.bot).size} `, true)
.addField("Bots", `${guild.members.cache.filter(member => member.user.bot).size}`, true)
.addField(`Owner`, guild.owner.user.tag + `[` + guild.owner.id + `]`, false);
client.channels.cache.get(`688393107821428766`).send(create);
let myGuild = client.guilds.cache.get(`629882029562920980`);
let guildCount = `${results.reduce((acc, guildCount) => acc + guildCount, 0)}`;
let guildCountChannel = myGuild.channels.cache.get(`700002993054941224`);
guildCountChannel.setName(`GuildUpStatus: ` + guildCount).catch(error => send.processes(client, error));
});
})```
(node:20460) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at C:\Users\Win10\Desktop\bot3\index.js:144:50
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:20460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:20460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js proce
and you probably want to guild.leave() your blacklisted servers
client.shard.fetchClientValues('guilds.cache.size').then(results => {
you mean this ?
no
client.channels.cache.get
and client.guilds.cache.get
cache is only for the current shard
so remove cache ?
if the guild is in the other shard, this will be undefined
it is more easier if you rewrite
sorry =((
client.shard.broadcastEval
you mean ?
if(!client.channels.cache.get(...)) await client.channels.fetch(...)
that would be the easiest way
you will have duplicated caches, but its fine if its just a couple channels
also you dont need the myguild
just fetch the channel directly
client.channels.cache.get(688393107821428766).send(create);
so addition on this line ?
before that line
or just do this ```js
let channel = await client.channels.fetch(id);
channel.send(create);
screeches in promise rejection handling and conditional chaining
chandling
shush





