#development

1 messages · Page 1657 of 1

lament rock
#

No

#

You can use a regex with | to replace multiple

earnest phoenix
#

AbortError: The user aborted a request. what is the error?

old cliff
#

bloated code++

lament rock
old cliff
#

should I make it more bloated?

lament rock
#

Seems like a high level interface for a simple task

boreal iron
#

@tired panther replace(/.*(a|b|c|d).*/gi)

earnest phoenix
#

oh

crimson vapor
#

@delicate zephyr

lament rock
#

.* could match the entire string

boreal iron
#

correct

old cliff
#

its called cramping code

tired panther
lament rock
#

You don't need to account for that. You can use boundary characters

boreal iron
#

ah oh, wew no, there isn't

boreal iron
#

not needed for js

#

it was a pattern for searching a string and I wrote replace in front of it, lmao

lament rock
boreal iron
#

happens if your fingers and your brain aren't working together

lament rock
#

it happens

boreal iron
#

just wait another 10-15 years and you will feel like I do

old cliff
#

is this the limit of bloated code?

lament rock
#

I cant read this

#

I don't think I'd be going crazy at 30

final lynx
#

im back >:)

lament rock
#

hi back

pale vessel
#

:)

sudden geyser
lament rock
#

run your code through a minifier

old cliff
#

already did

lament rock
#

all 1 line and obfuscated

#

good times

final lynx
#

im making a purge messages cmd

#

there is an error

#

but i cant find out what it means

lament rock
#

What's the error

final lynx
#

here is the script

#

and here is the error

opal plank
#

how are you sending messages? since channels arent cached you cant message.channel.send() cuz theres no channel
you either message.reply() or send it via raw gateway with request with the channelId payload

final lynx
#

i blurred my name

opal plank
#

same as above

cinder patio
#

ctx being Context

opal plank
#

use conetxt.message.reply()

lament rock
opal plank
#

ive had that before too

final lynx
#

so i should have this

opal plank
#

realistically you'd wanna cache guild/channel though

final lynx
lament rock
#

Message.startsWith isn't a function either. it should be Message.content.startsWith

earnest phoenix
lament rock
#

content is the string

final lynx
#

where do i put
msg.content.startsWith

opal plank
#

@cinder patio you can always do what i said and use rest which doesnt require cache, the way you're approach is using the cached method

lament rock
#

replace the message.startsWith
with
message.content.startsWith

final lynx
#

do i put message or msg

lament rock
#

message

final lynx
#

ok

#

so should i make all msg variables into message

lament rock
#

if it says msg is not defined and you use a mixture of both msg or message, you should choose one or the other

final lynx
#

ok

#

ill test it again

#

but before i do

#

this is how it should look, right?

opal plank
# cinder patio Alright txn
let channel = await context.client.rest.createGuildChannel(context.message.channelId);
channel.createMessage('hello world')
#

this is doable too

cinder patio
#

hm

crimson vapor
#

is this detritus

opal plank
#

yeah

cinder patio
#

why is the method called createGuildChannel

final lynx
#

i tried it

#

and the error is

cinder patio
#

that's a bit misleading

final lynx
#

"message not defined"

opal plank
#

cuz you can create different channel types

earnest phoenix
opal plank
#

DM is dm channel

boreal iron
#

oh Erwin is here

cinder patio
#

But doesn't the function fetch it

opal plank
#

the rest is guild related as parent

cinder patio
#

basically

final lynx
#

@lament rock said to put msg

lament rock
#

How do you define your message variable in the client.on("message"

opal plank
#

yeah, it does

#

but you can use rest to send it directly too

cinder patio
#

but why create thonkku

#

why not fetch or get

lament rock
#

if message is not defined and msg is not defined, what is defined?

final lynx
#

good question

lyric mountain
#

getch

final lynx
#

in my other commands i have a mix of msg and message

cinder patio
#

If I were to see that without knowing I'd think it creates a new guild channel

lament rock
#

You shouldn't do that unless you're assigning a new message to a variable

final lynx
#

so i should put

#

msg = ""

opal plank
#

you can use this directly too

#

ffs discord

final lynx
#

and put something in the ""

opal plank
#

discord fucking up again

#

@cinder patio did my messages send?

boreal iron
#

If I were to see that without knowing I'd think it creates a new guild channel

getGuildChannel() would probably be a better name

cinder patio
#

ye

opal plank
#

then there we go, you can use rest directly to send the message with the id

#

without any cache

#

as long as you have the channelId(which should always be present on message payload) you should be fine

lament rock
#

no, your .on("message"
should look like

.on("message, msg => {
// put your code here

but you can swap msg with whatever you want to cast your message variable to

final lynx
#

so

opal plank
#

personally i would recommend to keep channel cache, but its up to you

final lynx
#

i should replace all "msg" with "message"

cinder patio
#

I don't need any channel data

final lynx
#

.on("message, msg => {

#

goes at the start

boreal iron
#

Just take a look into your code and see which name you've choosed

opal plank
final lynx
#

wait

#

where do i put the ".on("message, msg => {"

lament rock
#

personal preference on how to name your variables. It has no effect on how things work

crimson vapor
#

grafana setup time pog

final lynx
#

where do i put it tho

boreal iron
lament rock
#

Where you have your code for checking command stuff. Where does the message variable in your code come from?

#

Do your other commands work?

#

You should be doing it similar to those.

final lynx
#

all my commands work

#

except the RemoveMessages one

#

i have a ban command, a kick command, and a embed command

lament rock
#

What are you doing differently

final lynx
#

i cant rly tell

#

do u want to see one of my other commands

#

and then see the purge command that doesnt work

boreal iron
#

Just show the code a few lines ABOVE your first command

copper cradle
#

so, considering discord lets 9999 people share the same name

final lynx
#

this works

boreal iron
#

there you go, your var name is message

final lynx
#

this doesnt

lament rock
#

Are you doing a client.on("message" for every single command

final lynx
#

so i should put my variable as message on all commands

copper cradle
#

it's possible to rate your discrim, u just need to find someone with your same discrim and set yor name to theirs

lament rock
#

do not do that

final lynx
#

all the commands that work have one

boreal iron
#

omg... I didn't see his last line

final lynx
#

the command that doesnt have one doesnt work

copper cradle
#

I'm not even gonna help here lmfao

final lynx
lament rock
#

It's bad practice to do that, since all of the event listeners are triggered and that requires more processing when everything could be routed through 1 listener. You should look at a tutorial for command handling

final lynx
#

so doing that would make my Bot slower

lament rock
#

how you have it, it would be

final lynx
#

ok

boreal iron
#

In simple words put all of your commands into the listener

final lynx
#

so what should i do in replacement

lament rock
#

you could also run into logical errors the current way it is

#

look at a command handler example

#

hard to describe in words

final lynx
#

cant you type what to put instead

lament rock
#

No. Not gonna type code on mobile lol

final lynx
#

rip

#

so how should i find what to put

lament rock
#

Look at examples and cherry pick what you think is relevant

final lynx
#

wont changing it mess up the command

boreal iron
#
client.on("message", (message) =>
{
   if(message.content.startWidth(...)) ...
   else if(message.content.startWidth(...)) ...
   else if(message.content.startWidth(...)) ...
}
lament rock
#

It shouldn't so long as things are mapped for compatibility

#

startWidth 02thinkgif

boreal iron
#

is horrible but works

#

nope

lament rock
#

It does not work

boreal iron
#

lol startWidth

final lynx
lament rock
#

string.startWidth is not a function xd

boreal iron
#

SHHH

#

just a typoi

#

and another one, lmao

boreal iron
# final lynx

As we told you already, DON'T create a new listener for each command

final lynx
#

should all commands be on the same listener

lament rock
# final lynx

You mentioned you have 1 message event for each command, the way they showed was having multiple commands in 1 event listener. You can make use of multiple if else statements in the same scope

boreal iron
#
client.on("message", (message) =>
{
   ALL COMMANDS IN HERE
}

NOT another client.on (listener)

#

oof... what a complicated case

final lynx
#

wait

boreal iron
final lynx
#

so i should do this

#

and put all commands

#

on the same listener

lament rock
#

looks correct

final lynx
#

u sure?

boreal iron
#

at least do an else if instead of if

final lynx
#

wont putting all my commands on one listener slow it down a LOT

lament rock
#

At a glance, looks okay. Not gonna check all of it since I'm short on time

sour flame
#
const Client = require('../structures/Client');
const { Messege, ReactionUserManager } = require('discord.js');
module.exports = {
    name: `modmail`, 

    /**
     * @param {Client} client
     * @param {Message} message
     * @param {String[]} args
     */
    run: async(client, message, args) => {
        if(client.threads.has(`${message.author.id}`)) return message.channel.send(`You already have a ticket open!`); 
        const Channel = message.guild.channels.cache.find(ch => ch.name.toLowerCase().includes("modmail"));
        if(!Channel) return message.channel.send(`There is no mod mail channel`);
        const newChannel = await message.guild.channels.create(`modmail-${message.author.id}`, {
            type: 'text',
            parent: client.catergory,
            permissionOvwrwrites: [
               {
              id: message.guild.id,
                deny: ['VIEW_CHANNEL']
               },
               {
                   id: client.role,
                   allow: [`VEIW_CHANNEL`, `SEND_MESSAGES`, `ADD_REACTIONS`, `ATTACH_FILES`]
               },
               {
                   id: message.author.id
                   allow: [`VEIW_CHANNEL`, `SEND_MESSAGES`, `ADD_REACTIONS`, `ATTACH_FILES`] 
               }
            ]
        });
        Channel.send(client.embed({
            description: `This user ${message.author.tag} (${message.author.id}) is creating a modmail thread! Created in ${newChannel}`
        }, message));
     }
}
``` Help meh my second allow is underlined red
final lynx
#

one sec

#

so i put all commands

#

under the same

boreal iron
#

Still yes.

sage bobcat
boreal iron
#

Help meh my second allow is underlined red

#

wut?

quartz kindle
final lynx
#

ok

#

ill do that

sage bobcat
#

One message removed from a suspended account.

sour flame
boreal iron
#

,

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lament rock
#

also, no. Imagine this:
you have 15 scopes listening for the same event:

when that event fires, all of the listeners are looped through and triggered with the data from the event that triggered and they do their own processing as compared to 1 doing it's own processing for every command since 1 message can only contain 1 command, logically speaking.

lyric mountain
quartz kindle
#

with all events in the same listener, the internal event emitter will just do runMessageListener(messagedata), if you use multiple listeners, the internal code has to do runMessageListener(messagedata); runMessageListener(messagedata); runMessageListener(messagedata); etc...

boreal iron
lyric mountain
#

and I thought he copying the embed example code was bad

sour flame
old cliff
#

Is there a way I can get function of setInterval?

sage bobcat
#

One message removed from a suspended account.

lyric mountain
old cliff
#

I didn't

#

I evaled

#

Now I want the function

lyric mountain
#

then use that variable in the setInterval

final lynx
old cliff
#

The function was important and I deleted the message

final lynx
#

the odes i have arnt 100% original

sage bobcat
copper cradle
#

inb4 they nest their listeners

sage bobcat
#

One message removed from a suspended account.

final lynx
sage bobcat
#

One message removed from a suspended account.

boreal iron
sage bobcat
#

One message removed from a suspended account.

final lynx
#

what command r u talking bout

lyric mountain
#
const someFunc = () => {
  doBlaBlaBla();
  //whatever
}

setInterval(someFunc, time);
sage bobcat
old cliff
#

I asked for something else

boreal iron
#

well then try to ask again

lament rock
#

You should learn JS a bit more before trying to make a bot. You could possibly put users at risk who depend on your bot and think it's reliable if it isn't and is being developed by an amateur. Nothing against you, personally.

old cliff
#

I wanted to get the function I used in an Interval

final lynx
#

i watched youtube videos on how to make the commands

sage bobcat
#

One message removed from a suspended account.

lyric mountain
sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

setIntervals are anonymous

old cliff
#

No... I evaled the code

#

Is there any process.intervals ?

lyric mountain
#

no

sage bobcat
#

One message removed from a suspended account.

lyric mountain
final lynx
#

i watch new vids

lyric mountain
#

you can do this

sour flame
#
DiscordAPIError: Invalid Form Body
parent_id: Not a category
    at RequestHandler.execute (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
    at async GuildChannelManager.create (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\managers\GuildChannelManager.js:112:18)
    at async Object.run (C:\Users\ravi_\Desktop\Discord Bots\Mail\commands\modmail.js:15:28) {
  method: 'post',
  path: '/guilds/821471322885718076/channels',
  code: 50035,
  httpStatus: 400
``` I got an error
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#
const interval = setInterval(() => something, time);
lament rock
#

There is no way to access ticking timers without assigning them to a reference

old cliff
#

Ok

final lynx
old cliff
#

Might have to write the code again

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

final lynx
#

ok

#

i get that

#

i also use the discord.js help page

#

they constantly update that

#

also

#

i came here to ask for help with a cmd :/

lyric mountain
#

why is more valuable than how

boreal iron
#

aye and you got your answer where to write your commands

lyric mountain
#

you become dependant on others

lament rock
#

I'm also unsure if you can access functions initialized with a NodeJS.Timeout

They'd have to hold a reference somewhere, but idk if the reference is actually anonymous or on the Timeout instance itself

lyric mountain
#

don't ask for a fish, ask to learn how to fish

boreal iron
#

and you got your answer to use the var name message instead of msg according to your code

final lynx
#

and im asking for help

lyric mountain
#

videos are too bad for languages like javascript or java

sour flame
#
DiscordAPIError: Invalid Form Body
parent_id: Not a category
    at RequestHandler.execute (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
    at async GuildChannelManager.create (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\managers\GuildChannelManager.js:112:18)
    at async Object.run (C:\Users\ravi_\Desktop\Discord Bots\Mail\commands\modmail.js:15:28) {
  method: 'post',
  path: '/guilds/821471322885718076/channels',
  code: 50035,
  httpStatus: 400
}

``` An error Help!
lyric mountain
#

those langs update too often

final lynx
#

so i can learn why something work and others dont

boreal iron
lyric mountain
final lynx
#

i did

lyric mountain
#

like, the most barebones you can get

sour flame
lyric mountain
#

no you didn't

final lynx
#

yes i did

lyric mountain
#

you started with an example code

final lynx
#

i made a empty file

lyric mountain
#

then pasted the code

final lynx
craggy pine
final lynx
#

where i wrote the code

sour flame
#
const Client = require('../structures/Client');
const { Messege, ReactionUserManager } = require('discord.js');
module.exports = {
    name: `modmail`, 

    /**
     * @param {Client} client
     * @param {Message} message
     * @param {String[]} args
     */
    run: async(client, message, args) => {
        if(client.threads.has(`${message.author.id}`)) return message.channel.send(`You already have a ticket open!`); 
        const Channel = message.guild.channels.cache.find(ch => ch.name.toLowerCase().includes("modmail"));
        if(!Channel) return message.channel.send(`There is no mod mail channel`);
        const newChannel = await message.guild.channels.create(`modmail-${message.author.id}`, {
            type: 'text',
            parent: client.catergory,
            permissionOverwrites: [
               {
              id: message.guild.id,
                deny: ['VIEW_CHANNEL']
               },
               {
                   id: client.role,
                   allow: [`VEIW_CHANNEL`, `SEND_MESSAGES`, `ADD_REACTIONS`, `ATTACH_FILES`]
               },
               {
                   id: message.author.id,
                   allow: [`VEIW_CHANNEL`, `SEND_MESSAGES`, `ADD_REACTIONS`, `ATTACH_FILES`] 
               }
            ]
        });
        Channel.send(client.embed({
            description: `This user ${message.author.tag} (${message.author.id}) is creating a modmail thread! Created in ${newChannel}`
        }, message));
        client.threads.set(message.author.id, {
            channel: newChannel
        })
     }
}
``` @boreal iron here my code
final lynx
#

the only thing that i have copy and pasted was the embed code, and ive learned enough to change almost all variables and still have the command work, exactly how i want it to

lament rock
#

Looks like Timeout._onTimeout is the reference to the callback function. You just need a reference to the Timeout

nimble kiln
lament rock
boreal iron
#

I guess that's not the only error

sour flame
#

I got a new error

#
DiscordAPIError: Invalid Form Body
parent_id: Not a category
    at RequestHandler.execute (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
    at async GuildChannelManager.create (C:\Users\ravi_\Desktop\Discord Bots\Mail\node_modules\discord.js\src\managers\GuildChannelManager.js:112:18)
    at async Object.run (C:\Users\ravi_\Desktop\Discord Bots\Mail\commands\modmail.js:15:28) {
  method: 'post',
  path: '/guilds/821471322885718076/channels',
  code: 50035,
  httpStatus: 400
}
#

Code is

lament rock
#

The ID you passed doesn't belong to a category channel

sour flame
#
const Client = require('../structures/Client');
const { Messege, ReactionUserManager } = require('discord.js');
module.exports = {
    name: `modmail`, 

    /**
     * @param {Client} client
     * @param {Message} message
     * @param {String[]} args
     */
    run: async(client, message, args) => {
        if(client.threads.has(`${message.author.id}`)) return message.channel.send(`You already have a ticket open!`); 
        const Channel = message.guild.channels.cache.find(ch => ch.name.toLowerCase().includes("modmail"));
        if(!Channel) return message.channel.send(`There is no mod mail channel`);
        const newChannel = await message.guild.channels.create(`modmail-${message.author.id}`, {
            type: 'text',
            parent: client.catergory,
            permissionOverwrites: [
               {
              id: message.guild.id,
                deny: ['VIEW_CHANNEL']
               },
               {
                   id: client.role,
                   allow: [`VIEW_CHANNEL`, `SEND_MESSAGES`, `ADD_REACTIONS`, `ATTACH_FILES`]
               },
               {
                   id: message.author.id,
                   allow: [`VIEW_CHANNEL`, `SEND_MESSAGES`, `ADD_REACTIONS`, `ATTACH_FILES`] 
               }
            ]
        });
        Channel.send(client.embed({
            description: `This user ${message.author.tag} (${message.author.id}) is creating a modmail thread! Created in ${newChannel}`
        }, message));
        client.threads.set(message.author.id, {
            channel: newChannel
        })
     }
}
sour flame
#

and add

solemn leaf
#
const type = types[args[0].toUpperCase()];
  if (!(args[0].isNaN() && type)) return message.reply(`${type} Isn't a valid type, or ${args[0]} isn't a number!`);

It says args[0]#isNaN() isnt a function

lament rock
#

what is client.catergory

#

string.isNaN isn't a function

sour flame
#

called Tickets

solemn leaf
#

@lament rock then how do I check if it is a number

boreal iron
#

isNaN(...)

opal plank
#

@cinder patio how you enjoying the lib so far?

cinder patio
#

It's nice, I haven't worked with it much though

#

arguments are a little confusing though

opal plank
#

parsedArgs?

cinder patio
#

the second argument from the run function

opal plank
#

heres a little trick for you

lament rock
opal plank
#
  async run(context: Command.Context, _args: ParsedArgs): Promise<any> {
    const message = context.message;
    const cc = message?.client.commandClient;
    if (!message || !cc || !message.channel) return;
#

use this and you'll have it exactly like discord.js

boreal iron
opal plank
#

actually

#

my bad

#
  async run(context: Command.Context, _args: ParsedArgs): Promise<any> {
    const message = context.message;
    const cc = message?.client.commandClient;
    if (!message || !cc || !message.channel) return;
    let args: string[] = _args[this.name].split(/ +/g);```
lament rock
#

CategoryChannel.toString(); // "<#id>"

opal plank
#

there we go

#

now its exactly like d.js

cinder patio
opal plank
#

parsed args comes with the name of the prefix that you have

boreal iron
#

huh... message?. does is check if the methods (after) are existing?

#

never saw ?.

lament rock
#

optional chaining

opal plank
lament rock
#

node 14 feature

opal plank
#

oh i guess you can use that too, but i never used it before

#

im still using the command as if it was d.js's

#

so i cant help much with that one

boreal iron
#

oh good to know

cinder patio
#

I tried using it but it didn't change the args arg at all

opal plank
#

could give it a try later, but it would probably be best to ask cake of evans directly

lament rock
#

ads! mods!1!

boreal iron
#

oh oh

#

ads

#

lol

solemn leaf
#
const type = types[args[1].toUpperCase()];

Why is this undefined if args[1] is equal to D6

[
"D6"
]
lament rock
#

Arrays are indexed by numbers

cinder patio
#

arrays start at 0

solemn leaf
#

so

#

indexof

opal plank
lament rock
#

Array<T>.indexOf(item: T): number

boreal iron
#

🤦‍♂️

solemn leaf
#

erwin I am ad

boreal iron
#

you just earned another 100 bucks I guess

lament rock
#

Posting link to Discord api server is ads /s

opal plank
lyric mountain
opal plank
boreal iron
quartz kindle
#

what is types?

solemn leaf
#

I need to use indexOf

lament rock
#

jobless reincarnation. Poggers

opal plank
#

ikr, amazing LN

solemn leaf
#

and how did kuuhaku know I was from lua

lament rock
#

true

opal plank
#

arrays at 1

#

thats a dead giveaway

lyric mountain
#

also it's a BR lang

quartz kindle
#

bronzil

lyric mountain
#

that's why its bad

solemn leaf
#

brazil

lament rock
#

Come to Brazil

opal plank
#

100% jesus country

quartz kindle
#

huehuehueland

opal plank
#

auhshushaushusauhsauhsa*land

quartz kindle
#

saokspoakspoakps-land

boreal iron
#

that escalated fast

opal plank
#

youblinkurobbed-land

quartz kindle
#

kkkkkkkkkkk-land

lyric mountain
#

r/ItHadToBeBrazil

boreal iron
#

Erwin doesn't need to steal it... he got rich cause of all the ads

cinder patio
#

Nah I don't wanna get murdered by the cartel

boreal iron
opal plank
#

my income is based off how many people i invite to the cult use detritus

boreal iron
#

lmao

lament rock
#

I'm yet to find a modular interface for voice

old cliff
#

Detritus?

opal plank
#

yeah detritus pog

lyric mountain
#

oh, wait

#

meh

#

it doesn't becomes a gif

lament rock
#

I tried to make one from djs code, but djs' internal code and code quality sucks

boreal iron
#

kadching

opal plank
#

you be casually talking in#development
and then katchau
le erwin appears with detritus ads

old cliff
nimble kiln
lament rock
#

djs is high level

opal plank
old cliff
#

Use djs... Which has normal complexity

quartz kindle
#

lmao

opal plank
#

theres plenty of reasons

lament rock
#

Why use a wrapper when you can build http requests yourself

opal plank
crimson vapor
#

@opal plank bro im pogging

old cliff
lament rock
#

tf is discord-rose

quartz kindle
#

those tests are not a good indicator btw

boreal iron
crimson vapor
quartz kindle
#

too small of a sample

crimson vapor
#

80 guilds most inactive

lyric mountain
opal plank
#

@nimble kiln @old cliff #development message you can always check this if you want to see how handy they make command handling

opal plank
#

told ya to benchmark their performance

#

you ignored it

quartz kindle
#

by performance you just mean memory usage and nothing else

#

lul

opal plank
#

anything you want to benchmark

#

i want data

nimble kiln
#

alright good, so I can stick with d.js

opal plank
#

gib data[

nimble kiln
#

I dont use command handling mmLol

#

if-else ftw.

quartz kindle
#

plus comparing different caching designs is not fair if they are not caching the same data

crimson vapor
#

I was doing all cache disabled

lament rock
#

I write my own interfaces for what I need in mem. Minimal garbage

opal plank
#

everything i write iss garabage

#

so, the more i write, the more garbage appears

crimson vapor
#

agreed

lament rock
#

I feel that

#

tfw your variables get sweeped because your code is garbage BocchiHands

opal plank
#

sometimes my bot restarts out of nowhere, and i just noticed its the Garbage Collector colleting the whole process

nimble kiln
#

When your bot detects that the bot itself is garbage 👀

lament rock
#

Do you send the process a SIGTERM or something

lyric mountain
#

sigterm is garbage

#

it gets collected too

willow river
#

is it possible to set up a webhook to send a msg on my server when someone votes for the server on top.gg? I'm not really sure how webhooks work with top.gg and i think i got told i can't use discord webhook links in the top.gg webhook area

Apologies if it has been answered earlier, i didn't see a msg so could someone ping me if they have a answer.

old cliff
#

Is that an old client?

lament rock
#

ah wait. Not SIGTERM. I forget which one forces node to take a heap dump

opal plank
crimson vapor
#

ctrl C

lament rock
#

SIGINT ftw

nimble kiln
boreal iron
#

lol

nimble kiln
#

But I'm not catching the error code so it doesnt matter

crimson vapor
#

what is error code 1?

quartz kindle
#

process.exit() :^)

gilded swallow
lyric mountain
cold lagoon
#

hi

lyric mountain
crimson vapor
#

I use 'h'.repeat(2 ** 64)

#

beat that

nimble kiln
lament rock
#

specific exit codes can allow for exit handling so that the process can clean itself up before exiting

lyric mountain
#

any status other than 0 is an error

willow river
# lyric mountain what lang?

i meant a discord webhook. which can sned a msg when soemone votes for my server on top.gg. i'm hoping to do tis without having to host something

lyric mountain
#

you can do process.exit(42069) it'll still be an error

crimson vapor
#

a nice error

lyric mountain
#

there's a bot that does that iirc tho

willow river
earnest phoenix
#

When I start my bot it says "undefined"

lyric mountain
#

does anyone remember its name?

willow river
lyric mountain
#

I don't remember its name

lyric mountain
willow river
#

is it on top.gg? i fuess if it is i can serach for it

lyric mountain
#

it is

willow river
#

this one? a few popped up

crimson vapor
#

@opal plank I request you flex your grafana

lyric mountain
#

yeah, that one iirc

earnest phoenix
lyric mountain
#

I can't read turk

#

idk what those fields are supposed to be

cobalt spruce
earnest phoenix
#

it says only "undefined"

#

in the guild delete

final lynx
#

hey, i made this all by my self because im a BIG BOY >:)), it doesnt work, the error says that it cant define 'Amount'. Does anyone know what i did wrong.

lyric mountain
#

but what is it supposed to show?

nimble kiln
lyric mountain
#

we don't speak turk

earnest phoenix
nimble kiln
#

Also translate this

crimson vapor
#

at last

final lynx
#

do you think thats the only reason?

crimson vapor
#

PascalCase is for classes

#

use camelCase

willow river
#

there's also this one, guess i'll inv both and see which i prefer

lament rock
final lynx
#

should i just do

#
  • amount
crimson vapor
#

wonderful

final lynx
#

is this what i should have

lament rock
#

Discord did a poopoo and threw a bunch of GUILD_DELETE

boreal iron
#

@final lynx Stop copying stuff. Think about what u do.

final lynx
#

i didnt copy stuff

#

i made that

#

y do u think it doesnt work

#

lol

boreal iron
#

if (!message.content.startsWith(prefix) || message.author.bot) return; is copied, once again

lament rock
#

I could write that and people could say that

boreal iron
#

shhh

#

impossible u would write that

#

I HOPE

lyric mountain
boreal iron
crimson vapor
lament rock
#

if (!message.content.startsWith(prefix) || message.author.bot) return;

final lynx
#

by to remove a message, would i put

message.channel - amount

or something else

#

(amount is the variable)

quartz kindle
#

wat

final lynx
#

im trying to delete messages

lament rock
#

TextChannel doesn't have mathematical expressions

quartz kindle
#

the fek

boreal iron
#

message.content.slice(prefix.length)

#

oh... and your actual command of course

quartz kindle
#

you want to delete a message? or remove a word from the content before you parse it?

boreal iron
#

if you wanna get args

#

nope he wanna get the arguments of the content

final lynx
#

so this?

quartz kindle
#

wat

final lynx
#

so clear messages

#

my command is

boreal iron
lyric mountain
#

tim be like

boreal iron
#

To get to know how to get the arguments your user enters

lyric mountain
#

first of all, you're not supposed to have any command inside an event

boreal iron
#

And think about it instead of just copying it

lyric mountain
#

use a command manager to prevent cluttering

boreal iron
#

don't...

lyric mountain
#

?

#

like, it's a really bad practice having all commands inside an event

boreal iron
#

meant don't waste your time

lyric mountain
#

with command managers?

boreal iron
#

we tried to explain already

lyric mountain
#

oh, that

nimble kiln
boreal iron
#

it's not like things need to be repeated over and over again (for the same person)

unreal estuary
#

im bored

boreal iron
#

I would call that bad practise, too

nimble kiln
#

yeah

lyric mountain
#

yet we can't say it's right

boreal iron
#

haha lmao

nimble kiln
#

it's absolutely right

#

If that cow wants to walk like that, let it do that

unreal estuary
#

i wanna make a discord bot but dont know what kind

#

any ideas

lyric mountain
#

I think you're crazy

nimble kiln
#

a bit maybe, yes

unreal estuary
#

i also think im crazy

final lynx
nimble kiln
#

I dont see any performance degradation when I do what I do

final lynx
#

so this is what i should have

boreal iron
#

well better crazy than boring

nimble kiln
#

So I dont have the need to rewrite it

final lynx
#

this is the entire thing

lyric mountain
#

also overhead

earnest phoenix
#

can somebody help me editing my desc

quartz kindle
unreal estuary
#

whats

#

the amount

#

const

nimble kiln
#

By now I know my 4000 line long index.js file very well

quartz kindle
#

you cant do mathematical operations on text

nimble kiln
#

I can maintan it pretty good

earnest phoenix
#

@earnest phoenix

final lynx
lyric mountain
#

@unreal estuary do you have programming experience?

quartz kindle
#

you need to process the text using textual tools

#

such as .slice()

#

to extract parts of the text

unreal estuary
#

what is it supposed to be

quartz kindle
#

or split() to divide it into pieces

lyric mountain
earnest phoenix
#

or splice to remove

boreal iron
#

or length() to get the length.. woop woop

final lynx
#

so this

unreal estuary
#

message.content - (prefix + "RemovedMessages" + " ")

quartz kindle
#

no

earnest phoenix
#

lol

lyric mountain
unreal estuary
#

that doesnt make sense @lyric mountain

quartz kindle
#

google "javascript strings slice"

#

and learn how the function works

unreal estuary
quartz kindle
#

the code wont magically understand what you want

#

you need to be extremely explicit with it

lyric mountain
#

trying to get the amount arg

final lynx
lyric mountain
#

like !!prune 10

#

he wants that 10

unreal estuary
#

ah

lyric mountain
#

let him think

unreal estuary
#

well u could split the message content by spaces?

boreal iron
#
if(command == "ban") banTheFuckingUserIGotInMyMind();```
_that's not how coding works_
final lynx
#

it does something now

final lynx
#

im going to change "all" to the amount

#

after i make the cmd work

crimson vapor
#

pog

opal plank
boreal iron
#

@opal plank Can I opt-out from the command tracker? pandasad

final lynx
#

im having a lot of trouble defining "amount"

wide ridge
#

Hey @twilit rapids, sorry for the ping. I wanted to ask you about 16x sharding on d.js w/ kurasuta. Can we take it to dms?

unreal estuary
final lynx
#

i want my amount to be the number after the command, so if i put ()RemoveMessage 3

#

i want amount to be 3

unreal estuary
#

ok

boreal iron
unreal estuary
#

maybe start with something simpler than a discord bot?

final lynx
#

i have

unreal estuary
#

like what?

final lynx
#

i can use Lua very well

crimson vapor
unreal estuary
#

javascript??

opal plank
#

once i finish work i wanna work on the bot for a bit

crimson vapor
#

ok pog

#

hello Kyoso

final lynx
twilit rapids
exotic galleon
#

I need codes to make a long explanation in top.gg. Do you have them?

twilit rapids
#

Not at home rn

quartz kindle
#

did you read the docs about string.slice()?

quartz kindle
#

and?

unreal estuary
lusty quest
#

need to fix my logging for MongoDB inside of Grafana. fucked there something up

boreal iron
exotic galleon
#

does anyone have top.gg long description

final lynx
unreal estuary
#

i want to help but i dont want to spoon feed you the answers lol

lusty quest
lyric mountain
#

if you're used to lua you could just make a bot in lua

unreal estuary
#

did u learn what .slice does?

crimson vapor
#

what do you guys have your ws ping stable at?

final lynx
unreal estuary
#

like tim said

lyric mountain
quartz kindle
#

yes

final lynx
#

nani

unreal estuary
#

ok look it up first

lyric mountain
quartz kindle
#

you can make bots in all languages

crimson vapor
#

huh

final lynx
#

one sec

#

time to lua

#

or maybe not

unreal estuary
#

you decide

lusty quest
final lynx
#

dont judge but i use Lua for roblox studios

crimson vapor
#

ok

lyric mountain
crimson vapor
#

18 gang

nimble kiln
#

OVH France

pale vessel
#

oh no! OVH

crimson vapor
#

you mean NaN?

pale vessel
#

Infinityms

lusty quest
#

you survived the fire?

nimble kiln
#

(Not Straßbourg Kapp )

twilit rapids
#

20-25ms / TS Pittsburgh

boreal iron
#

probably 9999999999ms on the next fire

unreal estuary
#

lua looks like javascript

crimson vapor
#

ok pog

#

im lowest

nimble kiln
#

Gravelines france

crimson vapor
#

pogging

unreal estuary
#

abit

lyric mountain
wide ridge
crimson vapor
#

thats what I thought for a sec

lusty quest
#

well i dont think there are API servers in europe atleast none you can ping directly

unreal estuary
#

is this lua lol

crimson vapor
#

yea

cinder patio
#

I'm also on the Lua train but for TBOI

lyric mountain
#

yes

#

100% lua

unreal estuary
#

it looks like discord.js

crimson vapor
#

its not

nimble kiln
#

Binding of Isaac mods? POGGERS

unreal estuary
#

just saying

crimson vapor
#

look at the source

#

LOL

#

rest part

#

its pain

unreal estuary
#

ok

lyric mountain
lyric mountain
#

the syntax is totally off

crimson vapor
#

way off

boreal iron
lyric mountain
#

also, what's the reason for ß to even exist?

opal plank
#

im confused as to what you're asking tbh

lyric mountain
#

isn't it always ss?

boreal iron
#

OH GOD... USER

opal plank
#

yes, im tracking which user uses which command, where and when

#

since its for logging and debugging purposes, not really

pale vessel
#

moon not here

crimson vapor
#

why does it matter?

unreal estuary
#

woah it rlly is

young flame
#

its s f w

crimson vapor
opal plank
#

@boreal iron why do you ask?

young flame
#

UH

#

OOPS

rustic nova
crimson vapor
#

LOL

young flame
#

you see nothing

rustic nova
#

mooni

lavish grove
#

Hi. I'm complaining about the MC-AT Discord Bot. Yes it's a very nice bot but for some reason my server is afk and therefore I can't run commands so I'm complaining.

rustic nova
#

stink

boreal iron
#

nah just wanted to ask if a client USER can opt-out

young flame
rustic nova
#

-wrongserver

gilded plankBOT
#

Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Get Support" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Support Server, then we can't help you. Sorry :(

opal plank
#

since its used internally, not really, the data consist by majority of discord data, not end user

young flame
rustic nova
#

Mooni bonk

opal plank
#

of course, you arent allowed to share it, hence why every time i send a screenshot i blur the id's

boreal iron
#

wasn't sure if that panel is internal use only

opal plank
#

its internal, yes

#

you can check every screenshot i sent, the ids are always blurred

boreal iron
#

I'm not confused about data sharing, just wanted to know (for statistics)

unreal estuary
#

can u make ur own license for your projects?

lyric mountain
#

yes

unreal estuary
#

ok cool

lyric mountain
#

well, actually

#

YOU can't make it

#

a lawyer can

unreal estuary
#

im not a lawyer im crazy

lyric mountain
#

unless you're fine with loopholes

opal plank
unreal estuary
boreal iron
#

hmm and I see you store all that data... I mean why not :D

opal plank
#

its usud mainly for debugging and improvement of the bot

unreal estuary
#

ok thanks

opal plank
#

with that i can see what were the last few commands used before the bot was kicked from a server, that gives me a hint of what commands are not meeting user satisfaction levels

lyric mountain
#

pick an existing license to see how it works

modest maple
#

rabbitMQ queues sad

lyric mountain
#

like apache or lgpl

#

mit is smaller

boreal iron
#

yeah, not a bad idea... my scope is a few guilds only
it's actually not a bad idea tho

final lynx
#

so, i think i found out my problem for all my commands

opal plank
unreal estuary
#

ok

nimble kiln
#

Better clean your phone

opal plank
final lynx
#

all of my commands are on "index.js"

#

should i add new files for every command

lyric mountain
#

yes

final lynx
#

ok

opal plank
#

top level dashboard, custom presence, insane logging

unreal estuary
#

you dont have to

opal plank
#

whatever i do, i put 110% commitment

unreal estuary
#

but its more organised

lyric mountain
#

as everyone pointed before

final lynx
#

i think it would be easier

final lynx
opal plank
#

but thats just me bragging

cunning gorge
#
else if (r.emoji.name === '📃') {

How do you aadd custom emojis for reactions?

unreal estuary
#

i put all my commands in one file for smaller discord bots

boreal iron
opal plank
#

indeed

#

its been paying off tho

cunning gorge
#

oh thanks

opal plank
#

4k servers soon

final lynx
lyric mountain
#

or <a:name:id> for animated

final lynx
#

i think this is where i would make the new scripts

opal plank
#

growing at a rate of 550 servers per week now

final lynx
#

how would i add them

unreal estuary
#

you dont do it from package.json

final lynx
#

what do i do it from

#

index.js?

unreal estuary
#

index.js

final lynx
#

ok

unreal estuary
#

yes

#

but maybe try

#

fix ur commands first

#

the delete messages one

final lynx
#

they work

#

ya

unreal estuary
#

thats good

modest maple
#

\o/ hazzar it works though

final lynx
#

but to do it

#

in index.js

#

i would put

#

else if (command === 'nil') {

boreal iron
#

doesn't sound bad even if I'm not aiming for popular bots... imma just coding for requests for stuff which doesn't exist yet

final lynx
#

and replace "nil"

#

with the name of a command

#

then make a new file inside a folder named "commands"

#

and add a file into that

boreal iron
#

just spoken about discord bots, of course

final lynx
#

with the name of the command

unreal estuary
#

how would you make the code do that?

final lynx
#

?

unreal estuary
#

the code doesnt just magically do things lol

#

you need to code it to do it

modest maple
unreal estuary
#

like how would you make it do a function from the command file

final lynx
#

i know

modest maple
#

perfect load balancing between clusters not just per shard happyKorone

opal plank
final lynx
#

but

#

inside of index.js

#

i would make commands called

#

else if (command === 'name) {

#

and inside a folder named

#

command

#

i would add a file called the name of the cmd

#

and then put the code inside of that

#

is that what im suppost to do?

unreal estuary
#

no

final lynx
#

supost*

unreal estuary
#

that wouldnt do anything

#

ur not making the command do anything by just creating a file

final lynx
#

if i do that

#

would i have to change anything inside of packson

unreal estuary
#

package.json?

#

nope

final lynx
#

ok

#

ill figure out how to do it

#

and be back in a sec

unreal estuary
#

you could use fs

opal plank
#

@modest maple

unreal estuary
#

@final lynx

modest maple
#

mine wont actually load sad

opal plank
#

yeah

#

let me enable the thing rq

modest maple
#

I might not have enabled it

#

getting connection reset

opal plank
#

that and redis are heling a lot with handling this much traffic

#

@modest maple

#

keep a copy stashed on rqm for one of my bots to parse chat moderation

modest maple
#

are you running rabbit on docker?

opal plank
#

to make sure it doesnt clog the main process

#

i dont know tbh

modest maple
#

oof

cinder patio
#

Me, who'll likely never get to use them practically:

opal plank
#

:p

modest maple
boreal iron
#

Oh no you revealed your IP address

nimble kiln
boreal iron
nimble kiln
#

Already hacking into his mainframe

twilit rapids
#

Oh you do

quartz kindle
#

i believe over 200k already

#

xD

twilit rapids
#

236k

#

@wide ridge can you DM me? I'll respond in a bit, almost home

wide ridge
crimson vapor
crimson vapor
#

wdym?

#

like not much change?

lusty quest
crimson vapor
#

influx

lusty quest
#

nice, tried to use it but the docs are "special"

crimson vapor
#

honestly im just fucking around trying to get it to work

lusty quest
#

i might look into it, tomorrow

crimson vapor
#

its cool

#

confusing for me

#

but cool

lusty quest
#

but for now, ive got a Dashboard for my Server, MongoDB and Redis

crimson vapor
#

pog

lusty quest
#

also got alerts for my server if the Ram or CPU usage is to high, if this happens i get a Alert send via Webhook into my Support Discord Server

crimson vapor
#

LOL

craggy pine
#

Imagine if Icarus had a webhook for that before you Kuu KEKW

lyric mountain
#

lul

lusty quest
#

works fine

#

you can also send a screenshot of the graph with it

lyric mountain
#

high value: 100.000000
higher value: 100.000001

lusty quest
#

its a test alert

#

just for testing the webhook

lyric mountain
#

ik

earnest phoenix
#

if(!message.guild.me.hasPermission("SEND_MESSAGES", "EMBED_LINKS")) return; my code is but not working is there a mistake?

pale vessel
#

try making it an array

#

["SEND_MESSAGES", "EMBED_LINKS"]

earnest phoenix
#

i will try

#

no not working

#

that's just a normal discord api error

pale vessel
#

check for channel overwrites too

boreal iron
#

Isn’t it ...permissions.has() right now?

#

I think so

long crow
#

What version?

#

If it master branch, hasPermission is depcreatied

livid lichen
#

Hi! Okay so you know how npm packages have this in them?

/**
 * Title
 * * lol
 * @type {Object}
 * @see {@link https://randomsite.co,}
 */
``` I don't now what they're called and I was wondering if you guys knew.
robust blade
#

I got this damn error saying UnhandledPromiseRejectionWarning: AbortError: The user aborted a request

robust blade
#

What does that mean?

long crow
#

Client taking too long to send a request to discord api

livid lichen
#

I don't know. I'm quite curious so imma google-

#

Okay nvm lol

robust blade
crimson vapor
#

nope

#

grafana

long crow
#

No, Im writing to you

livid lichen
earnest phoenix
#
mgs = (await message.channel.messages.fetch({limit:100})).array().filter(m => (!m.pinned) && (m.createdTimestamp < message.createdTimestamp) && (m.createdTimestamp > (message.createdTimestamp - 1209600000)) && (!m.deleted))``` what did i do wrong?
unreal estuary
#
var db = new sqlite3.Database(':memory:');```
#

can anyone explain wat the memory database is

pale vessel
#

it is

unreal estuary
#

what is it

#

lol

pale vessel
#

grafana

unreal estuary
#

ah

earnest phoenix
unreal estuary
#

dont think so

solemn leaf
#

How can I get the total space of the os in js

#

os.totalmem doesnt seem to be accurate

boreal iron
#

The space of the OS or the drive?
totalmem sounds like memory

solemn leaf
#

yeah it is but that would make it even more inaccurate

boreal iron
#

I asked you what are you looking for?
The DISK/DRIVE size or memory usage?

solemn leaf
#

all of the above

boreal iron
#

The inbuilt process infos of node can show you at least the memory usage

#

if you’re using node

heavy marsh
#

in d.js i am trying to get the badges can someone help

      let IncludeBadges = {
        "DISCORD_EMPLOYEE": "emoji 1",
        "PARTNERED_SERVER_OWNER": "emoji 2",
        "HYPESQUAD_EVENTS": "emoji 3",
        "BUGHUNTER_LEVEL_1": "emoji 4",
        "HOUSE_BRAVERY": "emoji 5",
        "HOUSE_BRILLIANCE": "emoji 6",
        "HOUSE_BALANCE": "emoji 7",
        "EARLY_SUPPORTER": "emoji 8",
        "BUGHUNTER_LEVEL_2": "emoji 9",
        "VERIFIED_BOT": "emoji 10",
        "EARLY_VERIFIED_BOT_DEVELOPER": "emoji 11"
      };

    let DisplayBadges;    
    for (var key in IncludeBadges) {
        if (member.user.flags.has(key)) {
            console.log(IncludeBadges[key]);
        }
    } 

I get an error ```js
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.

boreal iron
#

Not sure about the disk size tho but I’m sure there’s a lib for it

solemn leaf
#

@boreal iron that is what os is for im pretty sure getting ussage is process

boreal iron
#

process.memoryUsage()

solemn leaf
#

I kinda wanna get all the true stats of the host Im using

boreal iron
#

You’re not speaking about the node process but all processes and usages on the system?

solemn leaf
#

yeah

#

isnt that where you use os

boreal iron
#

Alright that’s a different story

tulip ledge
#

In a website, using JS is there a way to detect if a user scrolls to the bottom of the page? Meaning they hit the end of the page?

solemn leaf
#

yeah

boreal iron
#

Take a look and search for npm packages with key words, I’m sure there’s one if you think the node process infos are inaccurate

solemn leaf
#

I mean the host says I have 500mb

#

for both

boreal iron
#

You need to calculate the height and offset to check if he has scrolled to the bottom

craggy elk
#

help how to use node.js