#development

1 messages · Page 1913 of 1

quartz kindle
#

length actually starts from 1, but indexes start from 0

#

for example [0,1,2] is length 3, but indexes 0 1 and 2

forest drift
#

...

#

im confused even more now

#

but ok

quartz kindle
#

[a,b,c] is length 3

#

it has 3 items

forest drift
#

oh ok wait now i get it

#

the 'i' starts from zero, and only hits the full length on the last for, so one less than length is the last item in the array

quartz kindle
#

did you delete your node_modules folder AND your package-lock.json file?

#

AND delete the dependencies: {} block from your package.json?

forest drift
#
for(let i=0;i<arrays.message.trigger.length;i++){
        if(arrays.message.trigger[i].includes(";")){
            console.log(arrays.message.trigger[i])
           for(let ii=0;ii<arrays.message.trigger[i].split(";").length;ii++){
            if(message.content.toLowerCase()===arrays.message.trigger[i].split(";")[ii]){
                if(arrays.message.action[i].includes(";")){
                   message.channel.send(arrays.message.action[i].split(';')[Math.floor(random(arrays.message.action[i].split(';').length))]);
                   }else{
                   message.channel.send(arrays.message.action[i])
                }
               }
        }

seems to work now, thanks for the help!

quartz kindle
#

and save package.json?

stiff lynx
#

How can I check if the bot have the permission to create a text channel?

boreal iron
spark flint
#

@rustic nova

#

scam

earnest phoenix
#
const { Client, CommandInteraction, MessageEmbed } = require('discord.js')

module.exports = {
    name: "userinfo",
    description: "Displays the target's information.",
    options:[
        {
            name: "target",
            description: "Select a target.",
            type: "USER",
            required: true,
        },
    ],
    /**
     * @param {Client} client 
     * @param {CommandInteraction} interaction 
     */
    run: async(client, interaction) => {
        const Target = interaction.options.getMember('target');

        const Response = new MessageEmbed()
        .setAuthor(`${Target.user.username}`, `${Target.user.displayAvatarURL({dynamic: true})}?size=256`)
        .setThumbnail(`${Target.user.displayAvatarURL({dynamic: true})}?size=256)`)
        .setColor("#2f3136")
        .addField("UserID", `${Target.user.id}`, false)
        
.addField("Bages", `${Target.user.flags.toArray()}`)
        .addField("Server Member Since", `<t:${parseInt(Target.joinedTimestamp / 1000)}:R>`)
          .addField("Banner",
`${Target.bannerURL({ dynamic: true })}`)
        .addField("Discord User Since", `<t:${parseInt(Target.user.createdTimestamp / 1000)}:R>`)

        if (Target.roles.cache.size > 1) {
            Response.addField("Roles", `${Target.roles.cache.map(r => r).join(' ').replace("@everyone", " ")}`)
        } else {
            Response.addField("Roles", `No Roles to display.`)
        }

        interaction.followUp({embeds: [Response], ephemeral: false});
    }
}  ```
boreal iron
#

Regarding the docs, there's no bannerURL() method available in the member class

#

But in the user class, there is

#

You need to get the user object for your interaction option target to get the URL of the banner

hoary compass
#

Can you give me a example code this?

boreal iron
#

What's the part of the code you got an issue with?

#

Changing the embed in your original message?

hoary compass
#

The embed itself

boreal iron
#

You mean updating the embed when pressing a button?

hoary compass
#

yeah

boreal iron
#

Well that's actually the easiest part, I'm gonna give you an example

boreal iron
# hoary compass yeah

Your original interaction has a button you assigned a custom ID to, let's call this custom ID change_embed for now.
Also in your interactionCreate you check if a user has clicked your button with the ID change_embed.
If so you simply gonna edit the interaction response (which currently includes your button and embed).

If you wanna keep the button, then the code needs to look like:

let component = interaction.message.components;
let embed = { color: 0xffffff, description: "This is your new embed." };
await interaction.message.edit({ embeds: [embed], components: component }).catch(...);

If you wanna update the message (embed) and remove the button, the code needs to look like:

let embed = { color: 0xffffff, description: "This is your new embed." };
await interaction.message.edit({ embeds: [embed], components: null }).catch(...);
#

While the interaction object is still the interaction response your button is attached to (the message with your unchanged embed)

hoary compass
#

ok i'll try something like this.

boreal iron
#

Well to get the user object use interaction.options.getUser("target")

earnest phoenix
#

oh ok

#

but i want exaple for banner code

boreal iron
#

But you will still also need the member object

earnest phoenix
#

hm

#

so what do i do

boreal iron
#

You can also interact with the user object directly using Target.user.bannerURL()

#

Which is easier of course

boreal iron
#

I don’t see you tried that in your code

#

target.banner != target.user.banner

#

The user object should "always" be included in the member object

#

At least in djs

earnest phoenix
#

@boreal iron ok so what do i do?

stiff lynx
#

code: https://srcb.in/qNzGyZ3loj

I'm trying to do a ticket system with threads, but idk why I get an api error;
error: ```RequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^

DiscordAPIError: Unknown Webhook
at RequestHandler.execute (C:\Users\Utente\Documents\progetti\NOVABOT v13\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Utente\Documents\progetti\NOVABOT v13\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async InteractionWebhook.send (C:\Users\Utente\Documents\progetti\NOVABOT v13\node_modules\discord.js\src\structures\Webhook.js:192:15) {
method: 'post',
path: '/webhooks/899585166438191176/aW50ZXJhY3Rpb246OTA0ODM4NDA0MTc1NDYyNDMwOkw4N1lrTlpFWEpqTzVDRFRCN0U0QVJUUmtId1dYbU5TY3RWbmFvNmRYelcxWno0UzVnVDNYZHZLZkNORzdFTTk3cnN4TU1ENWg3QXlJUEdCUFJDWUxBZzBKaG01WHFsWDZDYWk5VnRUdUgxT09JYjIyQVJKRHNldW9RMEVYaE9F?wait=true',
code: 10015,
httpStatus: 404,
requestData: {
json: {
content: 'Ticket creato!',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
} ```

rustic nova
#

the webhook used is invalid

#

also probably good idea to edit it out

earnest phoenix
#

nvm i had to update discord.js lol

boreal iron
#

But still the member class doesn’t include the banner URL

#

The user class does

#

You just need to edit target.bannerURL() to target.user.bannerURL() as I mentioned

boreal iron
#

Since you await things to happen like creating a thread, which may take a few seconds
But the webhook is only available for 3s

#

After deferring you can respond to the interaction within 15 min

jolly notch
#

@woeful pike can I get a link for your jetbrains theme

woeful pike
#

im not sure how to send that

#

I think it's based off material deep ocean?

jolly notch
#

What plugin is it

woeful pike
#

material theme

#

it's a fork of palenight

jolly notch
woeful pike
#

I just pressed the export button

#

dunno how you're supposed to use it

jolly notch
#

fixed it

#

yeah it was colour scheme not a plugin

#

Xetera confirmed blind

woeful pike
#

it's not a plugin

#

it's a color schema

#

the plugin is material theme

#

it's just a fork of an existing theme

#

unless you're talking about something else

jolly notch
#

it works dw

#

just I got your high font size settings with it

eternal osprey
#

How do i react with a custom emoji?

jolly notch
#

how do you cope with size 16 font 😭

#

thanks @woeful pike it works great, best team member

untold dome
#

instead of: message.channel.send("":wave:")

#

type: message.react(":wave:")

lament rock
#

That's not what they asked and your code example is incorrect

#

For built in emojis, you have to use the unicode version of the emoji; \👋
For custom emojis, you have to supply a name and an ID in name:id format. The name seems like it can be anything, so you could pass _:id if you want to be generic

hybrid cargo
lament rock
#

Like I mentioned, it's name:id

hybrid cargo
#

Djs does, Eris doesn't iirc

lament rock
#

Can't make assumptions about their env

hybrid cargo
#

True true

bright talon
#

@quartz kindle or others who know sharding: I have an error in my event handler for guildCreate, where the sharding is saying it finds Discord undefined: ```// The embed which sends to channel
const joinEmbed = new Discord.MessageEmbed()
.setTitle('Server Joined')

#

I import Discord at top level, and this is within a broadcastEval scope.

#

I tried sending in through the context object as well, but then it said it's not a constructor....help? I guess I don't understand what is invisible to the broadcastEval scope from file-level definitions....thx.

quartz kindle
#

the file where the broadcasted function is executed does not have Discord in its context

#

you need to define it yourself with a require

#
broadcastEval((stuff) => {
  const Discord = require("discord.js")
})
loud tree
#

For specific values

#

We have been given, some values like

#

56+2 = 70

#

We need to be specific bout them

#

And the rest of the calculator must work fine

quartz kindle
#

based on the formula or on the result?

#

like anything that would result in 58 gets changed to 70? or only that specific 56 + 2 input?

loud tree
#

Specific

quartz kindle
#

lel funni

loud tree
#

Yeah....

bright talon
pale vessel
#

yes

#

How did they even do it, do they just .toString() the function and eval it like normal?

quartz kindle
bright talon
deft citrus
#
@client.event
async def on_message(message):
    if message.channel.id == 899242171838910527:
      data = message.content.split(" ")
      user = re.sub("\D","",data[4])
      print(user)
    await client.process_commands(message) 
#

i need to add voting rewards

#

i want to find the user which voted

#

i add webhook

#

Thankyou for your upvote@deft citrus

#

i add this in the webhook channel if someone voted

#

but i cant find the user

#

who voted

earnest phoenix
deft citrus
#

and print it

deft citrus
#

@deft citrus

earnest phoenix
#

My question was like does it not print the ID

deft citrus
earnest phoenix
#

Are you sure the channel ID was right?

deft citrus
earnest phoenix
#

Well, I have no clue man, it's hard to tell what the problem is without further information. Besides, this is rather a hacky way, I'd personally just set up a webserver for top.gg to send the requests directly

quartz kindle
#

what is re.sub?

deft citrus
quartz kindle
#

well we have no idea what that function does

#

so unless you show/explain, we cant help

earnest phoenix
quartz kindle
#

its a built in method?

earnest phoenix
#

re is part of the standard library yeah

quartz kindle
#

then the problem is likely data[4]

#

ie the content of the message you are receiving

earnest phoenix
deft citrus
#
  1. you have to invite me to your bots team
  2. i am the permanent owner of that team
  3. u send me the application for the bot so i can fill it out
  4. you stay in the team while i am just the owner
#

is this rules good

#

a person dm me

#

with this rules

#

to verify

#

my bot

quartz kindle
#

what

deft citrus
#

@quartz kindle

quartz kindle
#

???

deft citrus
#

a person called

#

marshy

#

said he will verify the bot for me

quartz kindle
#

do you know this person?

deft citrus
quartz kindle
#

then its a scammer

deft citrus
deft citrus
deft citrus
#
@client.event
async def on_message(message):
    if message.channel.id == 899242171838910527:
      data = message.content.split(" ")
      user = re.sub("\D","",data[4])
      await message.channel.send(user)
    await client.process_commands(message) 
#

see

#

Thankyou for your upvote @deft citrus

#

i add space

#

now 4 space

earnest phoenix
#

We're still lacking info. The problem can be anything, really. You might've overridden your on_message event with another

feral aspen
feral aspen
feral aspen
deft citrus
#

oh 3yrs

#

i want to wait

feral aspen
#

Are you 13 or almost thirteen?

deft citrus
feral aspen
#

Your birthday has passed and you became 13, correct?

#

Moreover, you can ask a legal guardian to verify the bot for you, too.

feral aspen
deft citrus
feral aspen
#

I know most developers are 16 and can use their own passports, according to the TOS and FAQ.

deft citrus
#

my parents dont like social media

feral aspen
feral aspen
#

As a developer, you're expected to go through stages like this, and I thought the same, years ago, when I also joined, but it's to prevent Fraud.

#

You're new to coding, correct?

deft citrus
deft citrus
feral aspen
deft citrus
#

ohk

#

my bot hit 100servers

feral aspen
#

The more you rush, the more you are preventing yourself from learning.

feral aspen
earnest phoenix
#

that doesnt really matter

deft citrus
#

so i got lot of servers

feral aspen
earnest phoenix
#

people invite hundreds of bots to their servers to "grow" them

#

should check the amount of bots in each server and leave ones with like 10 or more

deft citrus
#

i also have a server

#

with 400+

#

members

earnest phoenix
#

helps prevent much spam imo

feral aspen
#

Bot farms are servers with like 30 bots or more.

earnest phoenix
#

change the number how you want ¯_(ツ)_/¯

feral aspen
#

10 bots can be good, mostly the guild owner doesn't want a bot that has everything. (Due to some features are premium, etc.)

earnest phoenix
boreal iron
#

Absolutely nonsense to declare a fix value.
A check if a certain percentage of members is a bot makes more sense, e.g. 50% or more.

earnest phoenix
#

yes

lyric mountain
earnest phoenix
#

k

#

assuming thats a ban or smth

earnest phoenix
#

yeas

#

i made the mistake of sending !help in one of those servers

It had over 300 bots
My phone literally rebooted

#

What a nice day to NOT use exclamation mark for prefix

#

jeez

#

im surprised not many bots used / or // as a prefix before slash commands were added

#

// seemed like a good option so i used that until it started causing me issues with the app (not the bot)

#

They did

#

i meant to say not many

#

i will now disappear

#

Evaporate

tardy hornet
#
        if (message.guild.id === "754604182995992609" && message.content.includes("1")){
            message.reply(`Why are you pinging Broken Tooth! stop it <${a}:angryasf:904984616904036352>`)
            return
        }

for some reason it does not work

earnest phoenix
#

message.content.includes is not a function

#

how do i make the bages emojies?

#

like instead of HOUSE_BALANCE it show Balance

earnest phoenix
#

put an emoji there instead of HOUSE_BALANCE?

nimble kiln
#

Btw it's called Badges

#

Or Badge if it's only one

earnest phoenix
#

Baguettes

#

@nimble kiln but it is if a user have it then it show so i cant do anything with that

earnest phoenix
#

they put the exact user badges string inside the field description

#

and they don't know how to change the badges to emojis

tardy hornet
earnest phoenix
tardy hornet
earnest phoenix
#

oh sh*t

#

💩

#

wait

#

@tardy hornet

nimble kiln
tardy hornet
earnest phoenix
#

and var sucks

#

let and const are better

tardy hornet
nimble kiln
earnest phoenix
#

ahhhh

earnest phoenix
earnest phoenix
tardy hornet
#

yes

nimble kiln
#

Show the code for this part

#

do it

earnest phoenix
#

one sec

tardy hornet
earnest phoenix
#

.addField(''Bages'', ${Target.user.flags.toArray()})

earnest phoenix
#

lol

tardy hornet
#

but i am not good at explaining

earnest phoenix
earnest phoenix
#

how

#

edit it pleas

#

I have a serious question:
Do you actually know how to code or did you just follow an outdated discord bot tutorial

#

ik how to code but idk with badges

nimble kiln
#
if(Target.user.flags.toArray() == 'HOUSE_BALANCE') {
  userFlags = '<:balance:887102876407693383:>';
}
...
...
Somewhere below:
.addField('Badges', userFlags)```
earnest phoenix
#

ah ok

nimble kiln
#

But a user can have multiple badges, so you probably want to for loop it

#

(If you want to display multiple badges)

earnest phoenix
#

ouf

earnest phoenix
nimble kiln
#

¯_(ツ)_/¯

earnest phoenix
#

hmmm

#

why don't you just map and join the array

#

and I'm not going to send a code example because I know you're gonna copy paste it

#
.addField("Bages", ${Target.user.flags.toArray.map.join()})```? like that
tardy hornet
earnest phoenix
#

yo what

#

it's a valid function

nimble kiln
#

ofc it is

earnest phoenix
#

yeah

#

i need to read more mdn

earnest phoenix
#

how do i change it to emojie if idk if the user have it or no

#

map allows you to change the stuff inside the array to something else

#

ok so how do i change

#

[1, 2, 3].map(number => number + 2) becomes [3, 4, 5]

#

scruw it

#

my mind

#

To everyone in this channel who said creating a discord bot as your first project is fun:

fuck you

nimble kiln
#

hey it is fun

earnest phoenix
#

scratching your head, calling yourself an idiot and giving up programming is fun

nimble kiln
#

yeah

earnest phoenix
#

well if you give up you can go outside and socialize with people so

lament rock
#

My first project has been my Discord bot and it's been going on for well over 4 years

#

send help

earnest phoenix
#

That's the difference

You have a brain, most people in #development don't

jolly notch
#

shit developers be like

spark flint
pearl egret
#

hi, guys, need help for using webhooks

spark flint
#

What with

pearl egret
spark flint
#

Quicker response

pearl egret
#

when click "test" button in dashbord

#

I can receive event, but I can not receive anything when vote at bot page

#

@spark flintthank you

spark flint
#

No problem

#

Also scrolling through that chat may be helpful as there may already be a response from someone with the same issue

pearl egret
#

got it

stiff lynx
#

code: https://srcb.in/qNzGyZ3loj

I'm trying to do a ticket system with threads, but idk why I get an api error;
The thread is created but after the correct creation and the direct message I get this error.
error: ```
RequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^

DiscordAPIError: Unknown Webhook
at RequestHandler.execute (C:\Users\Utente\Documents\progetti\NOVABOT v13\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Utente\Documents\progetti\NOVABOT v13\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async InteractionWebhook.send (C:\Users\Utente\Documents\progetti\NOVABOT v13\node_modules\discord.js\src\structures\Webhook.js:192:15) {
method: 'post',
path: '/webhooks/899585166438191176/aW50ZXJhY3Rpb246OTA0ODM4NDA0MTc1NDYyNDMwOkw4N1lrTlpFWEpqTzVDRFRCN0U0QVJUUmtId1dYbU5TY3RWbmFvNmRYelcxWno0UzVnVDNYZHZLZkNORzdFTTk3cnN4TU1ENWg3QXlJUEdCUFJDWUxBZzBKaG01WHFsWDZDYWk5VnRUdUgxT09JYjIyQVJKRHNldW9RMEVYaE9F?wait=true',
code: 10015,
httpStatus: 404,
requestData: {
json: {
content: 'Ticket creato!',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
} ```

earnest phoenix
#

Does somebody have a solution for it?
My discord bots disconnects after 4 days automatically.

stiff lynx
earnest phoenix
earnest phoenix
spark flint
stiff lynx
spark flint
#

And then my bots statuses go as well

earnest phoenix
earnest phoenix
#

or defer reply

#

then respond

spark flint
#

It just says something about 403 unauthorised but doesn’t say what for or what is causing it

#

(I can now know tell it’s for Discord API)

#

Managed to connect using my Phone and can see the error I get now(different from yesterday)

astral coral
#

Errrr big bun I have a question

spark flint
#

Hi

astral coral
#

So on the site on top gg I can’t vote like at all cuz there’s always a problem occurring in the web page is there anything to fix it

#

I can like screenshare or sum and show you if you wanna

spark flint
#

Could you screenshot it

astral coral
#

Sure one sec

spark flint
#

I’m at school so can’t really call or anything

astral coral
#

Ah sorry then

#

It’ll always come up with this

#

Or reload the page

#

And then I have to watch the ad 8 million times

#

Like I’ll tap twice and it’ll reload the page after the ad

#

And say a problem occurred

pearl trail
#

dont use safari, also it's #support afaik

astral coral
#

Aight sorry

stiff lynx
#

how can I send the buttons inline?

pale vessel
#

Have them under the same ActionRow

earnest phoenix
boreal iron
#

Telling somebody to use a different browser because the site is still a nightmare, isn't the browsers fault.

earnest phoenix
#

idk css tricks says safari is the next internet explorer

boreal iron
#

Careful!!!1!

#

the next internet explorer

#

That's something you can't take back, Sir.

stiff lynx
#

It is possible for a bot to edit a message from a slash command?

boreal iron
#

The response for a slash command is just a normal message, so yeah it's possibe

boreal iron
#

djs?

#

Other than slash commands, button interactions for example come with the message property you can access

#

It might be needed to defer the initial slash command response if you wanna edit it later on, as the webhook is only available for 3s

slender thistle
slow terrace
tardy hornet
#

how to get all the servers that my bot is watching including the shard servers?

tardy hornet
spark flint
#

ah

#

im no use sorry

stiff lynx
rustic nova
quartz kindle
#

you still have a shit ton of trash in your package.json

#

and yes, you need windows build tools, which include visual studio

slow terrace
quartz kindle
#

npm i -g windows-build-tools from an administrator cmd or powershell

#

(right click -> run as administrator)

slow terrace
#

Okay I will try

earnest phoenix
tardy hornet
#

i have a problem

#
  bot.shard.fetchClientValues('guilds.cache.size')
        .then(results => {
        setInterval(() => {
           
            bot.user.setActivity(`with money | e!help | in ${results.reduce((acc, guildCount) => acc + guildCount, 0)} servers.`, ({ type: "PLAYING" }))
        }, 600);       
    }).catch(console.error);
native walrus
#

sounds like a really bad problem

earnest phoenix
#

you're not updating the guild count

#

you set the interval inside the fetchClientValues block which means every 600 milliseconds you're updating your client presence to the old data

tardy hornet
#

o so i need to put it outside of it?

tardy hornet
pale vessel
#

TIAS

#

He's not here to evaluate code for you yk

earnest phoenix
#

yes you can

#

and don't forget to do const results = bot.shard.whatever

native walrus
#

wait is that how you get data from shards in discord.js? that's so funny

quartz kindle
#

also 600ms is way too fast

#

you're gonna get tons of rate limit errors

pale vessel
#

At least every 4s but 5s just to be on the safe side

earnest phoenix
#

why the hell 600ms

native walrus
#

very important that users see 650 and not 649

#

try 6 hours instead

tired panther
#

Lol

spark flint
#

the usual is 5s

native walrus
#

why would you try to update your status every 5 seconds

tired panther
#

Users don't care about stats

spark flint
#

plus its not exactly important to have a live server stats updated instatly

#

make it update every 30s

native walrus
#

do it like once a day or something, nobody cares and inconsistency doesn't matter

#

doesn't this eat up into your other rate limits too

wheat mesa
#

30s is a reasonable update interval

native walrus
#

you're taking from your global rate limit doing something super unnecessary

spark flint
#

its not like anyone is going to go "wtf this isn't a live update on the bot status removes bot"

native walrus
#

I'd honestly just remove it completely idk why anybody would care

spark flint
#

true

#

i used to have a live count but then i changed it

native walrus
#

have shards send stats to a database or datadog

tardy hornet
#

i did that,

 setInterval(() => {
            bot.shard.fetchClientValues('guilds.cache.size')
            .then(results => {
            bot.user.setActivity(`with money | e!help | in ${results.reduce((acc, guildCount) => acc + guildCount, 0)} servers.`, ({ type: "PLAYING" }))
        })
        }, 600);       

and it still does not show the correct amount

pale vessel
#

600ms hmm

tardy hornet
#

its just to test on the test bot

#

on the main one is 30 minutes

native walrus
#

does this really matter

#

you're 4 servers off

#

there's obviously some caching involved somewhere along the way

pale vessel
#

${results.reduce((acc, guildCount) => acc + guildCount, 0) + 4.45445233533534545} there

#

Simple

tardy hornet
#

well i dont want to deal with it in the future

native walrus
#

I wouldn't be surprised if your bot was removed from a couple servers and the discord invite page just relies on eventual consistency or something

tardy hornet
pale vessel
#

Ahh

native walrus
#

this is like the ultimate bikeshed

pale vessel
#

with money | e!help | in ${Math.floor(Math.random() * 493)} servers.

#

activities are useless

#

No one cares about statistics, and if you want to put website/announcements, just add it to your bot's about me

#

No presence needed

native walrus
#

go set up metrics for your bot

pale vessel
#

Even better, everyone can still see it even when your bot is down

native walrus
#

doesn't top.gg have like some dashboard that shows you some of their own metrics for the site? Go make something like that

spark flint
#

Watching over X servers
now says
Watching for suspicious users | website.xyz

#

Make the status relevant to the bot

#

not just a server count

#

no one realistically needs a live server count

#

if i wanted server count, i would go to either top.gg or see the server count when adding the bot

hybrid cargo
#

Or just add the server count in the botinfo command if you have one

#

Ez

native walrus
#

just send metrics to datadog so you know how your bot is being used

pale vessel
spark flint
wheat mesa
#

That’s what I do instead of updating the bot status

#

(Only works when I’m on my pc though since it works through IPC)

spark flint
#

yeah

#

fair enough

sharp saddle
#

what did I do wrong?

tribal crow
#

Hey! I'm making a dashboard for my bot, and i get this error: GET https://dashboard-backend.wingek.repl.co/api/auth/ 401

#

it says the error is coming from this line: getUserDetails()

#

but i dont understand whats wrong/why it doesnt work

tribal crow
sharp saddle
#

show code

tribal crow
#
    return axios.get('https://dashboard-backend.wingek.repl.co/api/auth/', { withCredentials: true });
}```
#

this is whats on the https://dashboard-backend.wingek.repl.co/api/auth/ site

jolly notch
#

Skill issue

tribal crow
#

huh

round cove
#

You should look up what the 401 http code means.

tribal crow
#

Unauthorized

#

ik that

quartz kindle
#

im assuming you are using oauth2?

#

so when you visit that page in a browser, it asks you to login with discord?

quartz kindle
tribal crow
#

how tho?

#

when i log in via the oauth2

#

i get a cookie on the https://dashboard-backend.wingek.repl.co/api/auth/ site

#

and it displays all my info

#

if i clear the cookie it says unauthorized on that page

slow terrace
#

and some unwanted packages

quartz kindle
#

the cookie is stored in the browser

#

your code doesnt have it

quartz kindle
#
  1. open cmd or powershell in administrator mode, run npm i -g windows-build-tools
  2. open your package.json file and delete everything from dependencies that you dont use in your code. open all your files, look at all your requires and whatever you dont find, delete it from package.json
  3. save the modified package.json
  4. delete package-lock.json
  5. delete node_modules
  6. run npm i
#

also, READ all of these

#

if you dont use them, delete them. if you use them, read what it says, it likely tells you what to do, how to update

errant python
#

Has anyone here by chance used the XCP-ng hypervisor software

#

I'm having an odd issue I can't find any info about

#

Figured perhaps someone here may have a little insight lol

bright talon
#

hey Tim, for sharding, during a guildDelete event, is there a timing issue for broadcastEval calls, where the guild leaves the client's cache, while I'm in the event handler for the guildDelete event? bascially I'm getting a failure for finding the guild, so I'm wondering if this can be a timing thing?

tribal crow
bright talon
# bright talon hey Tim, for sharding, during a guildDelete event, is there a timing issue for b...

basically here's what I think I am doing wrong (and going to try the reverse): I have guildDelete event, and I have a support server on another shard I want to notify of the departure. I was finding the shard with the support, and then querying the client for the departing guild's info...which fails. I"m thinking the client sees this as "gone" already. So I'll swap and handle this in the shard/context of the departing guild and query the support server shard for the comms. I think that will fix it....

quartz kindle
boreal iron
#

Wanted to diss you earlier but just woke up now oldEyes

slender thistle
spark flint
#

is there a js version of """ ?

split hazel
spark flint
#

ah

split hazel
#

fuck

#

just one of them

#

discord is shit

#
\`
#

like

let test = `hello
world`;
#

though doesnt result in pretty code

spark flint
#

its html code

#

i'm using the sendgrid js module to send emails

west stag
#

Worth learning and switching to Typescript? slonk

cinder patio
#

yes

surreal sage
#

Does a Anti-Spam System flag block the request type? For example senddm?

glacial vapor
#

Write something in JS like this and it should be correct but doesn't work with TS.

module.exports = async (client) => {```

You get quickfix option and it modifies the code into this and then it works. (Varies between the use your code has.)
```ts
module.exports = async (client: { guilds: { cache: { size: any; }; }; user: { setPresence: (arg0: { activities: { name: string; type: string; url: string; }[]; }) => void; }; }) => {```
#

I've noticed typescript being super useful

#

Theres not much differences between JS and TS but one of the first differences you see is its not

const something = require('blahblahblah')

but instead

import something from 'something'
novel jetty
#

This is how my slash command is build, how can i add options to it?

import { CommandInteraction, Collection, MessageSelectMenu, MessageActionRow, Client, MessageEmbed } from 'discord.js'
import { commands } from '../..'

export const name: string = 'test';
export const description: string = 'This is a Test Slash command';
export const category: string = ''
export const run = async (client: Client, interaction: CommandInteraction): Promise<any> => {
  await interaction.deferReply(); 
  
  await interaction.editReply('Hello World!') 
}
#

I have added this but not sure if this is correct

export const options: string = ''
pale vessel
#

He do be type hinting everything

wheat mesa
#

Me when ts compiler gobbles up the type hints for my string literals

earnest phoenix
#

I did the same thing cause why not

slow terrace
#

I am running my bot on visual studio code on the rdp is this the right way to host it on it ?

earnest phoenix
#

How to make a slash command handler

boreal iron
#

It's pretty much the same as a common command handler

#

Just with the small difference to register/update/delete slash commands

earnest phoenix
#

every code i try it fails

boreal iron
#

client.application.commands.delete(...)

#

You can pass the whole command object or just it's ID

boreal iron
#

I mean the structure is absolutely the same but you won't pass message as argument into your run/execute function, you will pass interaction to it

#

Which you will receive in your event interactionCreate

slow terrace
#

H0w can i know the id

boreal iron
#

You will have to fetch the commands then to get your command by filtering the result by it's command name.

#

client.application.commands.fetch()

#

Keep in mind that's a promise

slow terrace
#

oh

pearl trail
#

why not just global slash command instead of per guild slash command

lament rock
#

That is very far from the truth and would be fixed if it was a Discord error. It sounds like an error on this person's end

#

@covert gale

viral plover
#

I'm coding in JavaScript and have been having trouble updating my embeds to work with Discord v13.
Is it still possible to have an image url put into an embed as an attachment?
I can either get the embed to post or the attachment, not both.

lament rock
#

you can set the file of specific fields with links still

#

use setImage to set a large version of the image providing the link to setImage

viral plover
#

I can just drop the link in the embed like

exampleEmbed.setImage("imageURL");
```and it works but I want to know if you can turn that URL into an attachment and have it display in the embed just like the URL image would.
#

That's what I was doing with my image embeds before v13.

lament rock
#

What?

#

If you want to set an attachment, you have to download the file and then create an attachment and specify that in the attachments field of the create message and reference attachments://filename.ext when you set the image field in the embed

viral plover
#

Is that new to v13?
I was able to make non-downloaded image links into attachments before.

lament rock
#

MessageAttachments are Buffers of image data to send to Discord. Discord.js downloaded the images first if it detected an http(s) protocol

viral plover
#

So it should still be possible and I don't know why it's not working.

lament rock
#

No because they removed that functionality. You need to manually do it yourself

viral plover
#

Oh, so it doesn't work anymore and you can only make attachments off of downloaded images.

lament rock
#

yep

viral plover
#

Well, at least now I know and I can stop frustrating myself trying to get it to work.
Thanks for your help~

boreal iron
#

That would be nonsense.
A registered command is registered and does not need to be registered again, unless it got deleted.

A proper command handler fetches the registered commands and compares them to your loaded commands.
It does then register unregistered ones, updates them if you changed the description or options for example or deletes the registered ones if this doesn’t exist locally anymore.

Also registering guild commands only makes sense to test things in the first place or to dynamically create commands in guilds for whatever reason since they will be available immediately.

#

Commands take up to an hour to be pushed to all guilds if you register them.
A joining guild should always have access to the commands within seconds or maybe minutes.

#

So that would only be the case if you register them over and over again for no reason as I explained above.

wheat mesa
#

it's simple

#

use a library that does it for you

#

(aka detritus)

boreal iron
#

Nope

#

It’s simple, create your own function loading your command files which you already have i guess, create a function that fetches the registered ones from Discord, compare them all together and then register/update/delete your commands

#

2 functions, only a few lines of code

#

Both been called in the ready event

#

Also consider to create a reload command calling these two functions

#

That lets you create or edit commands and get it in place without restarting the app

errant flax
#

how do i convert a bigint perms to a readable text?

wheat mesa
#

make your own function

#

iirc djs doesn't have "readable" permissions

quartz kindle
#

if you only have the bigint value and not an actual permissions object, just do new Discord.Permissions(bigint here)

lament rock
#

why does rewriting systems suck

#

I didn't want to use slash commands, but we all have to now 🙄

boreal iron
#

Use mentions?! okeh

#

I mean slash commands are in fact more user friendly

lament rock
#

perhaps, but Discord bots have been built on the existing system for years

#

They're mostly pushing this for privacy which doesn't even work because user bots exist. User bots literally break all of their security measures

boreal iron
#

Well some tech companies think they can change their whole image or the way users interact with their platform by forcing new rules

#

Which will mostly lead to issues and unhappy users instead of an improvement but companies think they need to reinvent themselves from time to time

lament rock
#

meta

boreal iron
#

Only issue is user bots are more dangerous since they don’t need an auth to get into guilds

#

So yeah I got your point

boreal iron
# lament rock meta

Yeah which is most likely the best example of one of the biggest players out there transforming into a gigantic shithole other than what it was or supposed to be in the beginning

lament rock
#

it always was a giant shithole

boreal iron
#

Also just exist because most people are addicted lurking for attention in any way

#

I never used it once in my life as well as insta shit or Twitter or any related other shit and still happy and around the net every day

#

Doesn’t mean it can’t be useful, it can but only for a very small circle of customers

sterile pulsar
#

Lol

lament rock
#

What the fuck is this shit

#

I am literally pulling my hair out because it's also saying the same thing for { [key: string]: unknown }

#

I guess declaring that it accepts a Model<any, any> works, but eslint does not like any

pale vessel
lament rock
#

It's a definition for a Table in Postgres

#

I'm rewriting my orm from JS to TS

#

I can provide the TS version once I'm done

pale vessel
#

How'd you define Model?

lament rock
#
class Model<T extends string | number | symbol, D extends Record<string, unknown>> {
    public table: T
    public primaryKey: Array<keyof D>
    public options: { useBuffer: boolean; bufferSize: number; bufferTimeout: number }

    public constructor(table: T, primaryKey: Array<keyof D> = [], options: { useBuffer?: boolean; bufferSize?: number; bufferTimeout?: number } = {}) {
        this.table = table
        this.primaryKey = primaryKey || []
        this.options = Object.assign({ useBuffer: false, bufferSize: 50, bufferTimeout: 5000 }, options)
    }
}
pale vessel
#

It didn't throw any error for me

lament rock
#

change line 36 to

class Database<M extends Record<string, Model<string, Record<string, unknown>>>> {
pale vessel
earnest phoenix
#

very complicated for me

#

i say i'm better at javascript

pale vessel
#

Dude I accidentally fixed it

lament rock
#

Then the methods won't work!

pale vessel
#

:c

lament rock
#

declaring {} as the def isn't an option sadly :(

#

I am SUPER proud of the orm. Especially buffering multiple calls together and de-duplicating prepared statement values

lament rock
# earnest phoenix very complicated for me

typescript is the better version of javascript since it helps you understand how coding really is like. There are some arbitrary requirements tied to it, but getting over that isn't too bad. The biggest upside is teaching you to think in terms of types where specific types have their own intrinsic properties and methods

#

I highly recommend a deep dive

earnest phoenix
#

lol

#

i main typescript

#

because i'm picky with everything

lament rock
#

just wanna be clear that you meant ts and not js?

earnest phoenix
#

i don't even know if what i said makes sense

earnest phoenix
lament rock
#

Okay. I take things pretty literally if I haven't interacted with people before. Now I know

earnest phoenix
#

i dropped js for ts a while ago

lament rock
#

Good choice

#

Wanted to get around to rewrite my bot, but the code base is over 20k lines last I checked

earnest phoenix
#

discordjs is just too bleh for me

#

too simple now

#

so i'm trying dpp

#

but my brain is getting fucked

#

not to mention the cpp operators

#

idek what & does

lament rock
#

if you wanna go pro mode, take a look at cloudstorm and snowtransfer on npm. I've updated them with original author perms and I like them :)

#

bitwise logic is fun

earnest phoenix
#

i only started 2 years ago

#

pls explain

#

oh

#

an ampersand

lament rock
#

& is bitwise and. | or bitwise or.

bits can be explained as a collection to some degree.
You can add bits together to form a collection and check for if the collection contains a bit which is the logic behind Discord permissions.

#

I can provide a Discord example. One sec

earnest phoenix
#

nah

#

i get it

#

i think

#
const member: Discord.Member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
#

something like that?

#

i forgot how djs worked

slender thistle
#

Bits aren't that hard if you think about it

earnest phoenix
#

i'm 13

#

don't murder me

slender thistle
#

It's just a different representation of your integers

earnest phoenix
#

so bits are ints?

#

actually

proven lantern
#

bits are base 2

earnest phoenix
#

lemme think

lament rock
#

Discord permissions example:
3145728 is a collection of (1 << 20) and (1 << 21) ORed together ((1 << 20) | (1 << 21)) 20 is the connect permission and 21 is the speak permission.
You can check if the collection contains a bit by doing:
collection & bit
if the collection contains the number on the right hand side of the operation, it returns the bit. Otherwise, it returns 0.

3145728 & (1 << 20) // 1048576

proven lantern
#

hex is base 16

slender thistle
#

Integers for you as a human are base 10

#

aka 0123456789

earnest phoenix
#

ye

#

so 1s and 0s

#

for base 2 i'm assuming

slender thistle
#

Binary (bits) is only 0 and 1, yup

#

HEX is 0123456789ABCDEF

earnest phoenix
#

wait

#

i've always wondered what ascii meant

#

this is the perfect time to ask

slender thistle
#

Depending on how you write them down, you will be able to convert it from, say, hex to decimal (base 10)

#

"American standard for code information interchange" I believe

proven lantern
lament rock
#

special encoding for characters

proven lantern
earnest phoenix
#

so just utf-8 but american?

slender thistle
#

It's basically a table that consists of Latin characters used in English and their decimal/binary representations, also what papi said

earnest phoenix
slender thistle
#

Well, UTF-8 is more of an "improvement" in a way as ASCII was the first to come afaik

#

Old computers worked with ASCII mainly, other encodings became a thing later

lament rock
#

utf-16 :)

earnest phoenix
#

dude

slender thistle
#

(:

earnest phoenix
#

all we do in a seventh grade comp sci class is code.org

proven lantern
#

the american standard was first and then they added support for other countries because the usa loves to help the world

earnest phoenix
#

i introduced something very easy to my teacher

#

and we did it for 3 days

#

and he said it was too hard

lament rock
slender thistle
#

Lol what did you tell him

earnest phoenix
#

can y'all guess what the lang was?

lament rock
#

Well. Not everyone thinks logically

earnest phoenix
slender thistle
#

Pascal? Python? C#?

#

kekw

#

Should've shown Assembly 3sChikaWink

earnest phoenix
#

i gave him a 10 minute video of the basics

lament rock
#

Fuck no to asm

#

even I don't wanna do asm even if I got paid

slender thistle
#

Make them all suffer.

earnest phoenix
#

what is asm

lament rock
#

assembly

slender thistle
#

Assembly

earnest phoenix
#

oh

lament rock
#

the closest fucking thing to machine code

slender thistle
#

No abstractions, everything done manually

earnest phoenix
#

y'all know how to make a cpp linker?

#

i'm tryna make a bot in dpp

slender thistle
#

Never worked with C and C++ 3HC_sunglasses

earnest phoenix
#

and mingw is giving me a hella hard time with it

#

actually

#

it might be the library

#

it's giving me a undefined reference __imp__* error

#

i'm just gonna take it as imp is an important

#

but it were an import

#

that'd be on me?

lament rock
#

google is cool

#

blame yourself first and then the libs and then the language

earnest phoenix
#

sadly

lament rock
#

I'm at the point of blaming the language :)

earnest phoenix
#

lmao

#

actually

#

it's the compiler!

lament rock
#

Welp. Good luck with that then

earnest phoenix
#

i'll be crying myself to sleep in a few

onyx torrent
#

can anyone help me in webhooks forwarding?

#

i am using top.gg/autoposter to sore vote events but also want the same webhook to be used by another bot

#

how can i do so?

lament rock
#

You have to forward the events to the other bot if you mean multiple sources receiving the same event

onyx torrent
lament rock
#

Not really because it depends on your setup. You could either make an HTTP request to your other bot or some other form of IPC

onyx torrent
#

idk exactly how to acheive it

lament rock
#

Then google examples

onyx torrent
#

so i use autoposter to log when any user votes

#

but the problem is its very inaccurate

#

doesnt logs every vote count

#

so i have to use an external bot "vote tracker"

#

now it also requires a webhook

#

but top.gg can handle only 1 at a time

#

so i need to forward my webhook to "vote tracker's" event

#

thats all i wnt............

lament rock
#

Then do that

onyx torrent
lament rock
#

If it's another process you have running, look up how to do IPC in whatever language you're using

onyx torrent
lament rock
#

I have no clue

onyx torrent
#

i have to host that too

pale vessel
lament rock
#

Nah. All of the DB methods require the data format assumption

#

what I have works

onyx torrent
#

suppose i reply to someone's message. Then is it possible to get the id of the replied message through interactions

amber lantern
#

When it gonna takes for approval on the Bot?

onyx torrent
amber lantern
#

oh thank you so much

#

i've been waiting for the answer

onyx torrent
amber lantern
#

oh sorry, My apologize

onyx torrent
#

np

onyx torrent
#

i cant figure out how to forward webhooks

molten mantle
earnest phoenix
#

where should i put message

#

async def mycmd(ctx, member: discord.Member,*,reason=None):

#

i want to add message here without getting error i am getting error when i add after ctx

#

With python can't you put it anywhere?

cold meteor
#

Could you possibly send the code like this

`

print("hello world")

`

earnest phoenix
#

Or does it matter where it goes

cold meteor
#

everything matters lol

earnest phoenix
#

mmm true

cold meteor
earnest phoenix
#

python kinda an annoying language at times

molten mantle
cold meteor
molten mantle
#

yes u can

cold meteor
#

wait now im confused.

earnest phoenix
earnest phoenix
still surge
#

How to show Total votes of each user in embed ?

spark flint
still surge
spark flint
glacial vapor
#

WOK Commands is so useful module

jolly notch
slow terrace
glacial vapor
#

i run my bot on heroku because i dont have money for hosting KEK

jolly notch
jolly notch
slow terrace
#

It's windows 10 system XD

jolly notch
slow terrace
#

Sad

glacial vapor
#

I'd say this is okay for my bot im not very experienced with coding bots

glacial vapor
#

and its not a all in one bot

#

its just a bot that is used to check stats from esportal

#

esportal is a csgo matchmaking provider like faceit

#

so i dont expect the count to be very high anyways

#

at first the user count was from cache and it showed 600 then my friend helped me make it count it from the servers and it now shows accurate number

#

and i finally added categories to the help command so it shows my commands KEK

#

I have WOK Commands node module its very useful and makes me not need to do a lot of stuff

dusty wave
#

I have been working on a ai chatbot

glacial vapor
dusty wave
glacial vapor
#

its gonna take time to teach it to be more humanlike

#

im happy that my bot was approved even tho it doesnt have much features

dusty wave
glacial vapor
#

but it does what its supposed to do and it does it pretty well

dusty wave
glacial vapor
#

i still need to do some changes at some point

#

at some point i need to make the stats channel into something anybody can add

#

at the moment its only in the support server that has no members lol

dusty wave
glacial vapor
#

my website only has a goose that you can click and it honks and then my webmail

#

so i can access my business email

glacial vapor
#

my discord status shows my business email just take the domain from that and u get to the website

glacial vapor
#

perfect update pushed to github and its gonna deploy on da bot now

stiff lynx
#

how can I get the guildId in an event.js file

boreal iron
#

You will receive the guild object in the associated event

#

For example the GUILD_CREATE or GUILD_DELETE event

stiff lynx
#

I'm trying to do a log system, and I've created a event for only logs

#

how can I get the guild Id here

boreal iron
#

By passing the guild object or just the ID to where ever you need it

stiff lynx
boreal iron
#

You may wanna be a little bit more specific

stiff lynx
#
const { MessageEmbed } = require("discord.js");
const log = require("../models/logs");

//const response = log.findOne({ guildId: channel.guild.id });

// Channel Topic Updating
client.on("guildChannelTopicUpdate", (channel, oldTopic, newTopic) => {
  const LogChannel = client.channels.cache.get("905412841266352148"); // Replace with your channel id
  const TopicUpdate = new MessageEmbed()
    .setTitle("Topic Updated!")
    .setColor("PURPLE")
    .setDescription(
      `${channel} Topic changed from **${oldTopic}** to **${newTopic}**`
    );

  return LogChannel.send({
    embeds: [TopicUpdate],
  });
});```
stiff lynx
#

Instead of that ID, I want to put obviously the id of the log channel of the guild

#

could work if inside every event I put the findOne?

#

srry for ping

boreal iron
#

Where did you create your event (guildChannelTopicUpdate)?
Why don't you simply pass the whole guild object ot it when you emit it?

#

What I see doesn't make much sense if you need to specify the channel yourself.

#

(if the event should be triggered in any guild, not just that one)

stiff lynx
boreal iron
#

Ok then log channel to see if that's actually a guildchannel obj or just a channel obj

#

If it's a guildchannel object it does include the guild property as well as the guildId

#

If not you fetch the channel by it's ID using your client and will get a guildchannel obj as result

#

This will contain the whole guild object of the channel, also it's ID of course

stiff lynx
# boreal iron Ok then log `channel` to see if that's actually a guildchannel obj or just a cha...

<ref *2> TextChannel {
type: 'GUILD_TEXT',
deleted: false,
guild: <ref *1> Guild {
id: '846752749555286027',
name: 'Server di cristiangrossano',
icon: null,
features: [],
commands: GuildApplicationCommandManager {
permissions: [ApplicationCommandPermissionsManager],
guild: [Circular *1]
},
members: GuildMemberManager { guild: [Circular *1] },
channels: GuildChannelManager { guild: [Circular *1] },
bans: GuildBanManager { guild: [Circular *1] },
roles: RoleManager { guild: [Circular *1] },
presences: PresenceManager {},
voiceStates: VoiceStateManager { guild: [Circular *1] },
stageInstances: StageInstanceManager { guild: [Circular *1] },
invites: GuildInviteManager { guild: [Circular *1] },
deleted: false,
available: true,
shardId: 0,
splash: null,
stickers: GuildStickerManager { guild: [Circular *1] }
},
guildId: '846752749555286027',
parentId: '846752750033305630',
permissionOverwrites: PermissionOverwriteManager { channel: [Circular *2] },
messages: MessageManager { channel: [Circular *2] },
threads: ThreadManager { channel: [Circular *2] },
nsfw: false,
id: '905413370210050048',
name: 'testfuigajkf',
rawPosition: 0,
topic: null,
lastMessageId: '905413437469892688',
rateLimitPerUser: 0
}

#

this is the log of channel

boreal iron
#

There you go, there's you guild object

stiff lynx
boreal iron
#

channel.guild.id

#

np

molten mantle
#

Top.gg's API docs is a bit confusing maybe adding some example of what you can do with it would be helpful 😃

boreal iron
#

Simply said receiving webhooks from topgg at your endpoint and generally the possibility to send requests to the API to get infos like bot stats, the last votes, etc.

spark flint
#

its pretty clear imo

#

it needs to be detailed

#

and it is

molten mantle
# spark flint and it is

i will try and see what i can do and do tests with a simple ping command ||it is allowed for,if a user wants to use a commands hey have to vote to use it every 12 hrs right?||

lyric mountain
#

not the majority of the commands

boreal iron
#

You can create vote only commands if you like to, it's your application

#

It just doesn't make sense to send a request to topgg everytime someone calls the command

#

To check if someone has voted

#

That would require to use webhooks then (recommended) and store the voters in a database

glacial vapor
#

oh i didnt notice i can post my bot repo url on topgg because its open source

molten mantle
molten mantle
boreal iron
#

Well... whatever Airtable is and how ever Google Sheets makes sense... lol but why not

earnest phoenix
#

It's a table but in the air (cloud)

molten mantle
#

lol know i just have to figure out how to check if the user voted in the last 12hrs

boreal iron
#

Well by sending a simple request to topgg's API or listen to their webhooks on your end.

#

Whatever you prefer

#

Both will only work if you got an approved bot

earnest phoenix
#

also do you really need to save vote data in a database?

#

memory works fine

boreal iron
#

Well the cache is gone if you restart the app

vital void
#

my bot is not able to kick a member even after it has role higher than the target and it has administration

earnest phoenix
#

and about bot restarts you can check if the user id exists in a vote Map (that auto deletes stuff after 12 hours) and if it doesn't then fetch from top.gg and cache again

boreal iron
#

Also if you store the user data for longer than a database is the way to go

boreal iron
#

Vote only command doesn't mean voted in the last 12 hours, can also mean at least voted once

boreal iron
#

As well as the developer portal

boreal iron
#

I see your reply but where's the code that actually kicks the member?

lyric mountain
boreal iron
#

Ah nvm, saw it now

lyric mountain
#

2nd: mess, that whole code is an entangled mess, please use if (condition) { code } blocks

boreal iron
#

What does the console error look like?

boreal iron
pale vessel
#

Are you checking the BOT's highest role position or the interaction MEMBER's? Oh I see

boreal iron
#

Looks better,y eah

earnest phoenix
#

screenshot the code better

boreal iron
#

he just fucked up the code tags

earnest phoenix
#

oh it had "expand", didnt see it

wheat mesa
#

Than having 30 if cases right next to each other

boreal iron
#

Sheeeesh Java coder

wheat mesa
#

Nah the only time I use Java now is in school

#

You fix it

earnest phoenix
#

define it

#

message

boreal iron
#

It sometimes happens messages, guilds, channels etc. aren't available

earnest phoenix
#

well its not displaying message author is it

#

nevermind it is

#

oh wait

#

bruh

#

u didnt add second field in embed

#

.addField(`Author`, message.author.tag)

boreal iron
#

lol

#

That should throw an error since field values can't be empty

#

That's the price of using that shit embed builder instead of writing the object yourself

earnest phoenix
#

just build your own library smh

boreal iron
#
{ 
  color: 0xffffff,
  description: "whatever",
  fields:
  [
    { name: "Test", value: "hello" },
    ...
  ]
}```
#

I'm gonna tell you something MAGIC

#

log your var in the console

#

console.log(ghostPing)

#

And see the magic

#

M A G I C

#

Yes, oh. It's an object freerealestate

#

The API accepts that object as serialized string

#

That's what all libs are doing for oyu

#

Or you can do yourself

#

Yes especially if you interact with the API without using a library.

#

How to interact with the API and the complexity is well documented in the Discord docs

#

just to say

earnest phoenix
#

doesnt it have garbage collection (nodejs)

wheat mesa
#

You can clear your caches every so often if you’re really worried about it, but I’m pretty sure you can set an option that makes items in the cache expire after a certain time period in djs

#

Maybe that’s just a detritus thing though, not entirely sure

quartz kindle
#

its a djs thing since v13

#

all caches have a .sweep() method

#

you can safely clear messages, members, users, most channels, presences, etc...

#

and in djs v13 you can configure max sizes and expiration times

#

no

#

guild.members.cache.sweep()

#

because thats the only thing thats designed to be swept

#

everything else is techincally not supported but it exists

#

no idea

#

why do you need to push it there?

#

lel

boreal iron
#

The event's called GUILD_CREATE

#

Providing the whole guild object

#

The object contains the whole guild object, guild.id

#

djs?

#

Keep in mind djs is using that weird camel format

#

guildCreate

#

Well async is only required if you got some async code running

#

Does include a list of events

#

djs can receive

#

The parameter is the guild object

#

client.on("guildCreate", (guild) => { console.log("Guild joined", guild); }

#

Wheter you search the cache for the guild first, then check for the channel or use the guild object directly

#

Lemme provide an example+

#

Yes that will work for a specific guild, assuming guild is your already choosed guild object

#

let guild = client.guilds.cache.get("guild_id");

#

for example

#

Searching all cached channels globally will may return similar channel (names) for different guilds

#

So make sure to always specify the guild before searching the channel cache

#

Yes.

slender thistle
#

Indeed.

boreal iron
#

You can simply one-line that shit tho if needed
client.guilds.cache.get("guild_id").channels.cache.find((channel) => channel.name.toLowerCase() === "general")

#

Well no, you already got the guild object, provided by the event

vivid fulcrum
#

^

#

also, you need to account for the fact that some people won't have a channel named general

boreal iron
#
client.on("guildCreate", (guild) =>
{
  console.log("Guild joined", guild);

  let channel = guild.channels.cache.find((channel) => channel.name.toLowerCase() === "general");

  if(channel) channel.send("fuck you for adding my bot");
})
#

Because code examples are fun

vivid fulcrum
#

you can make that even shorter