#development

1 messages · Page 1524 of 1

slim void
#

Alright, thanks for the feedback. Does the API go by overall bot limiting, or user limiting, as in would I have to rate limit each user or is it best to globally rate limit the entire server for a backup bot.

earnest phoenix
#

WHAT ABOUT ME GOD DAMIT

slim void
eternal osprey
#

hey guys

earnest phoenix
#

Hey KEKW

solemn latch
#

replace it

#

sure whatever

quartz kindle
earnest phoenix
#

Yea same lol

eternal osprey
#

how do i make sure that only 1 user can use the command, and then the function stops?

slim void
#

Okay Tim, personally, is it proper to rate limit the guild for a backup bot or a user, to avoid being limited?

quartz kindle
#

so for example if you do any kind of request that affects a specific channel, it will count towards that specific channel's rate limits, and not others, even within the same guild

eternal osprey
slim void
#

hmm

earnest phoenix
#

Can you show the code you’re trying to do it with?

slim void
#
   if (talkedRecently.has(message.author.id)) {
            message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
            return;
    } else {

           // the user can type the command ... your command code goes here :)

        // Adds the user to the set so that they can't talk for a minute
        talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after a minute
          talkedRecently.delete(message.author.id);
        }, 60000);
    }```
quartz kindle
slim void
#

so for this it's limiting the users

earnest phoenix
#

@eternal osprey

slim void
#

how does one limit a guild

quartz kindle
slim void
#

ah

#

omg

#

it's just like python

#

exactly the same

earnest phoenix
#

Lol

quartz kindle
#

yes, the dot notation is the same

slim void
#

only difference is the js part.

#

😄

#

sry, me spazzing xd

earnest phoenix
#

@eternal osprey show me the code you’re trying to do it with

quartz kindle
#

only difference is brackets and no indentation

#

lmao

#

and some functions are simpler

earnest phoenix
eternal osprey
#

there is a function called despawnpokemon

earnest phoenix
#

Mhm

eternal osprey
#

i want to use that function as soon as one user uses the !catch command

quartz kindle
#

the thing you have in line 19 does something different from that, its not a replacement, but you can have both if you want

earnest phoenix
#

Alr, show it

quartz kindle
#

in line 11

#

lol

earnest phoenix
#

LOL

eternal osprey
#
function attemptCatch(message, mon){
    if (message.channel.id === spawnChannel || !requireCatchingInSpawnChannel){
        if (mon){
            if (!trainers[message.author.id]) {
                var obj = {
                  name: message.author.username,
                  mons: [],
                  currentBalls: pConfig.numberOfAttempts,
                  spawnIds: [],
                  catching: false
                };
                trainers[message.author.id] = obj;
            }
            if (!trainers[message.author.id].spawnIds.includes(mon.spawnId)){
                if (trainers[message.author.id].currentBalls > 0){
                    if (pConfig.animatedCatch){
                        
                        if (!trainers[message.author.id].catching){
                            message.channel.send(".").then(function(sent) {
                                setTimeout(function() {
                                    updateAnimation(sent.id, pConfig.animationAmountShakes-1, message, mon);
                                }, pConfig.animationShakeTime);
                            });
                            trainers[message.author.id].catching = true;
                        }
                    }else{
                        testCatch(mon, message);
                    }
                }else{
                    message.reply(`you don't have any Pokéballs left. Try again later!`);
                }
            }else{
                message.reply("you've already caught this Pokémon! What are you doing?")
            }
        }else message.reply("there is no Pokémon to catch right now. Please wait a while.")
    }else message.reply("you can only catch Pokémon in the channel they spawn in.")
}
slim void
#

Tim

earnest phoenix
#

Alrighty

quartz kindle
#

if else hell

#

lmao

earnest phoenix
#

1 second lemme find he document

#

@eternal osprey

slim void
#

can u join my server to tell me if the bot is doing it to quickly?

eternal osprey
earnest phoenix
#

Mhm, like the role code

eternal osprey
#

oowh the docs yeah okay

earnest phoenix
#

Lol

#

client.dispatcher.addInhibitor(msg => {
if (msg.member.id != "ID") return false;
else
{
return(msg.reply("You can't use me"))
}
}); @eternal osprey

quartz kindle
eternal osprey
slim void
#

Tim

#

it's a backup

#

it will take 5 seconds to show u

earnest phoenix
#

You said only one person is allowed to use it

eternal osprey
#

i want to use stop the function as soon as someone uses the !catch command

eternal osprey
slim void
#
   if (talkedRecently.has(message.guild.id)) {
            message.channel.send("Wait 1 minute before getting typing this again. - " + message.author);
            return;
    } else {

           // the user can type the command ... your command code goes here :)

        // Adds the user to the set so that they can't talk for a minute
        talkedRecently.add(message.guild.id);
        setTimeout(() => {
          // Removes the user from the set after a minute
          talkedRecently.delete(message.guild.id);
        }, 60000);
    }```
#

btw

earnest phoenix
#

Ohhhhh

#

Lemme see

slim void
#

how would I inform the user "how much longer they have"?

eternal osprey
#

the first one that uses and catches it, wins and no-one can get it

earnest phoenix
#

Alr, 1 sec

eternal osprey
slim void
#

Tim*

quartz kindle
slim void
#

oh

#

do you think it's fine?

#

without telling them

#

also Tim

quartz kindle
#

a little less nice but its fine

slim void
#

the bot creates over 15 channels, 20 roles, and sets permissions and messages

#

all in 5 seconds

quartz kindle
#

sequentially or concurrently?

slim void
#

all at once

eternal osprey
quartz kindle
#

that doesnt answer the question

slim void
#

hmm

quartz kindle
#

show code

slim void
#

it's fast tho

earnest phoenix
#
  if (msg.member.id != "ID") return false;
  else
  {
   return(msg.reply("You can't use me"))
  }
}); 
if (message.guild.id !== 'TheIdOfYourGuild') return message.reply('This command can only be used in another server.');``` @eternal osprey try it
#

It’s kind of hard making those kind of commands

#

But it’s never impossible

slim void
#

it does it congruently

#

but if I had a 2min cooldown

#

it'd fine right?

earnest phoenix
#

Wait 1 second again

quartz kindle
#

the problem is not the cooldown, idk how happy discord will be to be spammed with a lot of requests in a very short time

#

so its good practice to spread them out

#

or at least do it sequentially

eternal osprey
earnest phoenix
#

This would only allow it to be used in your server

#

And if you want it to be used 1 time onoy

#

Only*

#

I suggest this

eternal osprey
earnest phoenix
#

Yes, but wait 1 sec

eternal osprey
#

to restrict it to the one that used the command first

earnest phoenix
#

Well, I don’t think it’s possible but hmm

#

let cooldown = 43200000;

#

You can add cool down

#

And then disable the command

slim void
#

If your bot got rate limited will my entire discord acc get banned or no

earnest phoenix
#

@eternal osprey

solemn latch
#

you dont even get banned

#

nor your bot

slim void
#

oh

eternal osprey
#

hey i am here

slim void
#

even if it spams it?

solemn latch
#

you just get ratelimited

eternal osprey
#

why would i want a cooldown?

solemn latch
#

if you api abuse, you potentially get banned.

slim void
#

If your bot isn't doing it on purpose will u get banned?

eternal osprey
#

I want to just restrict the command to the guy that used the !catch command first

slim void
#

and people abuse it

earnest phoenix
#

Nonono, it won’t work...

#

Hm...

eternal osprey
#

maybe Woo can help out?

solemn latch
#

bots get ratelimited all the time, the vast majority of bots dont have perfect cooldown systems and users will intentionally get it ratelimited.

slim void
#

rip

earnest phoenix
slim void
#

someone did it to my bot lol

earnest phoenix
#

@solemn latch would you mind helping @eternal osprey

slim void
#

I wish bots could have inf limits 😭

#

would be so fast and nice

solemn latch
#

then discord wouldnt work

#

and it would be shutdown

slim void
#

true

#

but i'm saying overall?

#

Like I wish it could handle it.

solemn latch
#

no one can handle that load

#

its impossible

slim void
#

ik it can't

#

but i'm telling you..

#

I wish it could..

#

it's a fantasy lol

eternal osprey
#

hey Woo

#

do you know how to restrict the functions to others when someone is first with the command?

slim void
#
embed=discord.Embed()
embed.add_field(name="undefined", value="undefined", inline=False)
await ctx.send(embed=embed)```
#

is this js?

#

does js work like this for embed

slim void
#

😭

#

how does js do embeds?

eternal osprey
slim void
#
const embed = new Discord.MessageEmbed() // Ver 12.2.0 of Discord.js
.setTitle("This is a title")
.setDescription("This is a description")
.setTimestamp()
.setFooter("This is a footer")
.setAuthor("This is the author's name", //and this its profile pic)
.addField("This is a field", "this is its description")
.setImage("https://images-ext-2.discordapp.net/external/cC-YBJkH2GXnX7MHMASUM9Gle1S1im3rDJj2K54A28w/%3Fcid%3D73b8f7b19a5ccc575679c0a7fc4a673b753e4ce993f35223%26rid%3Dgiphy.mp4/https/media2.giphy.com/media/Q8bEDnj9hZd6vivXSZ/giphy.mp4")
.setThumbnail("https://images-ext-2.discordapp.net/external/cC-YBJkH2GXnX7MHMASUM9Gle1S1im3rDJj2K54A28w/%3Fcid%3D73b8f7b19a5ccc575679c0a7fc4a673b753e4ce993f35223%26rid%3Dgiphy.mp4/https/media2.giphy.com/media/Q8bEDnj9hZd6vivXSZ/giphy.mp4")
<message>.<channel>.send(embed) // Remove the brackets <>```
solemn latch
slim void
#

oh like this

#

that's interesting lol

eternal osprey
#

the one that is first, so global.

#

after that the pokemon despawns

earnest phoenix
#

Why is this not working... not outputting any errors either

solemn latch
#

i think this might be an xy problem? @eternal osprey. what are you trying to do?

quartz kindle
eternal osprey
earnest phoenix
#

Oh, yea

#

it should be

eternal osprey
#

so only 1 member, the one that was the fastest, will be able to use the function @solemn latch

earnest phoenix
#

message.reply(banembed) @quartz kindle true?

quartz kindle
#

yes

solemn latch
#

have you heard of the x y problem?

eternal osprey
earnest phoenix
#

Still not working @quartz kindle

eternal osprey
#

so basically, that i ask a question about something while the real problem is something else?

solemn latch
#

yeah

eternal osprey
#

well no?

solemn latch
#

so i think thats the wrong solution

eternal osprey
#

I think my question is just... a question.

solemn latch
#

the xy problem is a question

eternal osprey
#

my question was how do i restrict a function to only 1 user, the one that is the fasted with the !catch command.

#

that is not xy.

solemn latch
#

so, why do you want to restrict the function?

eternal osprey
solemn latch
#

thats not the way i would handle a catch command

#

right so describe that part

eternal osprey
#

a pokemon spawns

#

you can use !catch to catch it.

earnest phoenix
#

Help me please..

eternal osprey
#

i don't want everyone to walk around with duplicates.

earnest phoenix
#

Why is this not working it’s not showing errors neither

eternal osprey
#

i just want the fastest guy to use the command, to catch the pokemon only.

cinder iron
#

how do you add moderation to your code

#

all

#

I have is Hello

#

and this isn't enough

dusky sundial
#

This channel isn't really for asking how to create entire commands

solemn latch
# eternal osprey do you understand me?

right, so when a pokemon spawns it should save that in a variable(or a map, or whatever method of storing you want to use) saying this is the currently spawned pokemon.
when the catch command is used it should check if there is a pokemon in that variable, and delete that variable if its correct.

#

you are not disabling any functions this way, just doing a basic if statement.

earnest phoenix
eternal osprey
solemn latch
#

ive never actually made this, personally i would just make a class called pokemon, and store it in a map with the channel id as the key. then just use delete to delete it.

earnest phoenix
#

Guys what about me?

solemn latch
#

whats the question

eternal osprey
#
function attemptCatch(message, mon){
    if (message.channel.id === spawnChannel || !requireCatchingInSpawnChannel){
        if (mon){
            if (!trainers[message.author.id]) {
                var obj = {
                  name: message.author.username,
                  mons: [],
                  currentBalls: pConfig.numberOfAttempts,
                  spawnIds: [],
                  catching: false
                };
                trainers[message.author.id] = obj;
            }
            if (!trainers[message.author.id].spawnIds.includes(mon.spawnId)){
                if (trainers[message.author.id].currentBalls > 0){
                    if (pConfig.animatedCatch){
                        
                        if (!trainers[message.author.id].catching){
                            message.channel.send(".").then(function(sent) {
                                setTimeout(function() {
                                    updateAnimation(sent.id, pConfig.animationAmountShakes-1, message, mon);
                                }, pConfig.animationShakeTime);
                            });
                            trainers[message.author.id].catching = true;
                        }
                    }else{
                        testCatch(mon, message);
                    }
                }else{
                    message.reply(`you don't have any Pokéballs left. Try again later!`);
                }
            }else{
                message.reply("you've already caught this Pokémon! What are you doing?")
            }
        }else message.reply("there is no Pokémon to catch right now. Please wait a while.")
    }else message.reply("you can only catch Pokémon in the channel they spawn in.")
}```this is the whole attemptcatch
solemn latch
#

mon being the pokemon?

earnest phoenix
cinder iron
#

ok

pliant obsidian
#

does anyone who understand css can help me?

cinder iron
#

walk me through

#

please

rustic nova
eternal osprey
#

and just mon, the pokemon.

cinder iron
#

ok

earnest phoenix
#

Alr, open discord.Js

pliant obsidian
summer torrent
#

img tag

rustic nova
#

you can do that with markdown too, would be easier than using html

eternal osprey
#

like is there no way to check whether a command was executed

rustic nova
#

img tag works too yeah

solemn latch
#

i wouldnt do it that way awsome

cinder iron
#

i opened it up

eternal osprey
cinder iron
#

this??

solemn latch
# eternal osprey Okay.

I feel like my explanation was good pandasad im not sure if i can explain it better without spoonfeeding code

pliant obsidian
#

and how exactly do I use img tag (I know 0 about css)

eternal osprey
#

i only can't really visualise anything.

#

so is there any examples you can provide

rustic nova
earnest phoenix
solemn latch
cinder iron
#

what???

eternal osprey
#

how do i check if its caught.

earnest phoenix
cinder iron
#

yes

#

it says

#

discord.js

earnest phoenix
#

Ok now um click on documents

cinder iron
#

u mean

#

documentation

earnest phoenix
#

Ye

solemn latch
cinder iron
#

ok

cinder iron
#

can u screensho tit

eternal osprey
#
unction testCatch(mon, message){
    const randGen = Math.random();
    if (randGen < mon.catchChance){
        
        console.log(`${message.author.username} caught ${mon.name}`);

        var mid = Math.floor(Math.random() * Math.floor(9999999-999999)) + 999999;
        while (mons[mid]){
            mid = Math.floor(Math.random() * Math.floor(9999999-999999)) + 999999;
        }
cinder iron
#

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});

client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('pong');
}
});

client.login('token');

eternal osprey
#

i have a despawn function

cinder iron
#

it says this

eternal osprey
#

can't i use .then(....)

#

after the console.log.

solemn latch
#

i dont think you can .then since theres no promise.

#

you can only .then promises

eternal osprey
umbral zealot
#

.then is used to resolve promises, it has no place being used on a console.log

eternal osprey
#

but just to call the function despawnMon

#
function testCatch(mon, message){
    const randGen = Math.random();
    if (randGen < mon.catchChance){
        
        console.log(`${message.author.username} caught ${mon.name}`);

        var mid = Math.floor(Math.random() * Math.floor(9999999-999999)) + 999999;
        while (mons[mid]){
            mid = Math.floor(Math.random() * Math.floor(9999999-999999)) + 999999;
        }
        despawnMon();```
quartz kindle
#

unction

eternal osprey
#

accidentally copied it wrong

umbral zealot
#

all this code is sync so there should be no issue

#

Race conditions would only happen on async code (promises, callbacks, event handlers, etc)

eternal osprey
#

it worked guys. After catching, calling the despawnMon.

umbral zealot
#

I'm relatively certain that if you receives 2 messages and parse them, they will not be parsed "simultaneously" so that shouldn't be a problem

cinder iron
#

so

#

all of u guys use js

#

ok

solemn latch
#

not everyone here

#

just happens to be a lot of js guys on right now.

eternal osprey
#

thanks @solemn latch for supporting and helping me!

#

I wasn't thinking clear for a sec.

solemn latch
#

always the worst when that happens

#

good luck with your pokemon bot

earnest phoenix
eternal osprey
earnest phoenix
eternal osprey
earnest phoenix
#

Congrats

#

why is this not working nor outputting any errors :/

rustic nova
#

add debug lines

earnest phoenix
#

Wdym?

#

console.log?

umbral zealot
earnest phoenix
#

Nice

earnest phoenix
# earnest phoenix

help? I’ve tried everything console.log everything that could show an error but no someone help

quartz kindle
craggy pine
earnest phoenix
#

I’ve tried it :/

craggy pine
#

clearly not or you would know.

#

console.log("1");
console.log("2");

#

ect

#

so u know which "#" it stops

quartz kindle
#

that code still has an empty message.reply()

earnest phoenix
#

Yes, I fixed it..

craggy pine
#

ah yeah that's true.

earnest phoenix
#

Oh my bad

craggy pine
#

message.reply("NEED STUFF HERE")

quartz kindle
#

thats like you telling an auto mechanic that your car is broken, then showing them a picture of the car when it was new

earnest phoenix
#

I just forget taking new picture

cinder iron
#

hello

green kestrel
cinder iron
#

but now what

#

how do you make the kick/ban, warn/mute and says Welcome to our server and a !help thing

craggy pine
green kestrel
#

82 concurrent is a record

#

i recently changed it to running all games in a cluster under one thread, rather than one thread per game

#

wasnt sure if it would scale, but i guess this proves it can

craggy pine
cinder iron
#

i know

#

but

#

does c++ work

craggy pine
#

look up c++ discord library mexShrug

quartz kindle
#

ask brain

#

his bot runs on c++

cinder iron
#

ok

green kestrel
#

lmao.... do you like pain

cinder iron
#

@green kestrel help please.

quartz kindle
#

good luck brain

#

you'll need it

green kestrel
#

what programming languages do you know

quartz kindle
#

:^)

craggy pine
cinder iron
quartz kindle
#

how proficient are you with c++?

green kestrel
#

how well do you know C++, and do you know modern C++ e.g. C++17 or just the "C with objects" taught in schools

cinder iron
#

the modern stuff

green kestrel
#

if youre on windows, get this template project:

quartz kindle
#

why are discord devs all weebs

mellow kelp
#

why not

craggy pine
green kestrel
quartz kindle
#

im not saying im not

#

but still asking

#

:^)

mellow kelp
#

this is beautiful

green kestrel
#

@quartz kindle im not a weeb. but i dont dare change the projects icon, i think i have access to

quartz kindle
#

owoegis

green kestrel
#

a-pee-gis

cinder iron
#

yes

#

im on windows

quartz kindle
#

a-pee-nis

green kestrel
#

ok, start with the template project for visual studio

#

youll need full visual studio not vs.code

cinder iron
#

ok so?

green kestrel
#

which im sure you have already?

#

load up the template project, it has a simple 'hello world' type bot in it, that you can start from

slim void
#
.addField('Information','Make sure you copy this ID as there is no other way we can recover it!', inline: false)```
#

Did I do this wrong Brain?

green kestrel
#

with all the libraries and dependencies set up for you

#

its about as easy as starting with discord.js to get that working

pliant obsidian
#

@solemn latch thanks bro I could do what I want 👌

green kestrel
#

but as for writing a bot in C++, like i said, i really hope you enjoy pain. and debugging. and crashes.

slim void
#

ok

quartz kindle
green kestrel
#

my last major bug, i spent 2.5 hours in gdb looking at raw memory dumps

#

trying to identify what other part of the code had written over an object

slim void
#

look

green kestrel
#

what comes before the .addField?

slim void
#
/home/container/commands/create-backup.js:18
.addField('Information','Make sure you copy this ID as there is no other way we can recover it!', inline: false)
^^^^^^
SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)```
green kestrel
#

did you just put that on its own?

quartz kindle
#

btw brain, what are these called in c++? something["key"] = value

slim void
#
    backup.create(message.guild).then((backupData) => {
        const embed2 = new Discord.MessageEmbed()
          .setColor('#03fccf')
          .setDescription('**Backup ID**: `'+backupData.id+'`')
          .addField('Information','Make sure you copy this ID as there is no other way we can recover it!', inline: false)
        return message.channel.send(embed1);```
#

I did this

#

ignore the indents, discord breaks them.

quartz kindle
#

objects? arrays?

#

lists?

craggy pine
#

@slim void embed 1 and embed 2

slim void
#

oh

earnest phoenix
#

Embed 1 embed2

slim void
#

😭

craggy pine
#

typos are the best.

slim void
#
👌 Event loaded: message
👌 Event loaded: ready
/home/container/commands/create-backup.js:18
.addField('Information','Make sure you copy this ID as there is no other way we can recover it!', inline: false)
^^^^^^
SyntaxError: missing ) after argument list```
#

no still broken

#

hmmm

#

missing )?

#

uh

green kestrel
#

depends! @quartz kindle
if youre only using standard library, its either a std::map or std::unordered_map.... both have the same syntax, and work like a dictionary/js array. BUT, std::map uses an RB-tree for storage, so is O(log n) speed for an element lookuop, and std::unordered_map uses a hash function so is generally O(1) for a lookup

#

unordered map has a memory overhead

slim void
#

how am I missing a )

green kestrel
#

so its a tradeoff, if you want speed or memory efficiency

slim void
#

I Included the )

craggy pine
#

so u should check.

quartz kindle
#

ah good to know. its actually node-addon-api's Napi::Object class, let me see what it extends

slim void
#
    backup.create(message.guild).then((backupData) => {
        const embed2 = new Discord.MessageEmbed()
          .setColor('#03fccf')
          .setDescription('**Backup ID**: `'+backupData.id+'`')
          .addField('Information','Make sure you copy this ID as there is no other way we can recover it!', inline: false)
        return message.channel.send(embed2);```
#

it's saying this is missing a )

#

I'm looking, don't see the issue

craggy pine
#

.then((backupData)

#

notice the (()

slim void
#

wdum

green kestrel
#

im betting to store an object's properties you'd use std::map or perhaps a lightweight imitation of it

slim void
#

I don't see it

#

wtf

#

ah

#

I see it

#

that crap hard to see 😂

green kestrel
#

the speed gains of unordered_map only really become visible once you have like tens of thousands of elements in an array

slim void
#

python depicts errors better than js 😭

craggy pine
#

JS is fine with displaying errors.

slim void
#

But when I fix that..

green kestrel
#

like in aegis, the users list is unordered_map keyed by snowflake id

slim void
#

more errors?

craggy pine
#

🤭

green kestrel
#

then you got like std::vector which is a simple resizeable array type container

craggy pine
#

you don't inclose backupdata like this

#

(())

slim void
#

Wdum

craggy pine
#

((thing))

#

(thing)

slim void
#

?

craggy pine
#

((backupdata)) is not correct

slim void
#

then what is correct

green kestrel
#

oh oh, aegis is moving away from Promise/Future imitations in its 3.0 release @quartz kindle 😄

#

finally moving to async++ instead, a more C++-like async library that isnt a wannabe-javascript

slim void
#

this is correct toh

#

I don't see the issue

earnest phoenix
#

you don't need to return in a callback fyi

slim void
#

wdum

opal plank
#

you should learn js rather than trying and error until your compiler doesnt scream at you miner

craggy pine
#

^^^^^^^^

slim void
#

I am learning js

opal plank
#

you are trying a bot

#

its not the same

slim void
#

But this formatting

#

makes no sense

green kestrel
#

what, nobody else here learned to code by brute force, like the monkeys making shakespere?

opal plank
#

its not formatting, its closing your brackers

craggy pine
#

^

slim void
#

I closed my brackets tho!

opal plank
#

it seems like you copying this somewhere and hoping it just works

slim void
#

when I close it

earnest phoenix
slim void
#

when I close it..

#

it has issues

opal plank
#

specially when i look at that code and see you arent properly handling perms from the looks of it

green kestrel
#

oh i tought myself BASIC at 13.... and you can thank that for me being here now @earnest phoenix

opal plank
#

what does it do if you remove the permission to send embeds?

slim void
#

so this is correct?

opal plank
#

remove the permissions to send embeds for your bot miner

green kestrel
#

@opal plank any message containing an embed is dropped, and a permission denied error generated

opal plank
#

and try running that command

slim void
#

no

#

It's a private bot for me

earnest phoenix
#

we were doing basic around that age too, but it was a pain for me because there were already modern day languages at the time

green kestrel
#

oh wait, i thought you asked the question legit, sorry

#

😄

opal plank
#

xD

opal plank
#

if your bot doesnt have send message permission or send embeds, it'll fail twice

slim void
#

yo so what am I doing wrong

green kestrel
#

i always kinda hated that aegis tried to copy js with promise/future

#

and the promise implementation is kinda iffy, it randomly causes thread deadlocks

slim void
#
/home/container/commands/create-backup.js:18
.addField('Information','Make sure you copy this ID as there is no other way we can recover it!', inline: false)
^^^^^^
SyntaxError: missing ) after argument list```
opal plank
#

sharon was telling us about that a couple days ago brain

slim void
#

?!?!?!

#

argument hmm

opal plank
#

its an object to be pássed no?

#

or jsut true?

sudden geyser
#

inline: false

#

That's not right.

slim void
#

It said on docs???

opal plank
#

its either true or an object

#

thats not how js works my dude

sudden geyser
#

inline: false is invalid syntax in this scenario.

slim void
#

I'm used to python

green kestrel
#

hmm, ive seen some parsers be ok with that in js

slim void
#

so if it's not false

#

how to disable inline?

opal plank
#

pass it an object

green kestrel
#

but it should be 'inline': false

sudden geyser
#

Remove the inline: part

slim void
#

🤔

opal plank
#

i dont think you can pass it like that brain

slim void
#

so simply removing it

#

fixes it?

craggy pine
#

'stuff', 'stuff', false

opal plank
#

you need an object

quartz kindle
#

btw @green kestrel i dont think node-addon-api uses maps after all

#

they have their own weird C structures

green kestrel
#

i bet it uses some custom map-like object wrapper

#

ew, C-with-objects

#

its probably scylla map or something

slim void
#

smh

#

host broke

quartz kindle
#

basically node-addon-api is a c++ wrapper for the underlying N-api which is in C

craggy pine
#

The problem with free hosting

slim void
#

bruh bot won't even start

#

it's not free hosting

opal plank
#

the moment you pick a free host you are legit screaming "i dont giv 2 fucks about my bot" btw

slim void
#

it's not free..

opal plank
#

witherhosting

craggy pine
#

I swore I seen Rpl.it which i thought was free? But I suppose now I see witherHosting so idk I may be incorrect then mexShrug

opal plank
#

that sounds like some minecraft stuff ngl

slim void
#

it is

#

I'm hosting a bot on a mc panel

#

😂

opal plank
#

you using minecraft hosting for a discord bot?

slim void
#

ye

opal plank
craggy pine
#

wat in the hell

opal plank
#

no wonder that shit aint working

slim void
#

it works

craggy pine
#

^

opal plank
#

get a proper vps mah dud

slim void
#

just has bugs

opal plank
#

$3 a month and you can get a basic one up and running

slim void
#

I don't like vps

craggy pine
slim void
#

I host my bot in 92 servers on repl.it 😄

opal plank
#

y.i.k.e.s

slim void
#

works rlly nice

green kestrel
#
obj.msg.get_channel().create_message(
    aegis::create_message_t()
        .content(fmt::format("Hello {}", obj.msg.author.username))
        .embed(
            embed()
            .color(0xFF0000)
            .title("Hello")
            .description(obj.msg.author.username)
            .fields({
                field().name("Hello").value(obj.msg.author.username)
            })
        )
);```
easiest way to do an embed, am i right? ![lul](https://cdn.discordapp.com/emojis/746363250714607676.webp?size=128 "lul")
quartz kindle
#

im starting to think making this wrapper wasnt such a good idea after all lmao, i havent even started with jsdoc/types and its already taking weeks

opal plank
#

YOU havent even started?

green kestrel
#

what are you trying to make, tim

opal plank
#

what do you mean YOU tim?

slim void
#

here is my bot

#

on mc panel

craggy pine
#

nice ip

slim void
#

?

green kestrel
#

512mb ram, wow, thats a lot of ram

quartz kindle
green kestrel
#

/s

slim void
#

512mb?

#

is it low??

#

I didn't know how much I needed

quartz kindle
#

one already exists, but its kinda bad

craggy pine
#

incredibly low

slim void
#

it works tho ;D

opal plank
slim void
#

it's a private bot

#

for me only

opal plank
quartz kindle
green kestrel
#

@quartz kindle just integrate the C lib into an aegis bot 😄 problem solved!

craggy pine
#

Discord bots use memory mexShrug

craggy pine
#

512 seems like ull just hit max in 2 secs

quartz kindle
#

the lib is a collection of around 90 functions related to astronomical calculations

opal plank
#

in fairness

green kestrel
#

smallest vps ive seen have at least 2 gigs of ram

#

and thats tiny

craggy pine
#

I use 16

opal plank
#
  • a fuckton of extra shit im attaching
#

like a whole new user object

#

also, wasnt the bot personal? why is it in 92 servers?

quartz kindle
#

im going over each of those 90 functions, and writing proper error handling, messages, etc, and later on i want to add jsdoc and typings for ts

opal plank
slim void
#

ayy

#

I got it online

quartz kindle
slim void
#

My bot in 92 servers has 212mb of ram

green kestrel
#

theres my current ram usage

quartz kindle
#

my bot in 7k servers has 150mb ram

green kestrel
#

but its not all the bot

slim void
#

tim how

green kestrel
#

about half of that is my bot

slim void
#

Brain

opal plank
#

126Gb

slim void
#

what u coding the bot in

opal plank
gilded olive
#

Write in C and all good

green kestrel
#

@slim void C++

slim void
#

wtf

#

that's hell

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

you all eat ram for breakfast jesus

sage bobcat
#

One message removed from a suspended account.

slim void
#

Tim

#

my Minecraft server has 40gb of ram

quartz kindle
#

LOL

opal plank
#

im sorry djs uses a shitton of ram

slim void
#

it runs a network tho

green kestrel
slim void
#

so it's kind of needed 😭

opal plank
#

tim, did you read what i pinged you for yesterday?

green kestrel
#

so like milton i'm happy to reign in hell

#

😄

quartz kindle
opal plank
#

dude

#

djs caches presences

#

and it used up 1gb of ram cuz some retards were doing it

#

also message edits

#

FUCK d.js dude

quartz kindle
#

lmao

green kestrel
#

lol, simple solution? turn off presences

slim void
#
(node:11) UnhandledPromiseRejectionWarning: ReferenceError: Discord is not defined
at /home/container/commands/create-backup.js:23:24
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
opal plank
#

literally

green kestrel
#

😄

slim void
#

rip ran into an error

opal plank
#

i was THIS far from switching to detritus

#

i shit you not

slim void
#

HOW CAN DISCORD not be defined -_-

opal plank
solemn latch
#

imagine changing one setting and cutting your ram usage down to a quarter of what it was

quartz kindle
#

you can turn off presence cache in djsl

green kestrel
#

Discord is not defined <- captain obvious says this is clear from the api docs

slim void
#

?

#

but I defined discord..

opal plank
#

i need to see when a user starts playing a game, but i dont care about what happens afterwards, and that retard shit literally caches everything, 200 messages PER channel, like wtf bro

#

also caching presences

#

AND message edits

gilded olive
#

Presences are needed to show badges for my bot bruh

opal plank
#

like fuck this whole shit

solemn latch
#

djs light erwin ;p

green kestrel
#

@opal plank move to eris?

slim void
#

can I not use discord in embed?

opal plank
green kestrel
#

in the eye?

opal plank
#

detritus is an option

quartz kindle
#

that motivates you do throw djs in the garbage doesnt it?

slim void
#

Tim

opal plank
quartz kindle
#

been there, done that

slim void
#

does

opal plank
quartz kindle
#

:^)

slim void
#

Client.Embed work?

#

instead of Discord

opal plank
#

i smill ads

solemn latch
#

when did you define discord in that snippet

quartz kindle
slim void
#

I didn't define Discord Woo

green kestrel
#

meh, sod advanced discord libs... just use a websocket lib and roll your own!

slim void
earnest phoenix
#

Define it then

slim void
#

?

earnest phoenix
#

Pepega

slim void
#

why

green kestrel
#

i mean how hard can it be lul

solemn latch
#

then how do you expect discord to be defined

slim void
#
const Discord = require('discord.js');```
#

like this?

solemn latch
#

yeah

slim void
#

I figured it didn't need it

earnest phoenix
#

Of course

#

What?

craggy pine
#

You always need it when doing discord things

quartz kindle
#

you need to require your libs in all files that use it

slim void
#

it was working just fine without it?

quartz kindle
#

like python import

opal plank
slim void
#

python so easy

#

import discord
client = discord.ClientI)

#

😄

#

rip typo

earnest phoenix
#

You're using the variable so if you didn't define it, you need to define it

gilded olive
#

Would use commands.Bot instead

earnest phoenix
#

Simple

green kestrel
#

in fact, i came this 👉 👈 close to doing this myself.... just using websocketpp, and rolling my own discord lib. because theres all kinds of crashy weirdness in aegis 2.6 at scale, but im holding out for 3.0 "soon" ™️

slim void
#

I'm not gonna Ghoul

earnest phoenix
#

!help

slim void
#

it's to much work to do that

#

I might give up js

gilded olive
#

no?

slim void
#

and go back to python

#

or lua

quartz kindle
slim void
#

but idk

opal plank
#

imma snitch on ya

gilded olive
#

Good choice

slim void
#

Tim no

opal plank
green kestrel
#

sharon can tell because im constantly posting my stack traces lol

slim void
#

yes*

gilded olive
#

using discord.Client is kinda eh

#

Commands extension provides so much more

quartz kindle
opal plank
green kestrel
#

thing is, i dont have the time to support a discord lib as a community project, anything i'd have made would have been specific to triviabot

#

so kinda a waste of my time

earnest phoenix
#

🗿 Just make discord global, js global.Discord = require('discord.js');

slim void
#

less go

green kestrel
#

yeah each time a bot cluster restarts, it emails me a stack dump

mellow kelp
#

🗿

sage bobcat
#

One message removed from a suspended account.

opal plank
earnest phoenix
opal plank
slim void
#

Anyone know of any free public anti raid bots?

opal plank
#

cuz otherwise i'd be getting banned for abusing mail

gilded olive
#

what type of anti raid

quartz kindle
#

are raids even a thing anymore? i havent seen one in a while

solemn latch
#

so, kinda dumb question, if you have required the same module in two different files, it doesnt actually re require the file right? it just gets it from a cache right?

earnest phoenix
#

how can i see demand list ?

gilded olive
#

arent anti raid just a boolean toggle

slim void
#

Tim why wouldn't raids be a thing

earnest phoenix
#

thinkhfjkld Anti-raid bots are dumb, they can't even do shit properly

gilded olive
#

What do they do

earnest phoenix
#

how can i see demand list ?

quartz kindle
gilded olive
#

Ill make on in py for u miner

slim void
#

not rlly

#

Discord has bad security

#

bypassing bans so easy

#

vpn ..

solemn latch
#

you should have seen discords old security KEKW

quartz kindle
#

i mean for automating stuff

#

like raidbots

slim void
#

Well true

green kestrel
#

@opal plank
im the only one that gets these stack dumps, i dont have anyone else who knows C++ on the bot team who i'd trust 🙂

slim void
#

Anyone code bots in ruby

#

or php

#

My friend coding a bot in php

mellow kelp
#

oh god

green kestrel
#

this is one of two repeated crashes i get, that i think are eliminated in 3.0

slim void
#

😂

earnest phoenix
#

Just code it in binary

green kestrel
#

but im not rolling it out in production until sharon says its stable enough

earnest phoenix
#

Weak ass

#

🗿

slim void
#

code a bot in html/css

green kestrel
#

no, use RPG Maker

slim void
#

Brain I have some bad news

mellow kelp
#

how about coding a bot in cow language

slim void
#

As a fellow developer here..

#

I'm going to have to demote you Brain..

earnest phoenix
slim void
#

jk

opal plank
slim void
#

Yukine never talks

#

Brain ping Yukine, I wanna hear him

green kestrel
#

i made that offer recently, i'd consider letting sharon help for sure.... but i dont know if sharon has the time

slim void
#

I'd ping him but ya know?

#

I'd be banned

green kestrel
#

aegis keeps sharon busy enough!

slim void
#

😭

earnest phoenix
#

WeirdChamp "Development"

slim void
#

?

#

What language is mee6 in

quartz kindle
#

C6

gilded olive
#

Python

slim void
#

c6?

gilded olive
#

iirc

slim void
#

oooO python

green kestrel
gilded olive
#

Yes

opal plank
green kestrel
#

theres some things C++ just plain sucks at

quartz kindle
#

DiscordOS™️

green kestrel
#

like image manipulation

solemn latch
#

discordos when

opal plank
#

doesnt canvas run on c++ ?

quartz kindle
#

cant you just use a lib like magik/pango/cairo?

earnest phoenix
#

how can i check if there is an specific ID inside a db?

gilded olive
#

Lang?

#

Well

#

Db?

#

If its postgres i know the query

green kestrel
#

no, canvas is a js specific thing

quartz kindle
#

node's version of canvas is built with c++

solemn latch
#

its for js, but its not written in js is it 🤔

green kestrel
#

i delegate image generation to php, and use a combination of GD2, and wkhtmltoimage

slim void
#

how do you change presence in js

green kestrel
#

which takes html/css, and outputs an image, using a cut down webkit renderer, as a lib

earnest phoenix
#

i use imagemagick for image manipulation

#

yum

green kestrel
#

that generates my rank cards

#

canvas is specific to the js ecosystem, originally designed for browser use

quartz kindle
#

yes but node's version of canvas is not

#

node.js doesnt have a built-in canvas

#

since it doesnt have DOM nor UI

#

the package node-canvas is a userland implementation backed by libcairo and libpango

#

in c++

green kestrel
#

hmmm

earnest phoenix
#

how can i check data of a easy.database's db?

green kestrel
#

i wonder if thats worth looking into

#

so long as its not node.js api specific

quartz kindle
#

ye

green kestrel
#

wkhtmltoimage is quite heavyweight

#

you basically generate a html/css file of what you want as an image, and call it as a command like wkhtmltoimage myhtml.html output.img

quartz kindle
#

Cairo is a 2d graphics library written in C

green kestrel
#

where either or the input or output can be stdin and stdout

#

so wkhtmltoimage can render anything chrome can

#

as an image

#

not just canvases

#

😄

quartz kindle
#

sounds like overkill tho lmao

slim void
#

hey

green kestrel
#

its very powerful but with that comes inefficiency

slim void
#

What's the easiest way to make a js bot

#

delete every single channel

solemn latch
#

api aboos

slim void
#

what

#

it's not abuse

quartz kindle
#

guild.channels.cache.forEach

slim void
#

I'm not raiding.. it's for my own server if I ever wanna delete or if I get raided.

green kestrel
#

yeah, but it was the only way i could render coloured glyphs (e.g. coloured emoji fonts) as GD doesnt support it

quartz kindle
#

lul

green kestrel
#

or rather freetype2 doesnt

quartz kindle
#

hmm

green kestrel
#

php needs to get with the times (new roman)

slim void
#
message.guild.channels.forEach(channel => channel.delete())```
earnest phoenix
quartz kindle
#

cairo should support it, since node-canvas does

slim void
#

damn all channels gone just in 1 line

green kestrel
#

im pretty sure it would

gilded olive
opal plank
solemn latch
#

just a heads up, servers can have 500 channels, youd absolutely get ratelimited and be reported for api abuse

slim void
#

oh

#

sry

#

Woo

#

I'd only use it in my server

gilded olive
#

Ive never seen a server have 500 channels

green kestrel
#

hmmm

slim void
#

So your saying

gilded olive
#

Or anything plus 100

slim void
#

a raider can make 500 channels in my server

green kestrel
#

cairo looks a lot more efficient than what im using now

slim void
#

but I cannot delete them?

opal plank
#

cuz most sane people dont, but i've seen those cringe servers having them

green kestrel
#

i might just make a standalone cairo program called render-rank-card which i pass in a snowflake id

opal plank
#

funnily enough, its always servers that have 400 roles and everyone has at least 120 out of them that usually have those spam of channels

green kestrel
#

it'd be a ton faster than the php stuff

opal plank
#

and all of them have those weird ass letters in it

gilded olive
#

Oop emojis broke

slim void
#
client.on('message', message =>{
  if(message.author.id == "YourID") {
  if(message.content === "!bye") {
  message.guild.channels.forEach(channel => channel.delete())
    }
  }
})```
#

now I will add sleep

#

like delay?

opal plank
#

why are you even ATTEMPTING to delete all channels?

gilded olive
#

Hes just showing its possible

opal plank
#

why?

gilded olive
#

Idk man

opal plank
#

why even post possibly malicious code here?

slim void
#

I'm not

#

It's to prevent a raid?

earnest phoenix
#

Ah yes, proving that API abuse is possible? KEKW

slim void
#

if someone ever raided me

solemn latch
#

how do you prevent a raid by deleting every channel

green kestrel
#

yeah, please dont post stuff like that

slim void
#

I can just delete his spam channels 😄

green kestrel
#

well theres nothing left to raid ig

solemn latch
#

lol

slim void
#

I also own a server with 240 channels

quartz kindle
#

is there a raid that creates channels? wut

gilded olive
#

Gmail is down????

slim void
#

and I wanna get rid of them

gilded olive
#

Or am i confused

solemn latch
#

oh no

earnest phoenix
#

why it returns undefined before the ID?

vipN.add(papuV.tag, papuV.id)
green kestrel
#

so wait, you want to make a bot that you trick someone into adding that destroys their server

#

let me get this straight

slim void
#

No?

#

wtf

opal plank
#

the fact that you have a bot with already 92 servers makes me reluctant to even tell you how your code is wrong

earnest phoenix
#

If you're to prevent a raid by deleting all channels then just delete the server instead KEKW

gilded olive
#

Nvm its working

green kestrel
#

so how would you ever get the opportunity to execute that code

#

:woozy_face:

slim void
#

Brain

#

I have a discord

#

with a bunch of channels

#

I need the code for me..

opal plank
slim void
#

My private bot

green kestrel
#

yeah im done

slim void
#

and public bot

#

are two different bots

green kestrel
#

so about butterflies. i hear butterflies are awesome.

solemn latch
#

brain qt

earnest phoenix
#

Doesn't mean you're allowed to abuse the API, private nor public

gilded olive
#

If they were less skids maybe rate limits wouldnt be so high

slim void
#

I'm not abusing the api

solemn latch
#

the ratelimits are good

slim void
#

if I set a delay

solemn latch
#

like actually super reasonable.

opal plank
#

if we killed 90% of the bots, they'd probably allow for a lot more shit

slim void
#

5 channels deleted in 4 seconds

#

that's not that bad

earnest phoenix
#

That's still API abuse

slim void
#

how much sleep do I need?!?!?

solemn latch
#

pretty sure nuke commands in general are api abuse my dude

earnest phoenix
#

You know how ratelimits work right?

gilded olive
#

Ban all non verified bots and start anew PoggersHype

slim void
#

So I can't nuke my own Discord?

solemn latch
#

no

#

not with a bot

slim void
#

How do I delete a mass bunch of channels

gilded olive
#

Thats still API abuse my guy

#

Yourself

slim void
#

what

solemn latch
#

^

slim void
#

that's dumb tho

earnest phoenix
#

You're nuking your own discord by the help of thousands of discord API calls

gilded olive
#

So api abuse isnt dumb?

slim void
#

how are backup bots allowed?

gilded olive
slim void
#

backup bots do the same thing

#

delete channels and replace new ones

#

they are worse

quartz kindle
#

type checking in n-api is a pain

solemn latch
#

thats not a nuke by discord definition afaik

gilded olive
#

Ah ues

slim void
#

fine my cmd is just a cmd

#

that deletes all channels

#

then makes a new channel to my needs

#

😄

#

therefore it's utility

earnest phoenix
#

API abuse much?

gilded olive
#

Api abuse shaggyface

slim void
#

it's not abuse -_-

earnest phoenix
solemn latch
#

its less of what you call it and more of what it does that makes it a nuke command

mellow kelp
slim void
#

It's a backup bot

gilded olive
#

"That deletes all channels"

slim void
#

all it does

gilded olive
slim void
#

is delete all channels

#

and replace is with my template?

#

it's not api abuse

gilded olive
#

Listen

slim void
#

and it does it all in 2 seconds

gilded olive
#

If i make a server

#

With 500 channeks

#

Bring your bot

#

And do that

slim void
#

my bot is private?

gilded olive
#

Youll be ip banned

slim void
#

it's private

earnest phoenix
#

How's it not API abuse to make hundreds of API calls under 30 seconds?

slim void
#

private

earnest phoenix
#

Do i have to repeat myself again?

slim void
#

Xenon bot makes hundreds

mellow kelp
#

it still uses the discord api

slim void
#

under 30 seconds

gilded olive
#

Well guys

opal plank
earnest phoenix
#

Public or private, both makes the API calls to the same route

gilded olive
#

Your private bot dosent even actually use discord api

slim void
#

anyways

#

I'm not doing anything out-of-line

#

so I'm fine

mellow kelp
#

you are

gilded olive
#

You are

slim void
#

I will just have it delete a channel every 10 seconds

earnest phoenix
#

API abuse is "out-of-line"

mellow kelp
#

extremely

gilded olive
#

ask in discord api server

#

Theyll tell you the same thing

slim void
#

HOW is it api abuse when other top.gg bots do it worse?!!!

#

invite me to api server

earnest phoenix
slim void
#

im going in

earnest phoenix
#

Ask here

slim void