#development

1 messages · Page 947 of 1

still merlin
#
client.on("message", (message) => {
  let args = message.content.substring(prefix.length).split(" ");

  switch (args[0]) {
    case "ping":
      message.channel.send(`Pong! ${client.ws.ping}`);

      break;
  }
});
#

@cosmic girder

earnest phoenix
#

not correct.

cosmic girder
#

With agrs

tight plinth
#

ping command wont even work mmlol

#

should be ${CODE}

twilit gust
#

pls accepted Claw bot

slender thistle
#

-faq 2

gilded plankBOT
open flicker
#

how can I find out the path to the command in error?
code:

process.on('unhandledRejection', error => {
    webhookEr.send(` ${error}`)
})
quartz kindle
#

error.stack

open flicker
#

thx

sudden geyser
#

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 komaruthinkies

earnest phoenix
#

TypeError: "file" argument must be a non-empty string help me

#

help me

quartz kindle
#

you tried to pass an empty string

fallow steppe
#

if ( message.author.id != 518738198982295564 ) return; would make the bot only respond to this id, right?

earnest phoenix
#

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.

cinder patio
#

it also accepts emoji ids

topaz fjord
#

it accepts unicode

cinder patio
#

you could use set timeouts of like 1 second, maybe 500 milliseconds

topaz fjord
#

if there is a unicode counter part in discord

cinder patio
#

but it also accepts emoji IDs

earnest phoenix
#

@Souper#1337 try.

#

oh

#

fu

earnest phoenix
tight plinth
#

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?

magic jackal
#

@tight plinth message.mentions

#

returns all mentions in the message content

tight plinth
#

i know

magic jackal
#

Then you'll have to split up the message and search for the mention

digital ibex
#

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

magic jackal
#

@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
}```
tight plinth
#

hmm

magic jackal
#

@digital ibex I use this for my updates

await client.database.collection('analytics').updateOne({
    command: commandToRun.name
}, {
    $set: {
        commandCount: commandStats.commandCount + 1
    }
})```
tight plinth
#

then I guess i have to do regex stuff with args[0]

#

i hate regex

magic jackal
#

Regex is slow btw, so I would try to use something like includes

digital ibex
#

the way i'm doing usually works, idk why its not working here

#

idk what stupid mistake i'm doing

magic jackal
#

Can you log the entire event to see what its returning?

digital ibex
#

no its uh, creating the field thing, with the object id, but its not adding the data i want, moderations.whatever

magic jackal
#

Test it without $push, maybe its that

digital ibex
#

ok

magic jackal
#

try my format see if it does anything

digital ibex
#

i don't see how it can be that as moderations is an array

magic jackal
#

its an object not an array

digital ibex
#

the format where it isn't work correctly is the same

#

no

magic jackal
#

this is an object

digital ibex
#

yes

magic jackal
#

oh i see u

digital ibex
#

u use the push operator on an array, and when u have values in that array u wanna update, its $push: { 'array.object': whatever }

magic jackal
#

Lemme check some things

uncut river
#

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

digital ibex
#

u want someone to vote for ur bot?

#

lol

uncut river
#

no

#

i meant check my webhook code

slender thistle
#

You could just post it here

uncut river
#

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

tight plinth
#

what is the error exactly

#

like

#

it dont detect vote?

earnest phoenix
#

time for debug lines pogey

#

message.guild.channels.create('Bla Bla', 'category', [{ id: message.guild.id, }])

#

text channel create

#

not category :(

tight plinth
#

yes?

magic jackal
#

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?

copper cradle
#

it don't detect vote, why is bot not work, I'll invite you to my project so you can fix it for me

earnest phoenix
#

l need to category create

copper cradle
#

I've seen some people actually say such stupid things lmao

earnest phoenix
#

errors?

tight plinth
#

@earnest phoenix read docs

copper cradle
#

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

slender thistle
#

If you're not willing to help, why comment

digital ibex
#

hi

magic jackal
#

My message was lost in transmission but I figured it out.

digital ibex
#

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
uncut river
#

@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

tight plinth
#

try to debug

digital ibex
#

moderations is js moderations: [ { kick: { user: { type: String }, mod: { type: String }, reason: { type: String } } } ],

lusty quest
#

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

balmy knoll
#

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?

turbid bough
#

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
#

@earnest phoenix let ping = m.createdTimestamp - message.createdTimestamp huh ?

#

or use .then(m => {})

lusty quest
#

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

cinder patio
#

how long do you want the chunks to be?

lusty quest
#

10 to get them into an embed

earnest phoenix
#

🤔

lusty quest
#

one of them is the heartbeat of the server

valid frigate
#

first one might be server latency (how long it takes for the server to process the command?)

cinder patio
#

Okay but, if it returns 6k keys, then you'll have to send 600 embeds, right?

earnest phoenix
#

the sec one ?

lusty quest
#

want to make it a single embed that reacts to emojis

valid frigate
#

how long it took for the bot to acknowledge the ws heartbeat is the 3rd one

lusty quest
#

bcs sending 600 embeds is stupid

glossy elk
#

Hey

amber fractal
#

api latency, round-trip latency, and heartbeat latency

valid frigate
#

no clue what the 2nd one is

earnest phoenix
#

oh

amber fractal
#

I would assume anyways

earnest phoenix
#

how i can get the round-trip

valid frigate
#

no one of those values definitely feels like server latency since there's three

#

then again

#

it's pretty vague

amber fractal
#

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

earnest phoenix
#

2020-05-02T13:44:25.787Z how i can make this to readable date

#

:((

#

with converting timestamps

#

how . . . .

#

js i assume?

amber fractal
#

Date.toLocaleString() is decent, might not be what you're looking for

#

in js

earnest phoenix
#

tried

#

:((

#

but not woroking

amber fractal
#

oh it's not gonna embed

earnest phoenix
#

output

2020-05-02T13:44:25.787Z
magic jackal
#

@earnest phoenix pretty colors

earnest phoenix
#

-__- but thx

#

use dracula theme

#

xD

magic jackal
#

lol, also are you wanting a real timestamp?

#

If you need that you can convert it, its an epoch time by default

earnest phoenix
#

but howww

amber fractal
#

Where do you define bots.date?

earnest phoenix
#

dblapi.js

amber fractal
#

oh that probably returns a timestamp

magic jackal
#

Here I use this

amber fractal
#

do new Date(bots.date).toLocaleString()

magic jackal
#

That also works ☝️

earnest phoenix
#

ok

magic jackal
#
new Date("2020-05-02T13:44:25.787Z").toLocaleString()```
earnest phoenix
#

ok

#

thx

magic jackal
#

:)

earnest phoenix
#

but do i have to require the module u sended

amber fractal
#

No, Dates are built in

magic jackal
#

Just use the code steven sent

#

Mine is different use case I realized

amber fractal
desert phoenix
#

Hi, I'm trying to implement code where the user can set the specific channel for a bot to respond to

earnest phoenix
#

well it work

#

nice

desert phoenix
#

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

magic jackal
#

Its honestly easiest by ID then you can parse the ID to a name by getting the channel info

slender thistle
#

Just... use the channel converter

magic jackal
#

I don't know much PY Py so listen to others

earnest phoenix
#

is that Py

#

wow

#

i never seen a PY code

glossy elk
#

SMe here

#

Same*

desert phoenix
#

bruh lol

#

So, basically use like a channel converter?

#

where tf xD

modest maple
#

type hinting

slender thistle
#

type annotation

desert phoenix
#

Whats that lmaoo

slender thistle
#

Basic python stuff 👀

earnest phoenix
#
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

still merlin
#

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?

spark raven
#
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?

mossy vine
#

you can use something like moment to format it

#

@spark raven javascript

spark raven
#

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

mossy vine
#

in javascript

#

i know how to do it on python if u want

#

ur being useless

still merlin
#

i said javascript thought i dont want python

spark raven
#

oh my bad

#

didn't read properly

still merlin
empty owl
still merlin
#

tysm

empty owl
#

np

#

u can search up google

#

to find out how to change it to your timezone

earnest phoenix
#

Yuu

still merlin
#

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)```
sudden geyser
#

Did you define getGMTDay

empty owl
#

you have to do something like

#
let something = new Date()
message.channel.send(`The day is: ${something.getGMTDay()})
earnest phoenix
#

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

empty owl
#

and you could do message.createdAt which is easier in my opinion

#

@earnest phoenix code?

earnest phoenix
#
let member = bot.fetchUser(args[0]) || msg.mentions.users.first() || message.member;
console.log(member);
empty owl
#

discordv12 or v11

earnest phoenix
#

12

empty owl
#

whats the error?

#

Also, since your using discord.js v12

#

you have to use the manager

earnest phoenix
#

im getting UnhandledPromiseRejectionWarning: ReferenceError: error is not defined

#

but thats not from this

#

ofc

empty owl
#

well try it first with bot.users.cache.fetch()

smoky spire
#

Also members and users are two different things

empty owl
#

yea

earnest phoenix
#

i know

#

it was just for testing first

empty owl
#

well do you want user or member

earnest phoenix
#

member

empty owl
#

instead of bot.users.cache.fetch()

#

use message.guild.members.cache.fetch()

smoky spire
#

fetch returns a promise so you'd have to await it

wide ruin
#

discord.py, how do i send a message to a specific channel id?

earnest phoenix
#

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

wide ruin
#

thanks

clear wraith
fallow steppe
#

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

earnest phoenix
#

true

#

just try.

sudden geyser
#

@fallow steppe what language.

earnest phoenix
#

@fallow steppe put id in quotes '518738198982295564', and yes

sudden geyser
obtuse wind
#

I need help apparently my bot is reacting to any prefixes I give out (d.js)

sudden geyser
#

did you check if the message started with the prefix

obtuse wind
#

if(!message.content.startsWith(prefix1)) return;

earnest phoenix
#

where u check?

obtuse wind
#

its at the very top of bot.on("message", async message => {

earnest phoenix
obtuse wind
#

idk why my bot is reacting to

!!
@@ or just any 2 lettered prefixes when my bot's prefix is only e/ and E/

smoky spire
#

Do you have more than one message listener

iron scroll
obtuse wind
#

@smoky spire sorry for ping if u hate being pinged but no.

smoky spire
#

@iron scroll try data.body instead of data when you define artist and name

iron scroll
#

all work correct

smoky spire
#

@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

obtuse wind
#

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 🤷‍♂️

smoky spire
#

@iron scroll did you initialize artist and name as constants

iron scroll
#

constants?

#

lol, constants cant be changed

smoky spire
#

That's why I'm asking

iron scroll
smoky spire
#

It's probably assigning targetsong before the .then is resolved

copper cradle
#

that if statement is wrong

#

checking for undefined is a hard task

#

just check for !data

#

if (!data)

sudden geyser
#

I mean one factor for both being undefined is the fact .then(() => {}) is a promise.

iron scroll
#

@copper cradle i delete if, but it returns undefined - undefined

sudden geyser
#

You could even console.log it within the then block and see if artist and name are strings

earnest phoenix
#

are you sure trackId is not undefined?

smoky spire
#

He said all the data logs correctly in the then

iron scroll
#

oof

#

i add await

#

and all work

earnest phoenix
#

He said all the data logs correctly in the then
That explains

fallow steppe
#

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

earnest phoenix
#

Simple if(a||b||c)

#
const prefixes = ['g!', 'gb!'];
prefixes.map(p => message.content.startsWith(p)).length > 0```
#

@fallow steppe

fallow steppe
#

Aight

obtuse wind
#

Well I found my problem "prefix1" its sposed to be "prefix2" prefix1 is for spechal commands

fallow steppe
#

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

obtuse wind
#

oh

copper cradle
#

it isn't that hard to imolement

obtuse wind
#

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:

earnest phoenix
#

so?

fallow steppe
#

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

magic jackal
#

I was wondering about that too, but it seems like a lot to integrate

copper cradle
#

just check for the edited message

#

duh

#

and parse its content

#

just like you normally do

fresh hatch
#

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

smoky spire
#

@fallow steppe some frameworks have that built in

fresh hatch
#

can i make the bot to sent a picture but to hide the link

smoky spire
#

Send the image as an attachment

fresh hatch
#

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 -

uncut river
#

could someone help me with my webhook code to receive votes in DMs?

#

i have debugged every event, no logs

magic jackal
#

@fresh hatch ```js
msg.channel.send(new Discord.MessageAttachment("url", 'tiktok.mp4'))

#

with discord.js

earnest phoenix
#
message.channel.send({files: [url1,url2..]})
``` works too
#

or one from disk:

message.channel.send({files: [{name: "E.png", attachment: "path/to/file"}]})
autumn compass
lofty hamlet
#

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 ?

earnest phoenix
#

"number of this channel"

#

you mean ID?

clear wraith
#

How do I get a YouTube API key

smoky spire
#

Google it

clear wraith
#

...

lofty hamlet
#

@earnest phoenix members

earnest phoenix
#

idk how to do that

wanton nova
#

@autumn compass you didnt provide an API key

autumn compass
#

thanks for the help

wanton nova
#

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

autumn compass
#

i just now realise that i need token for this api

earnest phoenix
#

what's problem?

#

just updated to 12

#

fixed.

serene night
#

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

digital oyster
#

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

cosmic dew
#

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.

idle mountain
cosmic dew
#

Thank you

modest maple
#

Rip Avrae since Dnd beyond brought it

clever garnet
#

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\

livid swallow
wet dove
#

-atmods

gilded plankBOT
#

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.
clever garnet
#

o.o

#

what did i just experience

slender thistle
#

Omae wa mou shindeiru

clever garnet
#

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

wet dove
#

No ping moderator role, mods will be mad and sad ;-;

sinful belfry
#

just give it some time @livid swallow

clever garnet
#

ive been waiting for a reasonable amount of time

sinful belfry
#

ping one of us if it still isn't working within 30 mins @livid swallow

digital ibex
#

hi

clever garnet
#

\

digital ibex
#
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
clever garnet
#

what library

digital ibex
#

moderations is ```js
moderations: [
{
kick: { user: { type: String }, mod: { type: String }, reason: { type: String } }
}
]

#

mongoose

clever garnet
#

what library

digital ibex
#

mongodb, mongoose

clever garnet
#

yeah ive never even heard of those good luck

hoary elm
#

LOL imagine being asked what coding library you use and you answer with the name of the DB 🤦‍♂️

quartz kindle
#

because its a db question?

smoky spire
#

his problem is with using mongoose, what's y'alls problem

clever garnet
#

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

earnest phoenix
#

user.avatarURL()

#

or user.displayAvatarURL()

clever garnet
#

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

smoky spire
#

Reread his answer

clever garnet
#

bot.on('guildMemberRemove', member => {

#

its member

#

so

#

member.displayAvatarURL

#

?

digital ibex
#

yes

smoky spire
#

member.user

clever garnet
#

TypeError: member.displayAvatarURL is not a function

glossy rapids
#

member.user

digital ibex
#

then member.user.... i don't use d.js

earnest phoenix
#

member.user.displayAvatarURL()

smoky spire
#

don't answer questions about djs if you don't know djs MegaThonk

digital ibex
#

i know d.js, i just don't use it

#

what i remember anyways

smoky spire
#

clearly you don't know much

digital ibex
#

thats unfortunate for me

regal saddle
#

.setImage(member.user.displayAvatarURL({
format: "png",
dynamic: true,
size: 128
}))
@clever garnet try something like this.

amber fractal
#

member.user.*

regal saddle
#

woops

#

Yeah

#

Thx Steven

wanton nova
#

sorry for the side question

#

but what does dynamic do?

#

i havent messed around with the settings of avatar URLs

mystic violet
#

Could someone help me with cloudflare? https://prnt.sc/spqbdj (its an express server hosted on port 1000) im using portzilla on cloudflare

Lightshot

Captured with Lightshot

#

I used dns checker

#

and apperently it works

earnest phoenix
#

<@&roleid>

#

try that

#

when it doesnt work, check the role

#

if its pingable, discord has a seizure

#

when its not ur idot

glossy elk
#

hewo

#

im free to help anyone (discord.js)

#

If anyone needs help.

livid swallow
#

@wet dove and @sinful belfry Thank you 😊

sick cloud
#

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

glossy elk
#

I don't have many experience with 'designs' but I feel like a grid would be nice.

sick cloud
#

so like 3-4 servers per row

#

all i need to show is an id (1-12 chars) and a link so yeah

digital ibex
#

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 */
}]
}

sick cloud
#

i assume you're talking api struct

digital ibex
#

just for a users modlogs in a db

sick cloud
#

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
    }
  }
}```
digital ibex
#

hm, thank u. i'm gonna look into it for a bit

#

see which ones most efficient and stuff

warm marsh
#

Define giveaway?

earnest phoenix
#

are you literally doing if (giveaway) {
}

#

without anything else?

forest mirage
#

🤔

earnest phoenix
#

show us your code

#

please

forest mirage
#

where is const giveaway or let giveaway

#

lol

earnest phoenix
#

just show us the code please

#

guess we cant help you then

forest mirage
#

just bruh

#

asks for help with code

won't share code

earnest phoenix
#

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?

zinc condor
#

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

earnest phoenix
#

though don't ask anything else here if you're not ready to share code

grizzled raven
#

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

copper cradle
#

what language is that

#

if that's js then wtf

wild mist
#

Is possible play spotify via lavalink?

pine aspen
#

How can I fetch a message with the id?

earnest phoenix
#

can I have a code to make a bot?

pine aspen
#

@earnest phoenix, no.

#

Use this.

earnest phoenix
#

ok

sudden geyser
#

what language is that
if that's js then wtf
@copper cradle yeah that's JavaScript. but with generator functions (*).

copper cradle
#

Oh yeah I forgot about them

#

what is Symbol.iterator

halcyon ember
#

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

pine aspen
#

How'd I check for a specific reaction id.

warm marsh
#

Lang/lib?

crystal socket
#

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?

forest mirage
#

Pika where is exn defined, also maybe make it message.guild

acoustic wigeon
#

D

slender thistle
#

@crystal socket what is get_input_of_type?

pine aspen
#

@warm marsh, discord.js v12,

warm marsh
#

listen to the reaction event and then check if it's that id.

pine aspen
#

Alright.

#

Also, got an idea how I can fetch a message from just the message id?

smoky spire
#

<textchannel>.messages.fetch(id)

pine aspen
#

Hmm.

#

What if it's a dm?

#

Do I need to fetch every DM channel?

smoky spire
#

<dmchannel>.messages.fetch(id)

pine aspen
#

Thanks.

earnest phoenix
#

(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?

mossy vine
#

congrats, you managed to show (almost) everything but the actual error

open oracle
#

congrats, you managed to show (almost) everything but the actual error
@mossy vine lmao

compact kite
#

bruh you could have just told him you didn't show the actual error

#

Cyber

neat ingot
#

pretty happy with the ping from contabo NY vps 🙂

lusty quest
#

                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?
neat ingot
#

why would that function cache anything from any time it was previously ran?

lusty quest
#

it does for some reason

neat ingot
#

it really shouldnt

lusty quest
#

i know

open oracle
#

oh and for my problem it only shows up when i execute that command

neat ingot
#

unless you have defined chunks globally/outside the function scope

lusty quest
#

but i get cached results from it

neat ingot
#

what is it your chunking into the chunks array?

#

perhaps that is what has cache'd

lusty quest
#

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

neat ingot
#

chunk caches nothing as expected

lusty quest
#

i have running it in a command and the command caches it. but i think i know my issue

open oracle
cinder patio
#

we cannot see the code

open oracle
#

thats weird

#

oh woops

#

xD

earnest phoenix
open oracle
#

there

earnest phoenix
#

Still unable

open oracle
#

ok one sec

#

try that?

earnest phoenix
#

As i see from error, you put empty second parameter for embed field

open oracle
#

its coming from my laptop

#

xD

earnest phoenix
#

Still unable GWcentralRainbawoo

open oracle
#

omg

#

srry

#

xD

earnest phoenix
#

Heres your error

cinder patio
#

That's not how addField works, it accepts 2 parameters: A title and a description

open oracle
#

oh

cinder patio
#

In all of those you just provide a title

earnest phoenix
#

.addField(name: string, content: string)

open oracle
#

ok

earnest phoenix
#

Instead of .addField('') use .addBlankField(inline: boolean)

open oracle
#

ok

coral stirrup
#

if you leave it out tho it should return undefined instead of an error

open oracle
#

srry

cinder patio
#

There's no addBlankField in v12

earnest phoenix
open oracle
#

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});
    }
});
earnest phoenix
#

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')

open oracle
#

ok

#

so

embed.addField('List', 'jsbot2 --Sends an embed message im going to change it soon!');
```like that?
earnest phoenix
#

Yes

open oracle
#

ok

#

ok

#

so it works

#

but why do i have to keep closing console?

#

re-opening*

earnest phoenix
#

Whad do you mean

compact kite
#

Anybody else having issues with the DBL api?

steel drum
grizzled raven
#

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 lmao

#

or not, seeing as it doesnt work but

#

but where did i go wrong

#

OH WAIT

#

nope i didnt solve it

#

nvm it did

earnest phoenix
#

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

grizzled raven
#

there's a user property for that iirc

earnest phoenix
#

Huh?

#

What's the property then?

grizzled raven
#

nvm

earnest phoenix
#

i checked xhr requests tho premium_since

grizzled raven
#

user flags have an early nitro supporter flag but other than that idk

earnest phoenix
#

There's a premium_type property but only accessible through oauth2 authorization

grizzled raven
#

yeah didnt that exist before?

earnest phoenix
#

But i have no idea how that works

grizzled raven
#

anyway i think its like

neat ingot
#

YES, finally got netdata showing my docker container names instead of id 😄

earnest phoenix
#

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 GWbruhThonkery

#

@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

coral stirrup
#

75 i think

earnest phoenix
#

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

coral stirrup
#

i think there was even a check for that

earnest phoenix
#

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

coral stirrup
#

user.premium or something cant remember

earnest phoenix
#

@earnest phoenix await hasNitro(id);

#

@earnest phoenix fake servers not counted
@earnest phoenix a ok thanks

coral stirrup
#

ye user.premium exists

earnest phoenix
#

@earnest phoenix k
@earnest phoenix if u see 'Bots cannot use this endpoint' try enter your token

#

@coral stirrup not

#

@earnest phoenix k

coral stirrup
#

was that removed?

earnest phoenix
#

Thanks for the help and excuse my English, I don’t know much truth, I’m from chile

coral stirrup
#

Alrighr

earnest phoenix
#

Im from Ukraine okkk

coral stirrup
#

That explains

earnest phoenix
#

@coral stirrup ClientUser is your bot client

#

require('discord.js').Client.user // ClientUser

coral stirrup
#

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

earnest phoenix
#

kk

opaque seal
#

What do you guys prefer between mongoDB and mySQL

#

?

earnest phoenix
#

sqlite GWjiangPepeThumb

coral stirrup
#

couchdb all the way

neat ingot
#

json files

coral stirrup
earnest phoenix
#

F

neat ingot
#

😛

opaque seal
#

json files
I started with that until someone told me it was really bad haha

neat ingot
#

nah, but fr, mongodb is awesome

#

it is

#

lol

earnest phoenix
#

mysql/sqlite

opaque seal
#

seems like from the reviews I'm watching

neat ingot
#

i mean, it is ok for small things

#

like, i have a json data file for storing my app version

earnest phoenix
#

thats ok

neat ingot
#

it auto updates when i reboot the app

opaque seal
#

yeah when you don't read/write too much from that file is fine

neat ingot
#

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*

lusty quest
#

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++}

earnest phoenix
#

n=n?

#

wut

lusty quest
#

just want to make sure that the number wont increase bcs otherwise it will break it

earnest phoenix
#

if(!(n >= chunked.length)) n++;

lusty quest
#

when you sit to long infont of an issue you forget the simple things for simple issues

earnest phoenix
#

what u want to make

lusty quest
#

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

earnest phoenix
#
const _ = require('lodash');

_.chunk(array, size);

// ex:
_.chunk([1, 2, 3, 4, 5, 6, 7, 8], 2); // [[1,2],[3,4],[...]]
lusty quest
#

got the chunking already done

#

the issue was just i can break the command by going past the number of pages that are aviable

opaque seal
#

Is there difference between using ' or " or `

earnest phoenix
#

U make 'book'-embed?

opaque seal
#

In js

earnest phoenix
#

' and " no

lusty quest
#

more or less yes

earnest phoenix
#

in ` u can use code parts

opaque seal
#

yeah I know that

earnest phoenix
#
'Test ${2+2}' // 'Test ${2+2}'
`Test ${2+2}` // 'Test 4'```
#

than ur issue is when u list backwards, commands breaks?

opaque seal
#

How do you guys use bot events in different files?

mossy vine
#

lang?

opaque seal
#

js

quartz kindle
#

in js, the most common way is to have the event call a function from another file

opaque seal
#

is that the same as using module export with node?

still merlin
#

In discord.js is client.ws.ping in milliseconds?

opaque seal
#

prob

quartz kindle
#
const fn = require("./anotherfile.js")
client.on("message",fn)
opaque seal
#

oh

quartz kindle
#

yes, you need to use module.exports in your anotherfile.js

#

and export a function

opaque seal
#

nice, thank you

quartz kindle
#

@still merlin yes

still merlin
#

ok tysm

opaque seal
#

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');
    }
};```
neat ingot
#

google seems to be down for me 👀

pure lion
#

@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

rigid maple
#

thanks

quartz kindle
#

@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)

pure lion
#

thanks
@rigid maple let me know if it works

rigid maple
#

how do i run this

#

@pure lion

#

either I couldn't do it or it didn't work

pure lion
#

uhhhh

opaque seal
#

@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?

pure lion
#

@rigid maple dm me

opaque seal
#

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

earnest phoenix
#

@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

opaque seal
#

shoew your code first

#

show*

earnest phoenix
#

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

#

oof xD

opaque seal
#

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

quartz kindle
#

its the same thing

#

but you must export the function itself, not the executed function

opaque seal
#

So there isn't any downside if I use the execute?

quartz kindle
#
module.exports = functionName

not
module.exports = functionName()```
earnest phoenix
#
// file.js
module.exports = (message) => {
  message.reply('works!');
}

// general
const messageHandler = require('./file.js');
bot.on('message', messageHandler);```
#

@opaque seal

quartz kindle
#

there is probably a microscopic performance advantage to exporting only the function, over having it contained in an object

opaque seal
#

Ok I'll do that then

quartz kindle
#

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

opaque seal
#

Yeah Ik, I use that for commans

#

i don't think I need that for events

quartz kindle
#

yeah probs not

opaque seal
#

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
quartz kindle
#

all discord.js structures have a .client property

opaque seal
#

I need to use the bot client in the function

quartz kindle
#

the raw event is not a discord.js structure

opaque seal
#

Uhm

#

So... I can't use the bot client in that function?
Should I just put this raw event in the index?

quartz kindle
#

you will have to pass client yourself

opaque seal
#

at this point I'll just put it in the index

quartz kindle
#

client.on("raw", r => myfunction(r,client))

earnest phoenix
#

@quartz kindle hi

#

how many time it take to get bot on top.gg

quartz kindle
#

if you applied, it takes 1-2 weeks for approval

earnest phoenix
#
    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

plucky heart
#

Hi, how i can show user flags name? I use this member.fetchFlags().then(u => u.serialize()) and return to me [object Promise] :c

earnest phoenix
#

Unless you have some way of entertaining yourself and time flies by

#

@plucky heart await

quartz kindle
#

@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
earnest phoenix
#
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
});```
pale vessel
#

?

spare goblet
#

anyone proficient at c++ that can help me with something

slender thistle
#

-ask2ask

gilded plankBOT
#

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.

spare goblet
#

my question is 5 pages long

pale vessel
#

excuses

solar quarry
#

Well send the question as a txt file and someone might look at it

spare goblet
#

yeah okay lmao

keen path
#

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?

quartz kindle
#

a basic vps starts at $2-3 per month and is well worth it

keen path
#

I'm starting to realize

quartz kindle
#

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

keen path
#

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?

quartz kindle
#

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

keen path
#

Well, I was thinking along the lines of a website, bot, a few game servers and perhaps a bit of git stuff

quartz kindle
#

game servers can be quite intensive depending on the game

keen path
#

^^

#

terraria, mc, for now, but yeah, that's why I was looking into local solutions first.

#

Also easier for development, I thought.

quartz kindle
#

yeah, i know mc uses a lot of ram

unique nimbus
#

mc servers does take quite a bit of ram

#

I know this from experience

quartz kindle
#

you will need to measure the network quality, if the latency is good enough hosted on your home network

unique nimbus
#

and also takes cpu

keen path
#

there are actually worse games out there

#

7days is ridiculous in ram, I believe

quaint cedar
#

It would Be Coo If someone Could Help me Make a WebSite for my Bot

river wing
#

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

quartz kindle
#

channel rate limits are quite restricted

keen path
#

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 -.-

quartz kindle
#

lmao why

keen path
#

M.2 screw... it's tiny and completely flat now on the top

quartz kindle
#

get a drill

keen path
#

I want to keep my M.2 drive though XD

quartz kindle
#

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

keen path
#

at that point, couldn't I try to snap it?

quartz kindle
#

sure

keen path
#

... I'll be back

quartz kindle
#

good luck lul

solar quarry
#

@keen path use AWS EC2 nano it's free for 12 months then about $0.10USD a month

keen path
#

thanks

#

also... I slayed the screw! Screw that one...

#

Unscrewed it with a pair of pliers longer than my forearm...

quartz kindle
#

nice

digital ibex
#

i recommend loc for a free host

keen path
#

?

digital ibex
#

no

knotty steeple
#

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
digital ibex
#

just use replace

knotty steeple
#

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

digital ibex
#

then like

quartz kindle
#
for(let key in replaceObj) {
  str.replace(`/${key}/g`,replaceObj[key]())
}
knotty steeple
#

looks pretty simple

#

cool thanks

quartz kindle
#

using // in a replace function means it uses regex

#

regex has a /g flag, which means global

ancient bloom
#

Hi

earnest phoenix
#
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

lyric mountain
#

darkmode background url?

fresh hatch
#

someone know how to make a message in 3 pargaraphs
1-help
2-ping
3-report

knotty steeple
#

@quartz kindle for some reason doing that didnt work

#

the regex

#

new RegExp(key, "g") did

#

idfk

grizzled raven
#

${} doesnt work in regex

knotty steeple
#

a

lyric mountain
#

you gotta put inside a capture group

#

[${key}]

knotty steeple
#

gay

fresh hatch
#

o_0

grizzled raven
#

that doesnt

#

no

#

you use the regex constructor

#

for vars

knotty steeple
#

@lyric mountain still didnt work

lyric mountain
#

so idk

#

java has Pattern.quote() to put a var inside a regex

#

idk if js has something like that

grizzled raven
#
// crappy code by me time
str.replace(
  new RegExp(Object.keys(replaceObj).join("|"), "g"), t => replaceObj[t]
)
knotty steeple
#

ur missing a )

#

also only replaces once

grizzled raven
#

oh yeah

knotty steeple
#
{
    "prompt": "→ {username} λ "
}```
#

lul

earnest phoenix
#

in discord.py how would i edit a category/channel to give someone access without using roles

digital ibex
#

its the beta site btw

lyric mountain
#

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

worthy kindle
#

How do you make it so it says on your bot its streaming?

keen path
#

thanks

pale vessel
#

read docs @worthy kindle

worthy kindle
#

What docs?

grizzled raven
#

the docs

#

discord.js/.py docs

pale vessel
#

are you still using botghost

#

don't tell me

digital ibex
#

o

#

botghost is bad

honest perch
#

^

grizzled raven
#

and banned

pale vessel
#

not

#

his bot is on botghost

#

i guess he made enough modification

light drift
#

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?

lyric mountain
#

I thought botghost was cheesy, but now that i've personally acessed it.....boi

earnest phoenix
#

im still using discord.js and pm2

mystic violet
#

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

river wing
#

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

mystic violet
#

thats api abuse (kinda)

#

I mean its a loop, but its not often

river wing
#

what do i have to do?

#

because like yesterday it works fine but it just stopped working today

dim prairie
#

why this reaction role bot goes offline for more than 24 hours

#

welppp

#

it is messing up my server

knotty steeple
#

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%}

mystic violet
knotty steeple
#

u sure its asssets

pale vessel
#

ass

#

not asss ?

#

.ga omegalul

amber fractal
#

Dont think you can make a template literal from a string without evaling/new function

knotty steeple
#

which way would be better

amber fractal
#

Well new Function() is probably safer, but Idk how it works completely/if it's less efficient

pine aspen
#

Hey! How'd I fetch a dmChannel message?

#
let channelID = userID.dmChannel.fetch();          
            channelID.messages.fetch()
#

This doesn't work anymore ;/

grizzled raven
#

an id is a string

pine aspen
#

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.

grizzled raven
#
bot.users.fetch(userID).then(u => 
  u.createDm().then(dm => 
    dm.messages.fetch().then(msgs => 
      console.log(msgs.size)
    )
  )
)
#

im a pro codr

pine aspen
#

cache

#

v12 🙂

grizzled raven
#

ik

#

anywho

pine aspen
#

Does it have to create a channel?

#

createDM()?

#

If it already exists.

light drift
#

@grizzled raven Yeah i see have some questions

grizzled raven
#

why is user the id and userID the user object?

#

no questions allowed

pine aspen
#

It's just to cache the messages already in the channel.

grizzled raven
#

its createDm()

#

refer at my snippet of code above imcool

pine aspen
#

Ok.

#

@grizzled raven, getting createDm() isn't a function.

#

createDM() it seems.

grizzled raven
#

yeah same thing

pine aspen
#

Thanks for your help.

#

Not rly.

#

Caps matter.

#

Thanks for your help!

#

You're a life saver.

worthy kindle
#

his bot is on botghost
@pale vessel So?

modest maple
#

Botghost shitttttttttttttt

worthy kindle
#

It got accepted so idc

pale vessel
#

because someone said something about library and you weren't using one

#

i didn't say anything

worthy kindle
#

But my friend has coded a bot can you give me some code to make it say so it is streaming?

pale vessel
#

i'm not sure because i've never used botghost before

quartz kindle
#

isnt botghost not allowed on top.gg?

pale vessel
#

it's allowed if you made heavy modifications

#

it's considered "effort"

forest mirage
amber fractal
#

No

knotty steeple
#

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}%}
`
worthy kindle
#

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

slender wagon
#

tysm

pale vessel
#

run: async (client, message, args)

slender wagon
#

and it worked tysm

#

i'm still new to command handlers

quartz kindle
#

@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

knotty steeple
#

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

quartz kindle
knotty steeple
#

no

#

"{red Text}" in an actual string

molten coral
#

Hi, how do we verify that a number is hexadecimal ? (sry for bad english)

knotty steeple
amber fractal
molten coral
#

yea

#

but to verify if it's an hexadecimal number

amber fractal
#

You'll need some regex

molten coral
#

I explain myself

#

RegExp ?

amber fractal
#

Yes

molten coral
#

It's actually what i'm trying to understand how it works 😂

earnest phoenix
#

regex Poggers

amber fractal
#

A hexadecimal number is just 3 (using less bits) or 6 numbers or the letters a-f