#development
1 messages · Page 947 of 1
not correct.
With agrs
pls accepted Claw bot
-faq 2
how can I find out the path to the command in error?
code:
process.on('unhandledRejection', error => {
webhookEr.send(` ${error}`)
})
error.stack
thx
What would happen if the unhandled rejection was something like not allowed to send a message to the channel, you send that and it throws the same error 
you tried to pass an empty string
if ( message.author.id != 518738198982295564 ) return; would make the bot only respond to this id, right?
my bot is getting ratelimited when reacting to embed, what is the recommended delay i should put between these to solve this issue?
yes
await
and it only accepts emoji.
it also accepts emoji ids
it accepts unicode
you could use set timeouts of like 1 second, maybe 500 milliseconds
if there is a unicode counter part in discord
but it also accepts emoji IDs
TypeError: "file" argument must be a non-empty string**
Could not extract html5player key: https://www.youtube.com/s/player/4583e272/player_ias.vflset/en_US/base.js
so with discord.js there is a way to check if a member is mentioned, but how can i check if the mention is at args[0] and not at args[1] for example?
i know
Then you'll have to split up the message and search for the mention
hi
with mongoose, does anyone know why js await guild.updateOne({ $push: { 'moderations.user': member.id, 'moderations.mod': message.author.id, 'moderations.reason': reason } }); isn't updating in the db? it just creates { _id: object id } for some reason
@tight plinth
if(commandArgs.length === 0){
// Do stuff here if there is no args
}else if(msg.mentions.users.first()){
// Do stuff here if there is an arg
}```
hmm
@digital ibex I use this for my updates
await client.database.collection('analytics').updateOne({
command: commandToRun.name
}, {
$set: {
commandCount: commandStats.commandCount + 1
}
})```
Regex is slow btw, so I would try to use something like includes
the way i'm doing usually works, idk why its not working here
idk what stupid mistake i'm doing
Can you log the entire event to see what its returning?
no its uh, creating the field thing, with the object id, but its not adding the data i want, moderations.whatever
Test it without $push, maybe its that
ok
try my format see if it does anything
i don't see how it can be that as moderations is an array
its an object not an array
this is an object
yes
oh i see u
u use the push operator on an array, and when u have values in that array u wanna update, its $push: { 'array.object': whatever }
Lemme check some things
could someone go to DM's with me and check my webhook? it doesn't seem to be working. discord.js v12
it used to, i don't know if it was because i upgraded to v12, theres no errors when someone votes but what used to work no longer does
You could just post it here
alrighty
// bot client blah blah
bot.dbl = new DBL(process.env.DBLTOKEN, { webhookServer: server, /*webhookPort: 5000,*/ webhookAuth: process.env.DBLKEY }, bot);
// haven't seen this log in a while
bot.dbl.webhook.on('ready', hook => {
console.log(`📯 Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
actual webhook for votes: https://hastebin.com/osihawoboj.js
a few weeks ago when i would vote or anyone, it would go through, then around the time i updated to v12 it wouldnt log or send any message anymore
no errors at all
@me if someone figures it out
time for debug lines 
message.guild.channels.create('Bla Bla', 'category', [{ id: message.guild.id, }])
text channel create
not category :(
yes?
I think I already know the answer to this.
However when you edit a message you cant just remove the message content and replace it with an attachment correct?
it don't detect vote, why is bot not work, I'll invite you to my project so you can fix it for me
I've seen some people actually say such stupid things lmao
errors?
@earnest phoenix read docs
dude
that's not how you create a category
and you can't assign an id
how does that even make sense
I'm out
If you're not willing to help, why comment
hi
My message was lost in transmission but I figured it out.
any1 kno why this aint updating in the db? it creates the object id, but not the other data
code:
await guild.updateOne({
$push: { 'moderations.kick' : {
user: member.id
}}
``` using mongoose
@tight plinth pardon the tag, it doesnt detect the vote
it used to log in a channel every time someone voted
then around the time i updated to 12 it stopped
i updated the code
fetch and embed
try to debug
moderations is js moderations: [ { kick: { user: { type: String }, mod: { type: String }, reason: { type: String } } } ],
is there a good way to generate a new Embed message if the embed reaches 2000 chars? I work with an API that fetches the droprate of an item and it can return about 200 locations
With version 12 of discord.js, calculating specific ping values has become a bit more complicated. How can I calculate the various pings of the bot?
you could just make it interactable with emotes if you could
I dont think its good that you try to print everything with multiple embeds, try to keep everything with one embed
@earnest phoenix let ping = m.createdTimestamp - message.createdTimestamp huh ?
or use .then(m => {})
any suggestions how to split an array into chunks with an for me unknown amount of keys inside. (node.js)
the api can return somewhere between 1 to 6k keys
how long do you want the chunks to be?
10 to get them into an embed
one of them is the heartbeat of the server
first one might be server latency (how long it takes for the server to process the command?)
Okay but, if it returns 6k keys, then you'll have to send 600 embeds, right?
the sec one ?
want to make it a single embed that reacts to emojis
how long it took for the bot to acknowledge the ws heartbeat is the 3rd one
bcs sending 600 embeds is stupid
Hey
api latency, round-trip latency, and heartbeat latency
no clue what the 2nd one is
oh
I would assume anyways
how i can get the round-trip
no one of those values definitely feels like server latency since there's three
then again
it's pretty vague
a naïve way would be to wait for it to send, get the timestamp of creation and edit it with subtracting now - creation but it's not really correct
That's how most people do stuff like that though
2020-05-02T13:44:25.787Z how i can make this to readable date
:((
with converting timestamps
how . . . .
js i assume?
what do you get? https://oliy.is-just-a.dev/sboi5c_4047.png
oh it's not gonna embed
@earnest phoenix pretty colors
lol, also are you wanting a real timestamp?
If you need that you can convert it, its an epoch time by default
but howww
Where do you define bots.date?
dblapi.js
oh that probably returns a timestamp
do new Date(bots.date).toLocaleString()
That also works ☝️
ok
new Date("2020-05-02T13:44:25.787Z").toLocaleString()```
but do i have to require the module u sended
No, Dates are built in
Hi, I'm trying to implement code where the user can set the specific channel for a bot to respond to
Initially I was looking to locate by specific channel name, but I think you could only do it by channel id right?
Also, I'm using discord.py, should we change to .js instead in this case?
Heres the code:
# Say
@client.command()
async def say(ctx, *, content):
await ctx.message.delete()
#channel = discord.TextChannel.name('test')
#channel = client.get_channel(715038598361120779)
await ctx.channel.send(content, channel)
Rn I think we're just trying to make it recognize by name on the same server, but it doesn't seem to work
Its honestly easiest by ID then you can parse the ID to a name by getting the channel info
Just... use the channel converter
I don't know much PY Py so listen to others
type hinting
type annotation
Whats that lmaoo
Basic python stuff 👀
1) await db.collection('codes').doc(zaehler).get().then((q) => {
console.log(q.data().inviteCode)
});
2) for (let index = 0; index < counter; index++) {
zaehler = toString(index)
await db.collection('codes').doc(zaehler).get().then((q) => {
console.log(q.data().inviteCode)
});
}
Why does the first work but the second says "inviteCode" is undefined?
Why i got this error in console even if i have quick.db installed? Cannot find module 'quick.db'
glitch?
no
ok
is there a way to get the time not being milliseconds after January 1, 1970 in javascript? like saying: 19:42 GMT 28/05/2020?
1) await db.collection('codes').doc(zaehler).get().then((q) => { console.log(q.data().inviteCode) }); 2) for (let index = 0; index < counter; index++) { zaehler = toString(index) await db.collection('codes').doc(zaehler).get().then((q) => { console.log(q.data().inviteCode) }); }Why does the first work but the second says "inviteCode" is undefined?
@earnest phoenix woah. what's that language?
is there a way to get the time not being milliseconds after January 1, 1970 in javascript? like saying: 19:42 GMT 28/05/2020?
@still merlin i know how to do it on python if u want
@spark raven javascript
@mossy vine oh alrighty
i said javascript thought i dont want python

tysm
Yuu
Hate to be a pest but I did something like the mozzila website said and its undefied? can someone help
code:
let args = message.content.substring(prefix.length).split(" ");
switch (args[0]) {
case "time":
message.channel.send(`The time is: ${getGMTDay()} ${setGMTCHours()} GMT`);
break;
}
});```
Terminal:
``` message.channel.send(`The time is: ${getGMTDay()} ${setGMTCHours()} GMT`);
^
ReferenceError: getGMTDay is not defined
at Client.<anonymous> (C:\Users\Jon\Desktop\SpiderBot Project\index.js:437:28)
at Client.emit (events.js:224:7)```
Did you define getGMTDay
you have to do something like
let something = new Date()
message.channel.send(`The day is: ${something.getGMTDay()})
I'm tryna make a 'whois' command via user-id.
But when I use <client>.fetchUser(args[0]), and there is for example a mention instead of id it will give an error.
How can I prevent this from happening
and you could do message.createdAt which is easier in my opinion
@earnest phoenix code?
let member = bot.fetchUser(args[0]) || msg.mentions.users.first() || message.member;
console.log(member);
discordv12 or v11
12
whats the error?
Also, since your using discord.js v12
you have to use the manager
im getting UnhandledPromiseRejectionWarning: ReferenceError: error is not defined
but thats not from this
ofc
well try it first with bot.users.cache.fetch()
Also members and users are two different things
yea
well do you want user or member
member
fetch returns a promise so you'd have to await it
discord.py, how do i send a message to a specific channel id?
you get the channel and send a message
im not a expert in d.py but i can look it up
channel = client.get_channel(channelIDAsInt)
await channel.send("AAAAAAAAAA")
@wide ruin
thanks

if ( message.author.id != 518738198982295564 ) return;would make the bot only respond to this id, right?
Didn't get an answer so I quote this again
@ me in response, thanks
@fallow steppe what language.
@fallow steppe put id in quotes '518738198982295564', and yes
if they're using discord.py it may be fine
I need help apparently my bot is reacting to any prefixes I give out (d.js)
did you check if the message started with the prefix
if(!message.content.startsWith(prefix1)) return;
where u check?
its at the very top of bot.on("message", async message => {

idk why my bot is reacting to
!!
@@ or just any 2 lettered prefixes when my bot's prefix is only e/ and E/
Do you have more than one message listener
@smoky spire sorry for ping if u hate being pinged but no.
@iron scroll try data.body instead of data when you define artist and name
@obtuse wind well even if your prefix check isn't working, the bot would get stopped by the message.author.bot check, so some other message listener is running
because I have way too much time on my hands, I'll start again from scratch anyway my bot has some bugs in it that I never got to fix such as misspelling and not actually logging the errors to the logchannels that I have defined at the top as well 🤷♂️
@iron scroll did you initialize artist and name as constants
That's why I'm asking
It's probably assigning targetsong before the .then is resolved
that if statement is wrong
checking for undefined is a hard task
just check for !data
if (!data)
I mean one factor for both being undefined is the fact .then(() => {}) is a promise.
@copper cradle i delete if, but it returns undefined - undefined
You could even console.log it within the then block and see if artist and name are strings
are you sure trackId is not undefined?
He said all the data logs correctly in the then
He said all the data logs correctly in the then
That explains
In js, how is it gonna be possible to set more than one useful prefix? Since I only know it's possible to have one but not sure how to make two
For example, g! and @bot#124 work as prefixes
Simple if(a||b||c)
const prefixes = ['g!', 'gb!'];
prefixes.map(p => message.content.startsWith(p)).length > 0```
@fallow steppe
Aight
Well I found my problem "prefix1" its sposed to be "prefix2" prefix1 is for spechal commands
Except that I use prefixes this way
And I have it setup as a custom prefix, so if anyone changes it I'd want it to change the g! and keep the mention
oh
it isn't that hard to imolement
idk how to set up custom prefixes for servers so I just made my local prefixes
e/ (E/ works too for people who are on mobile)
and people who have certain userIDs are my bot global "admins" or "bot masters" get e:/E:
so?
Also, how do I make the bot respond to edited messages? I know bots that can do that, so Im curious about it
Ex. If message was g!help and was changed to g!ping, it will respond to the new edited command
I was wondering about that too, but it seems like a lot to integrate
just check for the edited message
duh
and parse its content
just like you normally do
Why my bot keep spamming one message 70times?
I have 7commands, only 1 is like that
client.createMessage(msg.channel.id, "Здравей, командите на бота са help Пише командите на бота!" )
Oh i found it.. its because i wrote it in multi langluage
@fallow steppe some frameworks have that built in
can i make the bot to sent a picture but to hide the link
https://imgur.com/P75uaBW like this
Send the image as an attachment
Like?
because i want when people write !help to see
1.admin - the command tell who is online from admins
2.owner - ......etc...
but it write it like 1.admin - the command tell who is online from admins 2.owner -
could someone help me with my webhook code to receive votes in DMs?
i have debugged every event, no logs
@fresh hatch ```js
msg.channel.send(new Discord.MessageAttachment("url", 'tiktok.mp4'))
with discord.js
message.channel.send({files: [url1,url2..]})
``` works too
or one from disk:
message.channel.send({files: [{name: "E.png", attachment: "path/to/file"}]})
any help, im getting this error https://prnt.sc/spnnch when i try to get image_url from api https://api.ksoft.si/meme/random-meme
Hi, how i can delete a channel (voice) if the number of members of this channel is 0 and if this parent categorie is : IDTEST for example ?
How do I get a YouTube API key
Google it
...
@earnest phoenix members
idk how to do that
@autumn compass you didnt provide an API key
thanks for the help
im not sure where you would get it though
i've been reading the docs, doesn't seem to say it anywhere
but then again i might just not be looking in the right place
So, i'm trying to run my discord bot on heroku and i get a sodium_init undefined symbol error
Does anyone have any information as to why?
I had built it twice already and it was successful both times.
Not sure what the problem is with libsodium
also, i'm using discord.js v12 btw
Hello I have some problems with my OAuth2 login on my Website. I didn't touched my code, but It doesn't login the user anymore
My code:
And then:
method: 'POST', headers: { Authorization: `Basic ${creds}`
Have a question regarding Avrae bot in my discord. When using the !a function with custom actions it seems the bot requires there to be a damage dice associated with it. But I’m looking to have the bot recognize attacks with flat damage similar to “unarmed strike” but I can’t figure it out.
@cosmic dew ask here instead: https://discord.gg/pQbd4s6
Thank you
Rip Avrae since Dnd beyond brought it
okay so i made a join message and its an embed and i want to make the .setImage the members avatar what should i use to make it their avatar
im using discord.js\
<@&304313580025544704> My bot is online and working but the online status is not reflected on discord bots server (https://top.gg/bot/536870384474128384). How do I correct that?
-atmods
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
Omae wa mou shindeiru
okay so i made a join message and its an embed and i want to make the .setImage the members avatar what should i use to make it their avatar
im using discord.js
No ping moderator role, mods will be mad and sad ;-;
just give it some time @livid swallow
ive been waiting for a reasonable amount of time
ping one of us if it still isn't working within 30 mins @livid swallow
hi
\
await guild.updateOne({
$push: { 'moderations.kick' : {
user: member.id
}}
``` anyone know why this doesn't update? i'm using mongoose, it creates an object id but doesn't add the data i want
what library
moderations is ```js
moderations: [
{
kick: { user: { type: String }, mod: { type: String }, reason: { type: String } }
}
]
mongoose
what library
mongodb, mongoose
yeah ive never even heard of those good luck
LOL imagine being asked what coding library you use and you answer with the name of the DB 🤦♂️
because its a db question?
his problem is with using mongoose, what's y'alls problem
okay so i made a join message and its an embed and i want to make the .setImage the members avatar what should i use to make it their avatar
im using discord.js
ohh
it all didnt work because i forgot ()
thank you
.setColor('#FF0000')
.setTitle(`${member.user.username}`)
.setDescription(`Goodbye, ${member} we really hope you enjoyed\n being with us.`)
.setImage(displayAvatarURL())
.addFields(
{ name: 'UserId', value: `${member.id}` },
{ name: 'UserDiscriminator', value: `${member.user.discriminator}` },
{ name: 'AccountCreationDate', value: `${member.user.createdAt}` },
{ name: 'FullUsername', value: `${member.user.tag}` },
)
channel.send(embed)```
alr what should i do my error is
```ReferenceError: displayAvatarURL is not defined```
@earnest phoenix
Reread his answer
bot.on('guildMemberRemove', member => {
its member
so
member.displayAvatarURL
?
yes
member.user
TypeError: member.displayAvatarURL is not a function
member.user
then member.user.... i don't use d.js
member.user.displayAvatarURL()
don't answer questions about djs if you don't know djs 
clearly you don't know much
thats unfortunate for me
.setImage(member.user.displayAvatarURL({
format: "png",
dynamic: true,
size: 128
}))
@clever garnet try something like this.
member.user.*
sorry for the side question
but what does dynamic do?
i havent messed around with the settings of avatar URLs
Could someone help me with cloudflare? https://prnt.sc/spqbdj (its an express server hosted on port 1000) im using portzilla on cloudflare
I used dns checker
and apperently it works
<@&roleid>
try that
when it doesnt work, check the role
if its pingable, discord has a seizure
when its not ur idot
@wet dove and @sinful belfry Thank you 😊
bit of a design question but if i need to display a list of servers for eg, should i use a table or something like a grid to show them in groups
I don't have many experience with 'designs' but I feel like a grid would be nice.
so like 3-4 servers per row
all i need to show is an id (1-12 chars) and a link so yeah
what do u guys think is better for user modlogs
1: js type-of-action: { user: user, mod: moderator, /* other data */ } /* eg */ ban: { user: member.id, mod: message.author.id, /* other data */ } or 2: ```js
user: {
type-of-action: [
{
mod: moderator
},
]}
/* eg /
'1234567': {
ban: [
{
/ data */
}]
}
i assume you're talking api struct
just for a users modlogs in a db
generally i follow a layout like this
{
time: Date,
target: Snowflake, // user
user: Snowflake, // mod
actions: [
// allows to batch multiple actions
{
type: Number, // 0 for ban, 1 for kick, etc...
reason: String
}
}
}```
hm, thank u. i'm gonna look into it for a bit
see which ones most efficient and stuff
Define giveaway?
🤔
here's my shitty minecraft plugin code that i used to sell back in 2019, feel honoured yet?
@earnest phoenix
well we dont know what giveaway is
we dont know anything about your code
except that one condition check
how are we supposed to help you then?
so you know how when you start a shard or multiple of a discord bot it splits which guilds are controlled by which shard right?
so what if i wanted to host the bot on multiple docker containers
with something like swarm
instead of having it all started from one process
like 10 shards per container
for future reference
though don't ask anything else here if you're not ready to share code
any reasons why this doesnt work or what am i doing wrong?
class Emojis {
get guilds() { return client.guilds } // client is defined as a client lol
*[Symbol.iterator]() {
for (const guild of this.guilds.cache) if (guild.available) for (const [id, emoji] of guild.emojis.cache) yield [id, emoji]
}
entries() {
return this[Symbol.iterator]()
}
*keys() {
for (const emoji of this) yield emoji[0]
}
*values() {
for (const emoji of this) yield emoji[1]
}
}
im probably doing it all wrong but
Is possible play spotify via lavalink?
How can I fetch a message with the id?
can I have a code to make a bot?
ok
what language is that
if that's js then wtf
@copper cradle yeah that's JavaScript. but with generator functions (*).
uhm i have this
const channels = guild.channels.cache.find(channel => channel.name === `exchange-${exn}`) channels.send('<@&713541593121947699>, <@'+message.author.id+'> wants an exchange with note: '+details)
but it says cant send to undefined
How'd I check for a specific reaction id.
Lang/lib?
I am working on a discord bot in the rewrite in discord.py and I receive messages using the code below:
input = get_input_of_type(int, ctx)
I am trying to add a reaction using .add_reaction but cannot since the variable input is a string and not a message object. Interestly enough, if I dont specify to use a int I am returned with the member object. Sadly I have to only accept integers so this is not a fix. Is there any other way?
Pika where is exn defined, also maybe make it message.guild
D
@crystal socket what is get_input_of_type?
@warm marsh, discord.js v12,
listen to the reaction event and then check if it's that id.
<textchannel>.messages.fetch(id)
<dmchannel>.messages.fetch(id)
Thanks.
(node:4994) 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(). (rejection id: 3)
(node:4994) [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.```
anyone have this fix?
congrats, you managed to show (almost) everything but the actual error
congrats, you managed to show (almost) everything but the actual error
@mossy vine lmao
let chunks = [],
i = 0,
n = arr.length;
while (i < n) {
chunks.push(arr.slice(i, i += len));
}
return chunks;
}```
any idea how to prevent this from caching a result from a previously ran command?
why would that function cache anything from any time it was previously ran?
it does for some reason
it really shouldnt
i know
oh and for my problem it only shows up when i execute that command
unless you have defined chunks globally/outside the function scope
but i get cached results from it
i get an json from an API with an undefined amount of keys. i chunk them down to 10 results for displaying them in an Embed
already logged the result from the API and this is as expected
i have running it in a command and the command caches it. but i think i know my issue
can someone help with this
this is my code: https://pastebin.com/diOnFfeC
this is my error: https://pastebin.com/agKNrGDt
and the error only happens when i execute that command
we cannot see the code
there
Still unable
As i see from error, you put empty second parameter for embed field
Still unable 
That's not how addField works, it accepts 2 parameters: A title and a description
oh
In all of those you just provide a title
.addField(name: string, content: string)
ok
Instead of .addField('') use .addBlankField(inline: boolean)
ok
if you leave it out tho it should return undefined instead of an error
srry
There's no addBlankField in v12

so this? im new to javascript btw
client.on('message', message => {
if(message.author.bot) return;
if (message.content.toLowerCase() === 'jsbotlist')
{
const embed = new Discord.MessageEmbed();
embed.setColor('BLUE');
embed.setAuthor(client.user.username, client.user.displayAvatarURL);
embed.addField('name: title content: jsbot1 --just makes the bot say Ree.');
embed.addField('');
embed.addField('name: title content: jsbot2 --Sends an embed message im going to change it soon!');
embed.addField('');
embed.addField('name: title content: jsbotlist --Well... you are here.');
message.channel.send({embed});
}
});
Not
Thats parameters you need to defined, and types of them
.addField(name: string, content: string)
Means that you need to use.addField('Example', 'Test content')
ok
so
embed.addField('List', 'jsbot2 --Sends an embed message im going to change it soon!');
```like that?
Yes
Whad do you mean
Anybody else having issues with the DBL api?
any reasons why this doesnt work or what am i doing wrong?
class Emojis { get guilds() { return client.guilds } // client is defined as a client lol *[Symbol.iterator]() { for (const guild of this.guilds.cache.values()) if (guild.available) for (const [id, emoji] of guild.emojis.cache) yield [id, emoji] } entries() { return this[Symbol.iterator]() } *keys() { for (const emoji of this) yield emoji[0] } *values() { for (const emoji of this) yield emoji[1] } }
yeah its valid js 
or not, seeing as it doesnt work but
but where did i go wrong
OH WAIT
nope i didnt solve it
nvm it did
I found a way that you can that you can check for the user's avatar ID and check if it starts with a_ to know if the user has discord nitro, but how's it possible to check if the user has discord nitro if their avatar isn't animated?..
Lemme try
there's a user property for that iirc
nvm
i checked xhr requests tho premium_since
user flags have an early nitro supporter flag but other than that idk
There's a premium_type property but only accessible through oauth2 authorization
yeah didnt that exist before?
But i have no idea how that works
anyway i think its like
U need to check if user has nitro?
Yea like add the nitro and nitro booster badge if user has that to their userinfo
when there is xhr profile request, there is premium_since property
that not exists if user no has nitro
anyone here?
You talking about the guildMember premiumSince or the user itself?
thats your profile
embed.add_field(name='Permissions:', value=member.permissions_in())
can someone tell whats wrong
I need help, how to get bots developer verified badge?
@earnest phoenix i mean... I can't have access to that file of their discord client without oauth2 authorization
@earnest phoenix verify ur bot
@earnest phoenix read #502193464054644737
@earnest phoenix 
@earnest phoenix can u help me pls
@earnest phoenix but
still u can check other user profiles
@earnest phoenix verify ur bot
@earnest phoenix But verifying the bot requires some requirement?
@earnest phoenix yea but with what lol
@earnest phoenix 100 guilds then
Wait lemme try something
Oh sh*t
75 i think
But it serves to create random servers and put your bot there or it must be different owners of the server?
const fetch = require('node-fetch');
function hasNitro(id) {
return new Bluebird((resolve, reject) => {
fetch(`https://discordapp.com/api/v6/users/${id}/profile`, {
headers: { 'authorization': client.token },
json: true
}).then((resp) => {
if(!!resp.json().premium_since) return resolve(true);
return resolve(false);
}).catch(reject);
});
}```
@earnest phoenix try that
i think there was even a check for that
But it serves to create random servers and put your bot there or it must be different owners of the server?
@earnest phoenix fake servers not counted
@earnest phoenix k
user.premium or something cant remember
@earnest phoenix await hasNitro(id);
@earnest phoenix fake servers not counted
@earnest phoenix a ok thanks
ye user.premium exists
@earnest phoenix k
@earnest phoenix if u see 'Bots cannot use this endpoint' try enter your token
@coral stirrup not
@earnest phoenix k
was that removed?
Thanks for the help and excuse my English, I don’t know much truth, I’m from chile
Im from Ukraine okkk
That explains
@coral stirrup ClientUser is your bot client
require('discord.js').Client.user // ClientUser
i think there were some other too
but not sure
If i messed this up
Yeah thanks you dont have to explain to me what a clientuser is
kk
sqlite 
couchdb all the way
json files

F
😛
json files
I started with that until someone told me it was really bad haha
mysql/sqlite
seems like from the reviews I'm watching
i mean, it is ok for small things
like, i have a json data file for storing my app version
thats ok
it auto updates when i reboot the app
yeah when you don't read/write too much from that file is fine
but anything thats critical, no way its going to json without a backup
oh actually as a side note
i've been saving the questions from my quid command that gets questions from opentriviadb website
into a json file for a backup of questions
but again, not critical
quiz command*
i have an issue with an interactive embed. I try to limit how many pages are aviable over the amount of keys in an array, but what i thought is not working if(n>=chunked.length){n=n} else{ n++}
just want to make sure that the number wont increase bcs otherwise it will break it
if(!(n >= chunked.length)) n++;
when you sit to long infont of an issue you forget the simple things for simple issues
what u want to make
its a command that fetches drop data from an API and then display it in an interactive Embed, bcs the api can return around 6k keys i chunked the array into 10keys per chunk. the number is the index for the key
this line is just for preventing to get past the aviable pages in the Embed
const _ = require('lodash');
_.chunk(array, size);
// ex:
_.chunk([1, 2, 3, 4, 5, 6, 7, 8], 2); // [[1,2],[3,4],[...]]
got the chunking already done
the issue was just i can break the command by going past the number of pages that are aviable
Is there difference between using ' or " or `
U make 'book'-embed?
In js
' and " no
more or less yes
in ` u can use code parts
yeah I know that
'Test ${2+2}' // 'Test ${2+2}'
`Test ${2+2}` // 'Test 4'```
than ur issue is when u list backwards, commands breaks?
How do you guys use bot events in different files?
lang?
js
in js, the most common way is to have the event call a function from another file
is that the same as using module export with node?
In discord.js is client.ws.ping in milliseconds?
prob
const fn = require("./anotherfile.js")
client.on("message",fn)
oh
nice, thank you
@still merlin yes
ok tysm
So I just get the arguments of the event in the file right @quartz kindle ?
Ex of channelDelete Event:
module.exports = {
async execute(channel) {
console.log('A channel got deleted');
}
};```
@rigid maple the command should look something like
bot.on("message", msg => {
let args = msg.content.substring(PREFIX.length).split(' ');
if (!msg.content.startsWith(PREFIX)) return;
switch (args[0]) {
case 'botjoin'
msg.channel.send('bot joined at', msg.("bot's user ID here").joinedAt)
break;
}
})
its formatted horribly, sue me
thanks
@opaque seal yes, but you need to export the function itself, you're exporting an object containing the function
otherwise you have to use it like this ```js
let fn = require("./myfile.js")
client.on("message",fn.execute)
thanks
@rigid maple let me know if it works
uhhhh
@opaque seal yes, but you need to export the function itself, you're exporting an object containing the function
function channelDelete(channel){
console.log('A channel got deleted');
}
module.exports = channelDelete();```
Should be good right?
@rigid maple dm me
otherwise you have to use it like this ```js
let fn = require("./myfile.js")
client.on("message",fn.execute)
wouldn't that be more efficient or is it the same thing
@opaque seal module.exports = channelDelete(); -> module.exports = channelDelete;
How can I fix this?
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
xD
wait
It's a music bot, it happens sometimes when I put a music
seems u defined nothing instead of string
show full error
what about use js beautifier?
what's that? xd
var a = do();fucntion do() {return 1};
into ```js
var a = 1;
try https://beautifier.io/
ooh
nice
and as i can see, error in one of node modules
oof xD
otherwise you have to use it like this ```js
let fn = require("./myfile.js")
client.on("message",fn.execute)wouldn't that be more efficient or is it the same thing
@quartz kindle
its the same thing
but you must export the function itself, not the executed function
So there isn't any downside if I use the execute?
module.exports = functionName
not
module.exports = functionName()```
// file.js
module.exports = (message) => {
message.reply('works!');
}
// general
const messageHandler = require('./file.js');
bot.on('message', messageHandler);```
@opaque seal
there is probably a microscopic performance advantage to exporting only the function, over having it contained in an object
Ok I'll do that then
but if you contain it in an object, you can use it to define more properties to it than just the function
like the name, description, etc
so depends on how you want to use it
yeah probs not
How can I get the client from the function?
async function raw(event){
//Listen only to reactionAdd events
if(event.t !== 'MESSAGE_REACTION_ADD') return;
let client = event.client;```
That's what I've tried, I don't really know how to get it
all discord.js structures have a .client property
I need to use the bot client in the function
the raw event is not a discord.js structure
Uhm
So... I can't use the bot client in that function?
Should I just put this raw event in the index?
you will have to pass client yourself
at this point I'll just put it in the index
client.on("raw", r => myfunction(r,client))
if you applied, it takes 1-2 weeks for approval
bot.on('raw', async (packet) => {
if(packet.t != 'MESSAGE_REACTION_ADD') return;
let channel = bot.channels.cache.get(packet.d.channel_id);
if(channel.messages.cache.has(packet.d.message_id)) return;
channel.messages.fetch(packet.d.message_id).then(message => {
const emoji = packet.d.emoji.id ? `${packet.d.emoji.name}:${packet.d.emoji.id}` : packet.d.emoji.name;
const reaction = message.reactions.cache.get(emoji);
if (reaction) reaction.users.cache.set(packet.d.user_id, bot.users.cache.get(packet.d.user_id));
bot.emit('messageReactionAdd', reaction, bot.users.cache.get(packet.d.user_id));
});
});```
Lol, anyway in quarantine 1 week are 2 years if you have to wait for a while
Hi, how i can show user flags name? I use this member.fetchFlags().then(u => u.serialize()) and return to me [object Promise] :c
Unless you have some way of entertaining yourself and time flies by
@plucky heart await
@plucky heart if you use .then(), the result is only available inside the .then() and not outside of it
if you want the result to be available outside, you need to use await instead of .then()
member.fetchFlags().then(u => {
// result exists here
});
// result does not exist here
let u = await member.fetchFlags();
// result exists here
function sum(a, b) {
return new Promise((resolve, reject) => {
if(isNaN(a) || isNaN(b) || !isFinite(a) || !isFinite(b)) reject();
resolve(a + b);
});
}
let test = await sum(1, 2); // 3
sum(1, 2).then(test2 => {
// test2 == 3
});```
?
anyone proficient at c++ that can help me with something
-ask2ask
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
excuses
Well send the question as a txt file and someone might look at it
I had my PC running continuously for weeks with only short breaks in between. Of course I needed to have it crash exactly when my bot got reviewed XD
What are some good hosting options out there?
a basic vps starts at $2-3 per month and is well worth it
I'm starting to realize
if you want 100% free, there is glitch and heroku, but both have problems and need to do workarounds to keep it running
google and amazon also have a free-for-12-months deal
I'm looking into (ab)using it for many things though, for that I had thought about getting a second PC set up as a proper server
I found those before but was hesitant
are those good temporary options?
if the things you want to do aren't too ram/cpu intensive, a vps will have a much better network connection than any home server
and will probably be cheaper than your electricity bill
except if you use Pis
Well, I was thinking along the lines of a website, bot, a few game servers and perhaps a bit of git stuff
game servers can be quite intensive depending on the game
^^
terraria, mc, for now, but yeah, that's why I was looking into local solutions first.
Also easier for development, I thought.
yeah, i know mc uses a lot of ram
you will need to measure the network quality, if the latency is good enough hosted on your home network
and also takes cpu
It would Be Coo If someone Could Help me Make a WebSite for my Bot
does anyone know how fast i can make my bot change a voice channel name? because right now even though i have 10 seconds interval it changes every 5 minutes
channel rate limits are quite restricted
latency isn't terrible, tbh
My real issue is that I simply cannot remove a single screw from my MB on the would be server PC -.-
lmao why
M.2 screw... it's tiny and completely flat now on the top
get a drill
I want to keep my M.2 drive though XD
its not that hard to drill a screw
you need a drill thats exactly the width of the screw (not the head of the screw), and drill inside the head until the head pops off
then you remove the drive and unscrew the screw with pliers
at that point, couldn't I try to snap it?
sure
... I'll be back
good luck lul
@keen path use AWS EC2 nano it's free for 12 months then about $0.10USD a month
thanks
also... I slayed the screw! Screw that one...
Unscrewed it with a pair of pliers longer than my forearm...
nice
i recommend loc for a free host
Wir bieten Server Hosting und Cloud Hosting Lösungen in Düsseldorf über Managed Server sowie Managed Hosting und Colocation bis hin zu kompletten Hosting Lösungen
?
no
ok so i want to replace variables in a string multiple times
lets say i have a object where the keys are the variables i want to replace and the values are what i want to replace with
const replaceObj = {
"{username}": functionforusername()
}
let str = "Welcome {username}"```
it would be able to replace multiple times and for different keys
just use replace
helpful
it would be able to replace multiple times and for different keys
the actual string i want to replace comes from a json file
then like
for(let key in replaceObj) {
str.replace(`/${key}/g`,replaceObj[key]())
}
using // in a replace function means it uses regex
regex has a /g flag, which means global
Hi
Could not extract html5player key: https://www.youtube.com/s/player/de455b1a/player_ias.vflset/en_US/base.js
url.js:154
throw new ERR_INVALID_ARG_TYPE('url', 'string', url);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type undefined
at Url.parse (url.js:154:11)
at Object.urlParse [as parse] (url.js:148:13)
at doDownload (/rbd/pnpm-volume/a95f489f-0bec-48f3-b1aa-cf2f281b027c/node_modules/.registry.npmjs.org/miniget/1.6.1/node_modules/miniget/dist/index.js:90:28)
at process._tickCallback (internal/process/next_tick.js:61:11)```
when i do e!play
anyone give me darkmode background url
pls
darkmode background url?
someone know how to make a message in 3 pargaraphs
1-help
2-ping
3-report
@quartz kindle for some reason doing that didnt work
the regex
new RegExp(key, "g") did
idfk
${} doesnt work in regex
a
gay
o_0
@lyric mountain still didnt work
so idk
java has Pattern.quote() to put a var inside a regex
idk if js has something like that
// crappy code by me time
str.replace(
new RegExp(Object.keys(replaceObj).join("|"), "g"), t => replaceObj[t]
)

oh yeah
btw it was just for this https://python.is-stinky.wtf/hjrbzqepui.png
{
"prompt": "→ {username} λ "
}```
lul
in discord.py how would i edit a category/channel to give someone access without using roles
@keen path i had to find it, this is the host i was talking about, its free and good https://beta.libraryofcode.org
its the beta site btw
in discord.py how would i edit a category/channel to give someone access without using roles
@earnest phoenix you can change user perms, just pass the user obj as parameter
How do you make it so it says on your bot its streaming?
thanks
read docs @worthy kindle
What docs?
^
and banned
Hello, does anyone know how to create a system for the bot that users can use a command and the bot sends the user's message?
I thought botghost was cheesy, but now that i've personally acessed it.....boi
im still using discord.js and pm2
if you check on https://flexiboat.ga/ there isn't any CSS? Im using this, how would I fetch the resources
app.use(express.static(__dirname + '/resources'))```
bruh on god had like 5 bots just surf my website
im trying to get my bot to change my channel name every 10 seconds using setInterval() but it doesnt seem to be working? does anyone know why? it only works when my bot restarts every 5 mins
what do i have to do?
because like yesterday it works fine but it just stopped working today
why this reaction role bot goes offline for more than 24 hours
welppp
it is messing up my server
any way i can "turn a string to a template literal"
chalk needs it and this current method is really bad
return eval('chalk`'+str+'`')
str is basically {blue %username%}
https://prnt.sc/sq3bom https://prnt.sc/sq3bx0 Im so confused honestly, how does it require the images but cant load the CSS?
u sure its asssets
Dont think you can make a template literal from a string without evaling/new function
which way would be better
Well new Function() is probably safer, but Idk how it works completely/if it's less efficient
Hey! How'd I fetch a dmChannel message?
let channelID = userID.dmChannel.fetch();
channelID.messages.fetch()
This doesn't work anymore ;/
an id is a string
Well, a VARCHAR.
But grabs userID
User {
id: '249474587530625034',
bot: false,
username: 'Syn',
discriminator: '3777',
avatar: '0fb0bd56ec6e910ba06b9388a36f440e',
flags: UserFlags { bitfield: 256 },
lastMessageID: null,
lastMessageChannelID: null
}
userList.forEach((user) => {
let userID = client.users.cache.get(user)
console.log(userID)
let channelID = userID.dmChannel.fetch();
channelID.messages.fetch()
console.log(channelID)
});
Current code.
bot.users.fetch(userID).then(u =>
u.createDm().then(dm =>
dm.messages.fetch().then(msgs =>
console.log(msgs.size)
)
)
)
im a pro codr
@grizzled raven Yeah i see have some questions
It's just to cache the messages already in the channel.
yeah same thing

Thanks for your help.
Not rly.
Caps matter.
Thanks for your help!
You're a life saver.
his bot is on botghost
@pale vessel So?
Botghost shitttttttttttttt
It got accepted so idc
because someone said something about library and you weren't using one
i didn't say anything
But my friend has coded a bot can you give me some code to make it say so it is streaming?
i'm not sure because i've never used botghost before
isnt botghost not allowed on top.gg?
https://lasagna.cat/i/sjlz.png
No
chalk uses a tagged template literal so how would i make it work with a string instead
https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals i was reading this and thought doing
chalk(...str) instead of ```js
chalk${str}
would work but it doesnt
and yes for the first thing str is an array
example:
chalk`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`
i'm not sure because i've never used botghost before
@pale vessel Bruh I asked if you have any code to make it say your bot is streaming beacuse my friend has a coded bot.
isnt botghost not allowed on top.gg?
@quartz kindle My bot is in here I made it with botghost
run: async (client, message, args)
@knotty steeple you want to use chalk without tagged templates?
i've never used either of them, but the chalk docs show plenty of examples for using it with and without them
yes and no
example:
chalk` CPU: {red ${cpu.totalPercent}%} RAM: {green ${ram.used / ram.total * 100}%} DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%} `
i need things like this to work without tagged template literals
say a normal string
i just want the {red Text} thing
this?
Hi, how do we verify that a number is hexadecimal ? (sry for bad english)
i guess this works https://github.com/chalk/chalk/issues/185#issuecomment-396418340
@molten coral like this? https://oliy.is-just-a.dev/hcwaot_4063.png
You'll need some regex
Yes
It's actually what i'm trying to understand how it works 😂
regex 
A hexadecimal number is just 3 (using less bits) or 6 numbers or the letters a-f





