#development

1 messages ยท Page 1322 of 1

wind kayak
craggy agate
faint prism
craggy agate
#

anyways

#

i need to define commands

faint prism
#

Wasn't it Speedy who was asking about C# earlier?

craggy agate
#

probably

wind kayak
#

Yeah

#

You need to define commands

craggy agate
#

ue

#

ye*

wind kayak
#

Yeah

craggy agate
#

lol in general vc there's inly a person

#

only*

#

the issue is probably in the load commands file KoalaThink

#

or idk

#

somewhere lol

wind kayak
#

Just make sure that you declare commands and that it's an array

opal plank
#

maps > arrays

#

change my mind

wind kayak
#

No, can't change your mind

opal plank
#

having indexed commands is much more efficient

#

less search[

wind kayak
#

But for a beginner with a small bot it doesn't matter

opal plank
#

and they have unique indexers

#

if we gonna throw coding practices out of the winodws just cuz the bot is small why not make every command under its own client.on('message') ? you can have up to 11 commands

wind kayak
#

๐Ÿง 

opal plank
#

i dont see being a small bot excuse for using bad code

earnest phoenix
#

Hey Erwin

opal plank
#

sup

craggy agate
#

But for a beginner with a small bot it doesn't matter
like me

earnest phoenix
craggy agate
#

i'm the beginner that you're searching for

opal plank
craggy agate
#

๐Ÿ‘€

opal plank
#

best command handler right here

wind kayak
#

Oof

#

Delet

opal plank
#

no u

wind kayak
#

My eyes are burning

opal plank
#

best command handler

wind kayak
#

Don't tell me that's your bot panik

opal plank
#

thats my test branch for the clustering, yes

#

my focus is on the clustering and IPC bit, not on this rn

craggy agate
#

Panikk

opal plank
#

so i didnt even bother doing a better command handler

earnest phoenix
#

@slender thistle i tried the module u recommended

#

it didnt work

#
import asyncio
import aioschedule as schedule
import time

async def job():
    print('hello bob')
    asyncio.sleep(1)

schedule.every().day.at("18:25").do(job)

loop = asyncio.get_event_loop()
while True:
    loop.run_until_complete(schedule.run_pending())
    time.sleep(0.1)

print('help')
#

it never prints help

craggy agate
#

nope

drifting wedge
#

channel = discord.utils.get(payload.text_channels, name="starboard") how can i make channel be the channel called starboard when im only passing self and payload?

#

its for starboard command discordpy

wind kayak
#

Never heard of MariaDB

livid lichen
#
                                    ^

TypeError: Cannot read property 'filter' of undefined ```
restive furnace
#

@wind kayak it's MySQL v2

livid lichen
#

Uhhh... what??

wind kayak
#

I don't use d.js but I'm pretty sure it's members.cache

livid lichen
#

oh

#

Thanks

spare trench
#

anyone here who knows a way to clear cache of discord / twitch. im trying to fetch some images with twitch api but image wont update when im refetching it?

earnest phoenix
#

there shouldn't be any cache behavior by default

#

but just append a cache buster to the url

#

google it if you don't know what it is

spare trench
#

i added a unix timestamp on the url provided ...jpg?time=(unix timestamp)

earnest phoenix
#

that should work

spare trench
#

but doesnt have any affect

earnest phoenix
#

what are you fetching with

spare trench
#

i use nodejs with discord.js and twitch.tv-api which fetch data from streamer when its starts the stream. when its live it fetch stream data which includes api thumbnail.preview (small, medium, large), where i added the timestamp ?time=unixtimestamp

#

${data.stream.preview.medium}?time=${dateunix} something like this

opal plank
#

@spare trench twitch doesnt have cache

spare trench
#

@opal plank i figured out. its the cache of discord when i delete manual %appdata%\discord -> Cache folder and restart discord the images change to the new ones

opal plank
#

what are you even doing that requires you to clear your own cache?

#

whenever you do a request it returns the url of the preview

#

thats about it, no caching involved

#

so idk what you even attempting to do, less so about adding timestamp on your url

blissful coral
#

Promo

#

Cut out the name

#

Mods gonna get mad

spare trench
opal plank
#

yeah, i assumed that part, but what does the timestamp have to do with the returned preview?

spare trench
#

i want to refresh the image. but because discord is creating a cache of it, because name of image provided by twitch api is always the same it wont change and it keeps example: GTA V image of yesterday but streamer is currently playing Mario Kart it wont change to the new image because of cache

opal plank
#

try editing the embed

#

that might force the url to reload

spare trench
#

ke will try

night rose
#

Is there anyway that i can make the text color in discord embed?

earnest phoenix
#

hi

#

Why is my bot not listed in top.gg

#

why why why why why why why why why why

opal plank
#

@night rose dont think so, you could use image generation to bypass that though

#

@earnest phoenix cuz you either:
havent submitted your bot
it hasnt been approved yet
it has been declined

night rose
#

Ow yeah thnx

earnest phoenix
#

No, I was not rejected however

#

I have not been answered in the first place

#

what should I do

snow urchin
earnest phoenix
#

And why was not answered

#

why why why why ._.

opal plank
#

you need to submit your bot first

#

@snow urchin cuz its empty

earnest phoenix
#

I sent it

opal plank
#

then be patient

#

it takes up to 8 weeks+

snow urchin
#

@snow urchin cuz its empty
@opal plank How.. its sends an embed?

opal plank
#

is the embed empty though?

earnest phoenix
#

How will I ask for a response without sending the bot ._.

opal plank
#

i'd recommend logging the embbed object before sending it

snow urchin
opal plank
#

try adding content on it

snow urchin
#

Who here play rocket league Iโ€™m doing a giveaway check it out My user name is Lawzdogplayz
@obtuse tiger bruh

opal plank
#

@obtuse tiger advertise somewhere else

#

@modern sable

#

anyway

earnest phoenix
#

fuck off

#

thanks

opal plank
#

add content, i think your embed is malformed @snow urchin

#

if it only sends the content that would mean the embed is malformed

snow urchin
#

It works when sending straight to a channel

sudden geyser
opal plank
#

im fairly certain you can send the payload directly @sudden geyser

sudden geyser
#

Yes, but you need to supply it as the second argument under embeds: [...]

snow urchin
#

so null, embed?

opal plank
#

i dont think you even need that

snow urchin
#

didnt think so either

opal plank
#

just like send() it can parse the payload directly

sudden geyser
#

actually you don't even need to pass embeds: [...] nvm

opal plank
#

try what i said, add content property on your object

#

outside of embed

#

{content: 'test', embeds: ...}

tulip ledge
#
    fetch("api stuff")
        .then(res => res.json())
        .then(json => {
            return json;
        });

Why does this return undefined? But console.log(json) gives me the JSON

rotund yarrow
#

i need hewp with making a snipe command pls dm me

honest perch
#

so in theory im manually trying to launch 2 shards (for fun)

#

but it keeps restarting

#

without errors

opal plank
#

sharding is a fucking nightmare

#

i dont recommend messing with it @honest perch

honest perch
#

yes but im bored

#

and bored = max cpu

opal plank
#

ngl, watching paint dry is less infuriating than doing sharding

honest perch
#

i did it

#

lets launch 20 shards

#

and it crashed

opal plank
#

you starting to get a hold of what i was talking about in the previous msg

honest perch
#

i mean, it worked with 2 so i dont see the problem with 20

opal plank
#

i will simply repeat my message above

tulip ledge
#
    await request('api', function (error, response, body) {
        if(error) throw error;
        if(response.statusCode !== 200) return console.log(chalk.red("ERROR ") + 'Status code was ' + response.statusCode)
        return body;
    });

Returns Promise { <Pending> } even tho its an async function?

opal plank
honest perch
#

nvm 2 is the most that will spawn

#

sad

opal plank
#

websocket connections and spawning childs with IPC pipes is one hell of a nightmare

shy turret
rotund yarrow
#

nvm 2 is the most that will spawn
@honest perch wdym

honest perch
#

i can only spawn 2 shards without it breaking

rotund yarrow
#

im interested in sharding for fun also

#

oh

tulip ledge
#

Any help?

rotund yarrow
#

is there a like limit per how many servers you have

opal plank
#

yall legit hoping into a hornets nest, im not even kidding

rotund yarrow
#

possibly

honest perch
#

websocket connections and spawning childs with IPC pipes is one hell of a nightmare
@opal plank websockets themself are a pain

opal plank
#

sharding is:
hard
annoying to debug
advanced
and is a bitch with its mood swings

rotund yarrow
#

@opal plank well can you help me with a snipe command

opal plank
#

there aint much in a snipe command

rotund yarrow
#

yeah

#

but for some reason

opal plank
rotund yarrow
#

mine isnt working

#

also im not advanced

opal plank
#

its legit 3 lines

rotund yarrow
#

;>

#

well

#

send the lines then?

opal plank
#

on messageDelete => map.set(channel.id, message)

on snipe command
message.channel.send(map.get(channel.id))

#

thats it

tulip ledge
#

HeLlO? Am I being ignored?

rotund yarrow
#

thats it
@opal plank huh funny but that only works in index.js right what if i have a command handler

opal plank
#

then you pass the map around

rotund yarrow
#

oh gosh

#

liol

opal plank
#

as function parameter

#

or make a getter method under message

rotund yarrow
#

is that the most efficient way (as far as lag goes) to do it?

opal plank
#

probably passing it as parameter

rotund yarrow
#

right

opal plank
#

though depending on how your command handler is setup, it may not work very well

#

so its case-use

rotund yarrow
#

hmm

#

thats da issue

#

oofs

opal plank
#

then attach it to something handy

#

like client

rotund yarrow
#

ive tried that

wet dove
#
    await request('api', function (error, response, body) {
        if(error) throw error;
        if(response.statusCode !== 200) return console.log(chalk.red("ERROR ") + 'Status code was ' + response.statusCode)
        return body;
    });

Returns Promise { <Pending> } even tho its an async function?
@tulip ledge async function returns a promise

tulip ledge
#

how do I depromisify?

wet dove
#

^ that should work

tulip ledge
#

Nope request.then is not a function

#

Tried it before

#

And node-fetch fetch('api').then(res => {return res.json()}) returns Promise { <Pending> } too

opal plank
#

is 'api' even a valid url?

tulip ledge
#

yes but I don't want to leak my api key

#

It works in the browser

opal plank
#

oh i see

tulip ledge
#

and console.log(body) works too

#

I just need to return it

opal plank
#

you could try util on it

#

util usually works well with callbacks like that

#

to promisify it

tulip ledge
#

ill try

opal plank
#

const a = await promisify(your function);

#

then work on a afterwards

wet dove
#
fetch('api').then(res => res.json()).then(json => {
code here
})``` @tulip ledge
tulip ledge
#

tried that too

#

Doesn't work

opal plank
#

that would likely turn into a massive callback hell

#

specially if they do more stuff after that then() chain

#

try promisifying

tulip ledge
earnest phoenix
#

Bruh

#

.then(res => res.json()) is enought

#

You can't promisify a promise

tulip ledge
#

Taf urs returns Promise { undefined }

earnest phoenix
#
require("util").promisify(fetch)(<whatever you want to do in the function>)```
sudden geyser
#

callbackify ๐Ÿง 

earnest phoenix
#

Callback hell more like smol brain

tulip ledge
#

@earnest phoenix urs returns pending too

earnest phoenix
#

Resolve it?

#

bruh

tulip ledge
#

idk how lol

earnest phoenix
#
    .then(res => res.json())
```not works?
tulip ledge
#

no

earnest phoenix
tulip ledge
#

I have a console.log in a diff file tho maybe thats why!

#

?*

earnest phoenix
#

Nope

tulip ledge
#

Weird

earnest phoenix
#

Have you tried

#
let response = await <node-fetch>("API").then(res => res.json());```
tulip ledge
#

No

#

Ill try tmrw cuz I have a big test tmrw and I need sleep

wraith haven
#

What would be the best way to show two command prefixes without it being confusing

#

my two prefixes are chai and ,, so something like chai, . ?

#

I feel that could get confusing tho

quartz kindle
#

node-fetch uses two promises

#

you have to wait for the first promise, which returns a response object containing a data stream, then you have to wait for the second promise, which reads the stream and converts it into the appropriate data format you chose

#

so basically ```js
let response = await fetch("bla");
let data = await response.json();

// or

fetch("bla").then(response => response.json()).then(data => console.log(data))

tame kestrel
#

@wraith haven you can just put like , or chai

earnest phoenix
#

Or wrap both prefixes between one line code blocks

toxic junco
#

#credit

earnest phoenix
#

, and chai

toxic junco
#

C

#

c

pure lion
#

Anyone know how I can test an error event? D.js

#

I've tried client.ws.emit("error", "bar") and got nothing

quartz kindle
#

client.emit()
without ws

earnest phoenix
#

is there any token system bot
similar to licensy
that isnt donatebot.io also
license system bot

deep robin
#

I am looking to develop a bot.

earnest phoenix
#

is there any bots or source code for custom bots that can take payments through dms

#

so i dm the bot and it goes through a payment process

quartz kindle
#

idk if there is anything like that, but you can look into the paypal and stripe apis

blissful coral
#

Console log

#

type is not being changed to all enabled

drifting wedge
#

message = await self.client.get_channel(payload.channel_id).fetch_message(payload.message_) how would i get the message?

#

like payload.message_content?

#

content doesnt work

earnest phoenix
#

@blissful coral What's type at that point

sudden geyser
#

If you log results[0].channeltype do you get '1'

drifting wedge
#

python

blissful coral
#

@earnest phoenix Was a stupid error I fixed it

snow urchin
#

I have this inside a function inside a class, inside another function for the same class I log this.attachments, why does it return undefined?

merry thunder
#

How i can fix it?

sudden geyser
#

You were supposed to pass a function, but you passed nothing/something that evaluated to undefined instead.

merry thunder
#

@sudden geyser Here

sudden geyser
#

Notice the ) after "collect"

#

The second argument is supposed to be the function.

#

You instead closed it.

zenith knoll
#

message.guilds.members.cache.get(args[0]) DOes this check if a user is in any server that the bot is in?

#

or is it not valid syntax

sudden geyser
#

@snow urchin could you share your code on a site like hastebin.com as it's hard to visualize.

zenith knoll
#

omfg

#

nvm

sudden geyser
#

big brain

snow urchin
#

alright get ready for a big block of hastebin code ๐Ÿ˜„

zenith knoll
#

?

snow urchin
zenith knoll
#

is client.guilds.members.cache.get(args[0]) valid syntax?

snow urchin
#

line 90
line 418

#

@sudden geyser

merry thunder
#

@sudden geyser Actually I do not understand. Can you explain in more detail?

zenith knoll
#

bruh

#

lol

#

2pings

sudden geyser
#

No, it's not valid syntax. Check the docs for info as members is not a member of the .guilds cache manager.

zenith knoll
#

k

quartz kindle
#

@snow urchin how are you using this class?

#

can you show some code using it?

snow urchin
#

errrrrr one sec

#

๐Ÿ˜„

merry thunder
#

@sudden geyser Actually I do not understand. Can you explain in more detail?

snow urchin
#

@quartz kindle

#

Let me just push current

sudden geyser
#

It's not working because you only passed one argument to it. You closed it via ) after "collect". This comes down to syntax.

merry thunder
#

Like that?

snow urchin
#

reaction.on("collect", async (reaction, user) => {
// function code
})

#

Tim, that repo should be updated now, so you can have a look

quartz kindle
#

@snow urchin in the attach command, for example

#

you use new Ticket, then ticket.fetch, then ticket.attach

#

ticket.attach uses this.attachments

merry thunder
#

Og thx

quartz kindle
#

but this.attachments is only created by ticket.create

snow urchin
#

so it can only be used in ticket.create?

quartz kindle
#

your current code only creates this.attachments if you run ticket.create somewhere before using ticket.attach

snow urchin
#

yes, I do

#

Oh wait

#

I see now ๐Ÿ˜„

#

Since I push the attachments to the database, I guess my solution would be to set this.attachments in ticket.fetch

#

Thanks ๐Ÿ˜›

faint prism
umbral zephyr
#

how do you make a data base in discord.js

#

ping me

opal plank
#

@umbral zephyr you dont make a database in discord js

#

you make a database, then use the language(js) or a library(also js) to connect and exchange data from/into it

umbral zephyr
#

ok

opal plank
#

you need to do research about which database you need to use first

umbral zephyr
#

ik that

opal plank
#

Mongo, Maria, Cassandra, postgres, or the likes

#

it varies on preference and usage

#

its the right tool for the right job tbh

#

the only realistic thing you should worry about is ACID compliance and Relational Database

#

the rest shouldnt matter too much, unless dealing with specifics

sudden geyser
#

Why are there like 5-9 ways to represent a multi-line string in YAML

earnest phoenix
#

because fuck youโ„ข๏ธ

#

i hate working with yaml

#

it's so... inconsistent despite being a format

sudden geyser
#

I like some things of it, like creating a multi-line string isn't as painful as it is in JSON, but I have to agree that it's too inconsistent.

sweet ruin
blissful coral
#

If I am using a forEach and its going to run twice for 2 found then how do I make it wait 1 second before running the next foreach?

sudden geyser
#

You should convert it to a for of and use something that could block/pause the execution.

#

An example would be making a sleep function defined as so: js const sleep = (ms) => new Promise((res) => setTimeout(res, ms))

sweet ruin
#
        function sleep(milliseconds) {
            const date = Date.now();
            let currentDate = null;
            do {
              currentDate = Date.now();
            } while (currentDate - date < milliseconds);
          }



///then here you want it to sleep just add where you want it to sleep
sleep(1000);
#

@blissful coral

sudden geyser
#

Then in your forEach, , you call sleep(...).

#

Creepa I don't recommend that method.

#

That loop will constantly keep running until it's over.

#

That could be millions of iterations.

sweet ruin
#

odd mine doesnt do that period :/

#

well use Lite's method I guess

blissful coral
#

Wait so where would I put sleep then @sudden geyser

#

Just put sleep after the code

sweet ruin
#

where you want it to sleep at

sudden geyser
#

You put it where you want to block/pause the execution in the loop.

blissful coral
#

Okay

sweet ruin
#

so like where you want it to wait at in the code

sudden geyser
#

You also need to await it.

blissful coral
#

const sleep = (ms) => new Promise((res) => setTimeout(res, ms))

#

so I just change ms to the time

#

Ok

sweet ruin
#

no no

sudden geyser
#

No, you call the function with the duration in milliseconds.

blissful coral
#

ah

sweet ruin
#

leave that the same. but then where you want it to sleep do ```js
sleep(1000) //this sleeps it for one second which is 1000 milliseconds

blissful coral
#

I am probably dumb for this

#

It is true but isn't returning

sudden geyser
#

.query(...) is executed later as it's a callback. There's no guarantee found will be true on time.

blissful coral
#

Is there a work around?

sudden geyser
#

Yes, handle it in the callback instead.

opaque seal
#

Or maybe make the query function async

#

I think you could do that with promisify

sudden geyser
#

The only gain from that is readability/syntax though. And they would still need to make the forEach function argument async, and since promises are also called "later", there wouldn't be any benefit.

blissful coral
#

That is what I have

opaque seal
#

The only gain from that is readability/syntax though. And they would still need to make the forEach function argument async, and since promises are also called "later", there wouldn't be any benefit.
yeah it would just be cleaner imo

#

query isn't async by default

#

i thin, but I'm not sure, never used it

blissful coral
#

This worked for checking forEach with IDs on a different bot I had

#

Don't know why it isn't working here

sonic lodge
#

don't use await with .forEach

#

it won't wait for the async function to complete

earnest phoenix
#

Hello

#
import asyncio
import aioschedule as schedule
import time

async def job():
    print('hello bob')
    asyncio.sleep(1)

schedule.every().day.at("18:25").do(job)

loop = asyncio.get_event_loop()
while True:
    loop.run_until_complete(schedule.run_pending())
    time.sleep(0.1)

print('help')
#

this never prints help

#

i used module aioschedule

blissful coral
#

Shouldn't this work better?

#

The loop isn't running

#

hmm

#

I see it don't answer

#

LMFAO

#
const channels = message.mentions.channels.filter(c => c.type === 'text')
console.log(channels[i].id)
``` Tells me channels[i] is undefined
i is 0
#

When I do

#
const channelarray = channels.array()
console.log(channnelarray[0].id)
#

I get a error that id is not defined aka channelarray 0 is not defined

#

Anyone know why?

stark abyss
#

Does anyone have any idea on how to draw text using canvas?

#

spooky maybe your channels is just getting the id and not object? nah that wouldn't make sense never mind

past ferry
#

Btw, guys, arch I've seen in my bot guilds logs, that my bot has leaved this server or other servers (pseudo-leave, I mean - bot receives leave event, but isn't actually leaving) . And I know that discord is doing this brrrrrrrrrr. But is there some way to know about this "weird" events?

#

*know/detect

vernal rivet
#

O.o too many questions

quartz kindle
#

a GUILD_DELETE event is emitted by discord when guilds become unavailable

#

you can check if the event contains unavailable:true

past ferry
#

So... I can detect it.

#

Thanks for answer.

#

Have a great day catsmug

vernal rivet
#

Isnt channels a collection not an array @blissful coral

blissful coral
#

@vernal rivet yeah but you can do .array() according to the docs

vernal rivet
#

What are you trying to do?

blissful coral
#

So I provide multiple channels

#

Then it will search the db for each channel

#

I am using a for loop to search by each one

#

But I can't do channel[number] because it isn't a array

vernal rivet
#

There should be a .forEach method

blissful coral
#

when I search through my db it doesn't come back in time and I can't use await because it won't wait for it in a forEach

vernal rivet
#

How long does the db call take?

blissful coral
#

Should be instant

#

We talked about it here.

vernal rivet
#

I mean it looks like you're doing remote db correct?

#

Oh your dealing with callbacks

#

Try wrapping it in a promise

#

Either that or inside a function and have a function call into a variable

jovial void
#

can someone explain the basics of clustering in the context of a discord bot? I think I have a slight understanding, but any explanation would help a lot :)

stark abyss
#

Does anyone have any idea on how to draw text using canvas?

quartz kindle
stark abyss
#

thx

#

ctx.font = '30px "bhb"';
ctx.fillText(textMessage, 0, imgHeight/2);

#

I was doing that but it wasn't working for some reason

quartz kindle
#

@jovial void clustering doesnt actually mean anything in itself, its just a popularly used word to define multiple processes running multiple shards each

jovial void
#

so I can have two processes running like 30 shards each, with the first process running shards 0 - 29 and second running 30 - 59 and nothing conflicts with each other

quartz kindle
#

yes you can

jovial void
#

do you have any insights on how one would go about implementing such a system?

#

thank you for your help thus far btw :)

quartz kindle
#

depends on the library you use

jovial void
#

I am on python, but basic principles might apply across all languages, idk

#

never done something like this before, thats why I'm finding it a bit confusing sorry

quartz kindle
#

so technically you would need to supply a total shard count, ie 60, and a list of shard ids, ie [0,2,3,4,...30] to the client

#

but from looking at the dpy docs, it seems discord.py doesnt support internal sharding

#

their shard_id option only accepts an integer, and not an array

#

oh wait i forgot about autosharded client

#

let me check

#

ah yes here it is

#

client = discord.AutoShardedClient(shard_count=10, shard_ids=(1, 2, 5, 6))

#

so you would launch one process with ids 0 through 29, and another with ids 30 through 59, both with a total count of 60

jovial void
#

ohhhhhhh

#

I see

#

so suppose I've calculated the required amount of shards, I could then launch processes accordingly with the appropriate shard_count and shard_ids for each process

quartz kindle
#

yup

jovial void
#

coming together

#

yeah ig I just thought it was more complicated than it sounds

#

thanks a lot!

#

really appreciate it

quartz kindle
#

np :3

stark abyss
#

Tim filltext does work but it won't wrap the text on image

#

I am not sure how to do that, do you have any idea?

quartz kindle
#

there is no text wrapping on canvas

#

fillText does have a 4th parameter where you can specify the text's max width in pixels, and if reached, it will automatically resize the font to make it fit

#

but there is no autowrap feature

#

you need to wrap the text yourself

#

you can use the measureText functions to get the text width in pixels, and if bigger than the width you're working with, split the text into two lines

#

to make it go into a second line, you need to use fillText again but with a different Y value

#

you need to define the line height yourself

stark abyss
#

oh

#

well not very convenient thanks for helping though

carmine summit
#

how do I throw a DM if missing permissions on sending messages?

boreal iron
#

Doesnโ€™t sending message return a value assuming to be the message id if successful?

#

Create a new DM channel with a user. Returns a DM channel object.

drifting wedge
#

how do i convert a pdf to some other filetype?

boreal iron
#

Guessing it will return null or false if not successful meaning permissions are missing or recipient doesnโ€™t allow DM. @carmine summit

carmine summit
#

I can't seem to make it work by try{}catch{}

#
try{
message.channel.send('Test')
}
catch (e) {
    message.author.send(`Error: ${e.message}\n\nKindy join our support server and report it there.`)
  }
#

try catch doesn't work and gives an error in the console

earnest phoenix
#

Canvas is an un found module yet if I run npm install canvas it installs then displays tons of errors then donโ€™t work.

solemn latch
#

Canvas has requirements

earnest phoenix
#

Wdym

solemn latch
#

Check out their github page

earnest phoenix
#

Idk where to find their page at.

boreal iron
#

Canโ€™t copy your message nicely on mobile but try to catch the return value by let result = message...send();

See what result will be.
If successful it should be an object if not false or null I assume. @carmine summit

carmine summit
#

uh

#

there is a lot of coding to do

#

if i did that

#

there are like a thousand of message.channel.send() in my codes

#

ah wait

#

client.member.hasPermission()

#

YES

boreal iron
#

Just test it once to see the result.

#

Well or a different way, aye

carmine summit
#

nono I'm ust gon use .hasPermission()

#

that could work too

#

alright

#

hmm

#

channel overrides could be a pain

earnest phoenix
#

Idk where to find their page at. @solemn latch

boreal iron
#

Good luck gonna sleep now

solemn latch
#

Did they rework lmgtfy, it sucks now :(

carmine summit
#

So .hasPermission() returns true/false depending on the roles and completely ignores channel overwrites.

#

What I wanted to do, is to check if the channel has permission overwrites

zenith knoll
#

How would you loop through json info to check if a item is alr there?

#

so

carmine summit
#

@zenith knoll json.includes(search)

zenith knoll
#

so

#

if my json was this:

carmine summit
#

no?

zenith knoll
#
{
  '2': {'s': '3', 'r': '7'}
}
#

and i did search for a 7

#

would it get to the 'r': '7'

carmine summit
#

so you want to search the values

zenith knoll
#

yea

carmine summit
#

then return the object

#

of which the value is in

zenith knoll
#

no

#

im just checking IF its true

#

like

#

im checking if 7 is in the 'r' key of anything in the first key layer

#

its hard to explain

#

here

#

is an json example ion it

#
{
  372856234756: {"chanid": 102348796, "firstmsg": "hi"},
  23423424: {"chanid": 3242342, "firstmsg": "ji"},
  987789789: {"chanid": 10232342448796, "firstmsg": "by"}
}```
#

@carmine summit

solemn latch
#

Should this data be in a database?

zenith knoll
#

no

#

its in a json

solemn latch
#

Yeah, but why?

zenith knoll
#

wdym

#

cause json is more plug and playable

#

and scalable

solemn latch
#

I feel like this data looks like something that should be in a database

#

Databases fit millions and millions of row

#

Rows

#

And are designed to be plug and play

#

And do this perfectly

zenith knoll
#

ok

#

lets pretend it is

#

okay?

solemn latch
#

Loop over the entire json

zenith knoll
#

uh

#

thats what im asking...

solemn latch
#

In what language?

zenith knoll
#

js

solemn latch
#

Use object keys

zenith knoll
#

o

#

im so dumb

#

thank you

#

so i get the array of obj keys

#

and do a foreach

#

and check if the id is alr used

#

kk

small prairie
#

What are the advantages/disadvantages of Internal Vs Traditional sharding?

#

D.js

solemn latch
#

Internal you can save some ram and put more shards in a single thread iirc

small prairie
#

So internal is better?

solemn latch
#

Internal can be better. Can be worse

carmine summit
#

So .hasPermission() returns true/false depending on the roles and completely ignores channel overwrites.
What I wanted to do, is to check if the channel has permission overwrites.
So: Role permissions: false, Channel overwrites: true //returns true

solemn latch
#

If your bot uses 100% of a thread at 2000 guilds, and you use internal sharding making it so you have 4000 guilds per thread you'll have some lag issues

small prairie
#

Ah gotit

#

thanks!

solemn latch
#

You can combine them iirc

small prairie
#

Yea ig

#

2*2

solemn latch
#

Huge bots typically do afaik

small prairie
#

Huge bots have such of different things lmao

zenith knoll
#

huge bots use their own thing

#

lol

#

jk

small prairie
#

One last question, const client = new Discord.client({ shardCount: 'auto' });
this is for normal d.js
If i use commando
Um what would it be then?

sonic lodge
#

same thing, though .client should be capitalized

small prairie
#

Thanks

zenith knoll
#

wait

#

that works?

#

you just do shardCount: 'auto to shard?

#

lol

small prairie
#

Seems like it

#

sad

#

auto doesnt work

sonic lodge
#

you set shards to 'auto', not shardCount

small prairie
#

Oh

#

Welp

#

My bad

#

Is there any client.shards number which tells how many shards are their or something?

#

got it nvm

#

client.shard.count

jovial void
#

@quartz kindle round two, this time with just one question lol. That got me thinking about how I'd sync all the instances up with one another (say for a restart) and how I'd actually obtain the recommended number of shards in the first place. Would this call for some fancy docker stuff or am I overcomplicating things? (please ping if you respond, thank you!)

carmine summit
#

i can't connect to pm2

#

package.json

{
  "name": "Bot",
  "version": "1.0.0",
  "description": "",
  "main": "bot.js",
  "scripts": {
    "prod:start": "pm2-runtime bot.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.19.2",
    "discord.js": "^12.3.1",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "moment": "^2.27.0",
    "ms": "^2.1.2",
    "node-fetch": "^2.6.0",
    "pm2": "^4.5.0",
    "quick.db": "^7.1.1"
  }
}

.env

PM2_PUBLIC_KEY=nothingtoseehere
PM2_SECRET_KEY=nothingtoseehere

bot.js

const pm2 = require('pm2')
small prairie
#

connect to pm2? do you mean the web dashboard thingy

carmine summit
#

connect to pm2? do you mean the web dashboard thingy
@small prairie yes

small prairie
#

pm2 link

carmine summit
#

???

small prairie
#

Thats what it says on the help thingy

carmine summit
#

SyntaxError: Unexpected identifier

#

pm2 link
@small prairie where ima put this?

small prairie
#

Wait what

#

Why are you requring pm2 in bot?

carmine summit
#

uh

#

no?

small prairie
#

Isnt pm2 a terminal app?

carmine summit
#

idk

solemn latch
#

Yeah

carmine summit
#

ok i removed it

#

package.json

{
  "name": "Bot",
  "version": "1.0.0",
  "description": "",
  "main": "bot.js",
  "scripts": {
    "prod:start": "pm2-runtime bot.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.19.2",
    "discord.js": "^12.3.1",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "moment": "^2.27.0",
    "ms": "^2.1.2",
    "node-fetch": "^2.6.0",
    "quick.db": "^7.1.1"
  }
}

.env

PM2_PUBLIC_KEY=nothingtoseehere
PM2_SECRET_KEY=nothingtoseehere
small prairie
#

Whenever i think i cant be surprised
New devs at DBL Do it

#

Dbl new devs never cease to amaze me

carmine summit
#

hmm

#

it says that ita a dependency

#

so i added back "pm2": "^4.5.0", in package.json

#

its still dosn't connect

small prairie
#

Uh what do you think PM2 is?

carmine summit
#

process manager

#

monitoring

small prairie
#

Monitoring for?

carmine summit
#

processes

#

thingy

#

restart

#

thingy

#

@small prairie

#

help

granite tendon
#

helloo

#

I have made progress :D,

#

how do I install discord.js though

small prairie
#

npm i discordjs

granite tendon
#

?

small prairie
#

how do I install discord.js though
^

granite tendon
#

Im a noob

#

What do you mean

small prairie
#

Do you known what NPM is?

fathom pecan
#

Ok I started The Bot Iow Do you put it on Top.gg lmao

granite tendon
#

no

small prairie
#

Do you know what nodejs is?

granite tendon
#

no

clever dust
#

do you know how to make js code?

small prairie
#

Do you know javascript?

granite tendon
#

no

#

no

small prairie
#

Welp this isnt the right place to start then

granite tendon
#

but how do i install discord,js though

clever dust
#

learn javascript first

small prairie
#

^

carmine summit
#

@small prairie I need help conencting to pm2 please

granite tendon
#

im just want to know how to install that

small prairie
#

Install discordjs is not like installing "An app" or a game

#

You need to use terminal in the most cases

granite tendon
#

...

small prairie
#

And you need basic JS knowledge if you are starting with d.js

clever dust
#

you won't understand what you will be doing if you don't understand javascript

small prairie
#

Or there are always people who will mock you like crazy

granite tendon
#

;-;

small prairie
#

That has happened to me, The developer world is not all friendly

solemn latch
#

Well, not in communities like this one

small prairie
#

Who knows lmao
A good guy might be having a bad day and comes here to vent

#

But yea, This server is a good place

granite tendon
#

thats good

#

i guess making a bot will take ages

carmine summit
#

its pretty much easy

small prairie
#

If you are an complete beginner give it like one full week

#

Thats all,

carmine summit
#

you tell a variable what he is, then call it, then he will say what he is

small prairie
#

Thats confusing but surprisingly correct

carmine summit
#
var str = "Hello world!";
console.log(str);
//returns Hello world!
granite tendon
#

0.0

solemn latch
granite tendon
#

thanks

small prairie
#

Yea

carmine summit
#

aaaaa

#

pm2 is not efined

#

aaaa

small prairie
#

I dont understand what you are trying to do so i cant help

solemn latch
#

Type pm2 in console

#

๐Ÿค”

small prairie
#

Afaik pm2 isnt even a in file module

solemn latch
#

Pm2 is just a process manager.
Not sure what you'd want a module for it?

granite tendon
solemn latch
#

Its the basics of the basics

granite tendon
#

...

solemn latch
#

Its best to understand a bit about the language first really.

granite tendon
#

which link do i choose first

small prairie
#

There is only 1 link ._.

solemn latch
small prairie
#

ok nvm

granite tendon
#

the link in the site

solemn latch
#

Most here hate it, but codecademy i like for the very very basics. Anything past like the second section kinda sucks

carmine summit
#

i typed pm2 in console, gave me pm2 is not defined

small prairie
#

do npm i pm2 -g

granite tendon
#

wtf

#

i give up

carmine summit
#

ok then???

small prairie
#

then retype pm2 in your console

slender thistle
#

Codecademy sucked for me with HTML and CSS ngl

#

I barely learned anything, it was mostly an equivalent of copy-pasting with all the "enter the small snippet of CSS here"

carmine summit
#

then retype pm2 in your console
@small prairie gave me an object that has spaggethi code

small prairie
#

sigh

#

My exam began, Thats good enough for me to leave this cheat

solemn latch
#

Hf

small prairie
#

thats really not the thing to have fun about but Thanks!

solemn latch
#

What happens when you do pm2 monit

sudden geyser
#

@slender thistle codecademy has sucked at a lot of stuff tbh

#

every task you finish it suggests pro mode

slender thistle
#

lol

sudden geyser
#

or that one time where in their C++ tutorial were talking about inlines and shoved a bunch of code I never saw and basically said "yeah test it and see if it makes your code faster"

solemn latch
#

I miss the days when it didn't have pro mode

#

Would have 4 pages of text per example

#

๐Ÿคทโ€โ™‚๏ธ

slender thistle
#

I'm sorry hwat

sudden geyser
#

oh and there's one more thing. When the number of users for a course isn't that high they'll usually just put the number of users they have across the entire site (join 45m+ "learners") which looks silly

slender thistle
#

man

#

I prefer to use multiple sources for my stuff tbh

somber wigeon
hazy sparrow
#

how do i check if a channel type is dm

#

d.js

carmine summit
#

if (message.channel.type === 'DM')

#

@hazy sparrow

#

wtf 1000 lines

#

lmao

hazy sparrow
#

ty

#

i was doing "DIRECT_MESSAGE" instead of "DM'

tardy hornet
#

message.guild.channels.cache

#

will it say how many channels are in the server?

carmine summit
#

add .size at the last part maybe

lost cove
tardy hornet
#

add .size at the last part maybe
@carmine summit and if i want it to say how many text channels, then that?

message.guild.TextChannels.cache.size

hazy sparrow
#
const Discord = require("discord.js");

const client = new Discord.Client();

const fs = require('fs');

const prefix = 'bow ';


client.commands = new Discord.Collection();

const commandFiles = fs.readdirSync(`./Commands/`)
for(const file of commandFiles){
     const command = require(`./Commands/${file}`);

    const name = file.split('.')[0];
    client.commands.set(name, command);
  }
 
  const cooldowns = new Discord.Collection();
  client.on("ready", () => {
  console.log("bow bot is online!!");
  client.user.setActivity(`${client.users.cache.size} people!`, { type: 'WATCHING' });
  
});




client.on("message", (message) => {
  
  if (message.channel.type === "DM") return;
  if (!message.content.toLowerCase().startsWith(prefix) || message.author.bot) return;
  const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
 
if (!cooldowns.has(command.name)) {
    cooldowns.set(command.name, new Discord.Collection());
}



 

if(client.commands.has(command)) {
   client.commands.get(command).execute(message)
 
  }
 


}

  )
 









  client.login('NzI1NjMwMjkwNTg3ODExOT5.Xw8ltQ.aNqF_ii6thN-J9hhTWOdLXOsQEI')
// fake token dw

okay so even if i do this thing where it checks if the channel type is dm, it still responds to dm commands how do i fix it

carmine summit
#

uh

#

delete

#

token

#

leak

#

DELETE

hazy sparrow
#

read the comment

carmine summit
#

ok for that im not gon help you

#

you freaked me out

tardy hornet
#

if (message.channel.type === 'dm') return

#

@hazy sparrow
if (message.channel.type === 'dm') return

sonic lodge
#

dm is lowercase ^

hazy sparrow
#

oh

#

thanks

tardy hornet
#

yo cwickks

#

add .size at the last part maybe
and if i want it to say how many text channels, then that?

message.guild.TextChannels.cache.size

sonic lodge
#

you need to loop through message.guild.channels.cache and manually count the text channels

carmine summit
#

BRUH

tardy hornet
#

............

carmine summit
#

-nodot

sonic lodge
#

or filter the cache to include only text channels and count the size of the filtered collection

tardy hornet
#

how?

#

thats what im trying to do

sonic lodge
#

message.guild.channels.cache.filter((channel) => channel.type === 'text')

tardy hornet
#

there was only 2 channels

carmine summit
#

message.guild.channels.cache.filter((c) => c.type !== "category").size;

tardy hornet
#

then?

sonic lodge
#

there you go

#

you have a collection of only text channels, and you can find the size of it easily with .size

tardy hornet
#

k

#

ty

#

hmm

#

@sonic lodge

silver lintel
#

ive got message.channel.send(attachment); and it takes some time to upload, so how do i make it send a message and delete the message after it has sent?

tardy hornet
#

what do you mean?

carmine summit
#

put dot size

tardy hornet
#

where?

#

ive got message.channel.send(attachment); and it takes some time to upload, so how do i make it send a message and delete the message after it has sent?
@silver lintel
message.channel.send(attachment).then (message.delete({timeout: time in milliseconds }));

silver lintel
#

ahh yes thanks

#

but

#

no

#

wait

carmine summit
#

no

tardy hornet
#

put dot size
@carmine summit where? i tried and its giving me errors

silver lintel
#

no

carmine summit
#

define it

#

first

tardy hornet
#

oh yeah

carmine summit
#

ahhh

tardy hornet
#

right

carmine summit
#

message.channel.send(attachment).then(m => m.delete({timeout: 5000 }));

tardy hornet
#

yeah

#

sorry

#

forgot

silver lintel
#

excaept i dont know the timeout

#

its an await message.channel.send attatchment

tardy hornet
#

how many seconds you want?

#

10?

silver lintel
#

:/

#

wait

#

oof its so easy

tardy hornet
#

every second is 1k

carmine summit
#

its called miliseconds

tardy hornet
#

@carmine summit where do i put the .size

carmine summit
#

Imagine doing this with microseconds

#

at the last

#

at the evry last

tardy hornet
#

lol

silver lintel
#

await is asynchronous right?

tardy hornet
#

where do i put the size?

#

cwickks

silver lintel
#

after

#

at the end

carmine summit
#

how do i get guild owner?

#

message.guild.____

#

???

#

forgot

tardy hornet
#

no

#

look

silver lintel
#

message.guild.owner

tardy hornet
#

${message.guild.owner.user.tag}

#

yeah

carmine summit
#

why is there user.tag

#

excuse me

tardy hornet
#

i use the tag lol sorry

#

where do i put the size!

carmine summit
#

AT THE END

#

OF THE

#

THING

#

message.guild.channels.cache.filter(m => m.type != "category").size

hazy sparrow
#

spoonfeed?

carmine summit
#

no

#

forkfeed

#

๐Ÿ‘Œ

restive furnace
#

why, guild owner might not be cached use this instead: js guildOwner ? guildOwner#tag : guildMembers#fetch(ownerId).tag

carmine summit
#

ffs

tardy hornet
#
case 'meme':
  fetch( 'https://meme-api.herokuapp.com/gimme' )
  .then( async response => {
    const meme = await response.json();
    const embed = new MessageEmbed()
      .setColor( '#EFFF00' )
      .setTitle( meme.title )
      .setURL( meme.url )
      .setImage( meme.url );

    message.channel.send( embed );
  } );
break;
pearl trail
#

dispatcher.setVolumeLogarithmic(queue.volume / 1000000000000000);

tardy hornet
#
case 'meme':
  fetch( 'https://meme-api.herokuapp.com/gimme' )
  .then( async response => {
    const meme = await response.json();
    const embed = new Discord.MessageEmbed()
      .setColor( '#EFFF00' )
      .setTitle( meme.title )
      .setURL( meme.url )
      .setImage( meme.url );

    message.channel.send( embed );
  } );
break;

@tardy hornet
not working

#

please someone

carmine summit
#

uh

#

user.avatar returns a random string i dunno what to do with it

sour junco
#

Rpg h

tardy hornet
#

how do i see the servers that added my bot?
i want to make a command that will send me the servers that added him

#

i need help, i dont want to get in the eval stuff

carmine summit
#

Uh

pearl trail
#

client.guilds.cache.size

carmine summit
#

tat will get your bot instanly denied

#

because of

#

privacy

#

thingy

#

but if you do want? client.guilds.cache.forEach(g => console.log(g.name))

#

just add a filter that only you can see it

carmine summit
#

oof im stupid

#

How can I know the reason if someone banned/kicked my bot?

#

feedback101

merry thunder
carmine summit
#

edit??????????????

#

or change ur bot's pfp

hasty mulch
#

@merry thunder Are you talking your botโ€™s logo?

merry thunder
#

yeah

hasty mulch
#

Change the profile picture in the application page

boreal iron
#

How can I know the reason if someone banned/kicked my bot?
@carmine summit You will receive the GUILD_DELETED event through the gateway if so.

#

Returning the guild id.

merry thunder
#

Change the profile picture in the application page
@hasty mulch Have another opitons?

boreal iron
#

And afaik the reason if the user has used one.

hasty mulch
#

@hasty mulch Have another opitons?
@merry thunder Uhhhhhh, @modern sable ?????

modern sable
#

Not that i'm aware of

carmine summit
#

And afaik the reason if the user has used one.
@boreal iron how

boreal iron
#

One second...

#

Just woke up lol

carmine summit
#

wow

#

I've learned so much

boreal iron
#

Oh okay

#

nvm

carmine summit
boreal iron
#

Huh whatโ€™s your issue with it?

#

It will return the client object and optionally the reason as string of given by the client.

carmine summit
#

How do I do this

#

BanInfo.reason?

boreal iron
#

huh damn I canโ€™t copy on mobile

#

Gimme a second

#

To move to the PC

#

Let god thanks for Windows updates...

#

Oh I see... that just fetches a ban reason, not a kick reason

#

hmm

fickle sapphire
#

That's because kick's dont come with a Reason by standard.. If you want to save the reason you've gotta use a Database or a JSON file.. but its easier to use a Database

boreal iron
#

You can use the user ID or object etc.

#

To fetch the ban.

#

The reason is optional, which means you need to check if baninfo.reason is undefined and if so there's no reason.

#
guild.fetchBan(user).then(baninfo => console.log(baninfo.reason));

@carmine summit

#

But I'm not sure if "fetchBan" will be transmitted through the gateway before the BOT is banned.

#

Could probably be possible the BOT will receive the GUILD_DELETED event only.

#

Not tested this out yet.

carmine summit
#

its too confusing for me

boreal iron
#

lemme test it real quick...

#

oh hold on for a second... may I'm missing the right intents

#

need to check this real quick

#

oof

earnest phoenix
#

ohh meeennnnn

boreal iron
#

Thought if your BOT is used in less than 100 server priviledged intents are allowed, shouldn't they?

misty sigil
#

You need to enable them

boreal iron
#

oh nvm, forgot to enable them

#

aye, thanks for the hint

#

idk, no reason given on GUILD_MEMBER_UPDATE event

#

for kicks even if I enter one

misty sigil
#

You need to fetch that from audits iirc

boreal iron
#

oh

#

yeah got that, GUILD_MEMBER_... events don't contain the reason

#

You need to fetch that from audits iirc
It would be needed to fetch the latest audit log if any GUILD_MEMBER_REMOVE event is been sent through the gateway, aye

#

its too confusing for me
@carmine summit guild.fetchBan(user).then(baninfo => console.log(baninfo.reason));
How so?

dark axle
shell crystal
#

.

boreal iron
#

Wrong channel for dotposts

earnest phoenix
#

lol

boreal iron
#

Just for the deleted message about Math.random issue:
(quoting the JS docs)

function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min)) + min;
}
#

And your_array.length will return the array size, to use it as max value to return the keys, you need to do: let max = (your_array.length - 1);

#

Because array keys will start at 0, not 1

vagrant tree
#

hi, i have an embed with a thumbnail and a main image. i want to know if i can attach a link to the images? the code is simply embeded.set_image(url=img) but i want to be able to click on the image and send the person to another url. is this possible?

opaque seal
#

no you can't

boreal iron
#

But you can set an URL for the embed itself, which will turn the title into a link.

vagrant tree
#

ok thanks

surreal sage
#

What is the new message.mentions.channels.first()

quartz kindle
#

@jovial void discord has an endpoint which gives you the recommended number of shards, so you can get them from there, then arrange them among your processes

#

This can be done either from a script that launches/controls the processes like a sharding manager, or it can be done from the processes themselves as long as they have a way to identify themselves

#

For example if process 2 knows that it is number 2, then it can fetch the total and assign itself the latter half

tardy hornet
#
if(args[0] === prefixMention) return message.channel.send('please use the `!` prefix in this command, ty')```

its still sending the command.
#

when i use the mention

#

someone

gleaming pebble
#

uhhh

#

what di you need?

#

do*

opal plank
#

args is usually AFTER your prefix

#

if you followed the guide, at least

#

@tardy hornet

#

without more code we cant tell much

tardy hornet
#

the command is the you kill the user.mention.first()

#

but if someone use my @mention perfix it will kill the bot

#

not the user

opal plank
#

!command bla bleh
prefix is !
command is command
bla is args[0]
bleh is args[1]

by logic using args[0], it surely wouldnt do anything regarding to prefix cuz its under args

gleaming pebble
tardy hornet
#

no im not

gleaming pebble
#

that is what helped me

#

oh ok

#

IDK what you want

tardy hornet
#

i want it to kill the user not the bot

gleaming pebble
#

oh

opal plank
#

i still dont see what you are trying to do

gleaming pebble
#

for that i had a video

#

it gives a role, but it has the code to dtect a mention.

#

its for discord.js

opal plank
#

the snippet your provided doesnt give any info whatsoever
if you want a mention, message comes shipped with a mentions porperty in it which you can use to get the person, so i have no idea what your prefixMention is and how its related to what you want to accomplish

#

like i said, i need more context

tardy hornet
#

i have a command that for example:
!kill @mention

and when i use the mention prefix, its killing the bot, not the user, because its killing the message.mentions.users.first()

opal plank
#

yes cuz thats the first one

tardy hornet
#

ik

gleaming pebble
opal plank
#

if message.mentions.first() === me => get second mention

#

first() returns first mention

#

if i do @opal plank kill @tardy hornet , the first mention is me, which is returned in first()

#

instead of using that, get the second mention instead

#

so just check if the prefix is your mention, if so, grab second mention

#

if the prefix is the normal prefix, get the first mention

#

should be as simple as doing that

tardy hornet
#

thats what im trying to do

opaque seal
#

if i do @opal plank kill @tardy hornet , the first mention is me, which is returned in first()
iirc correctly they are ordered by ID not by mention order

opal plank
#

if(client.mentions.users.first().id === client.user.id) => get second mention
else { //use first mention}

#

im not too sure tbh about the order they come shipped in, so you might be right

opaque seal
#

See this @tardy hornet ^

opal plank
#

what i sent should also work

opaque seal
#

TLDR

You might expect it to ban @Offender, because that is who you mentioned first. However, the Discord API does not send the mentions in the order they appear; They are sorted by their ID instead.

tardy hornet
#

what do i put in the get second mention part

opal plank
#

regexing is rally bad

#

i try to avoid it whenever is possible

opaque seal
#

regexing is rally bad
@opal plank ?

opal plank
#

interate in the map and get the second index value

tardy hornet
#

what do i put in the get second mention part
@opal plank

opal plank
#

you could use spread operator for this

#

@opaque seal regex is really bad when it comes to performance