#development

1 messages ยท Page 1566 of 1

umbral zealot
#

show us your switch/case code

#

as well as how args is defined

earnest phoenix
umbral zealot
#

oh god

#

ok nevermind

cinder patio
#

๐Ÿ‘๏ธ ๐Ÿ‘„ ๐Ÿ‘๏ธ

marble juniper
umbral zealot
marble juniper
#

k thanks

marble juniper
# earnest phoenix

we already said you should read the guide before asking here again so please do that

earnest phoenix
#

k

umbral zealot
#

You can't just take a bot online and then throw in random code from some other bot and expect it to work. Please learn javascript first.

marble juniper
#

^

#

you can't code something without knowing how to code

signal summit
#

How do i get the json information of my bot's ratelimits bucket?

earnest phoenix
#

ratelimits aren't returned in json, they're returned in the request headers (except when you're actually ratelimited, you get Retry-After header set in the json response)

#

also

#

your lib should handle ratelimits for you

#

why do you want to access those

signal summit
#

Just to make sure my bot doesn't gets ratelimited?

#

As far as i know discord.py creators say it handles the ratelimits for me

slender thistle
#

yes

#

that is correct

tired panther
signal summit
#

Yes

modest maple
#

I mean you can hit ratelimits

signal summit
#

That's what's worrying the heck outta me

modest maple
#

the libs just re-schedule and wait till it clears before sending again

signal summit
#

So again asking is there a way to enquire information about ratelimits bucket or i take steps (make some sort of wrapper) to prevent bot sending messages too quickly?

tired panther
modest maple
#

again, you're library should already handle that for you

#

you dont know the ratelimit untill you hit it when it gives you how long to wait for

tired panther
signal summit
#

Alright then ty guys.

modest maple
#

change channel names are every 2 times every 10 minutes

tired panther
modest maple
#

the only ratelimit discord has publicly disclosed

tired panther
#

But you should take 10 minutes, to be safe xD

#

or 7,8

signal summit
#

I feel dumb i still don't know what channel are you talking about. Or how do i change it

tired panther
#

#topgg-api you can just change the channel name every 5 minutes

signal summit
#

How changing channel names will help l9l

#

lol*

tired panther
#

I just now it for js lol

#

#channel.setName("hashdadjijd");

signal summit
#

Okay that's fine but what about DM channels then

tired panther
signal summit
#

Yeah exactly

#

Ok I'll figure a way out to keep discord away from swinging that block hammer upon my bot ty again.doggowave

tired panther
terse finch
#

in discord.py i know i can do @has_permission(permission=True) but i need it to be more modular like if ctx.author has permission == permission or if ctx.author.role in approved_roles: is this possible? whats the method to get a users permission, ive been searching up online but most of the results for me are either outdated using the old discord library or only cover the first method which is not what i need.

slender thistle
#

manual check function, should be explained in d.py docs faq

dusky sundial
#

Is it normal to not get a reply on your intents application after 19 days? SadKitty

slender thistle
#

With Discord nothing is normal

dusky sundial
#

Fair enough

earnest phoenix
#

Or manual one as shiv mentioned, both work

terse finch
#

ok thanks for the suggestions

terse finch
stable nimbus
#

I am still in need of assistance. I tried something else and it didn't work and I'm struggling.

terse finch
#

one more question is there a way to get a list of an authors permissions as well?

earnest phoenix
#

For what usecase?

#

You wanna list it as string or you wanna check if the author has certain permission?

earnest phoenix
crystal wigeon
#

was i pinged here?

earnest phoenix
#

Get a Permissions object first, assuming author is a Member object, you can do either author.guild_permissions or channel.permissions_for(author) or author.permissions_in(channel). And just get the attribute you want to check and it'll return boolean. If you wanna list out all the perm the author has, you can do [perm for perm, allowed in permissions if allowed], it'll return list of str

#

How do IDEs do syntax highlighting? I mean, you can't insert markup inside an html input element so you can't use CSS to color stuff or some other wizardry.

old cliff
#

they don't use html for that.... they use js think_gmagik

restive furnace
earnest phoenix
#

vsc uses electron

#

im wondering how they do it

restive furnace
#

with css iirc

earnest phoenix
#

how are you gonna insert css in an input

old cliff
#

And on keypress

restive furnace
#

if (keyword === "return") return <p classname="main.css">return</p> ig?

old cliff
#

Change a div

#

With css

#

And on click on div focus window to the hidden textbox

#

Simple

earnest phoenix
#

there's an entire jquery plugin that does that
but the div is behind the input so it cant color the text itself just add backgrounds

restive furnace
#

he's asking how do they highlight it

restive furnace
earnest phoenix
#

ok

restive furnace
#

reading code is best way to learn (actually 2nd best way but still)

misty sigil
#

whats the best way

#

reading docs?

earnest phoenix
#

will goto sleep and wake up next morning then see the answers on my stakuverflo question about dis

restive furnace
#

learning by practice

#

and reading the docs

earnest phoenix
restive furnace
#

no?

earnest phoenix
#

yes?

zenith terrace
restive furnace
#

with i n t e l l i s e n s e

old cliff
earnest phoenix
old cliff
#

Hmm

restive furnace
old cliff
#

Consideravleee

restive furnace
#

bad practice

earnest phoenix
#

and yes i did try spoonfeed and it didnt work anyways so

#

e

restive furnace
#
function feed() {
    return "spoon";
}```
old cliff
#

Use jquery to do that

#

I could code it for u but

#

I don't have time

earnest phoenix
#

ok bye

terse finch
#

idky but i thought his profile was a psyduck :P

old cliff
#

You could copy pasta stuff from hastebin highlighting @earnest phoenix

restive furnace
#

smh my head

deft lark
#

hi

earnest phoenix
#

you can snoop around the source code

old cliff
#

Noice

earnest phoenix
#

hey, after so many guides i made a code

#

but bot is not replying to that

#

ban command

#

heres the code

#

its above 2000 characters

mellow kelp
#

use hastebin or something

earnest phoenix
#

ok wait

#

bro i used some public codes n merged them n edited them

#

i used kick command

#

and edited it

stable nimbus
#

I cneed help reloading all files inside of a folder. I get it to read the files but I need it to walk through the files and reload them and I have no idea how to do this and google isn't helping.

earnest phoenix
#

not working

#

yes i did

stable nimbus
#

I want to prevent restarting my bot when I add new commands, I wanna reload an entire folder of .js files and cache new commands.

earnest phoenix
#

can u share a ban code for node.js, as i tried 3-4 codes none of them works, but it works in kick

stable nimbus
#

I have it looking at the files and its able to tell me the files that are in the folder, but I can't figure out how to reload them and cache new ones.

crimson vapor
#

its likely your command handler

#

you can clear the cache

#

then re run the command loader

earnest phoenix
#

please check this out

stable nimbus
#

How would I do that?

earnest phoenix
#

tried

old cliff
stable nimbus
#

bruh

solemn leaf
#

wait

old cliff
#

No

solemn leaf
#

case "clear":

#

lmfao

old cliff
#

Its a part of the spoon conversation

earnest phoenix
#

bro i did it already and even changed

#

token is working in the kick command but not in ban command

earnest phoenix
earnest phoenix
#

but bro i did it in kick command,n its working 100% fine

#

but same code with ban

#

not working

old cliff
#

Literally giving away token

earnest phoenix
#

oh shit

#

wait

crimson vapor
#

it does yes

old cliff
umbral zealot
#

didn't you have a full command handler earlier with commands in their own files

#

that you copied from github somewhere

earnest phoenix
#

one for kick

#

and one for ban

#

kick is working fine

#

but ban is not

old cliff
#

Thats not how its done

#

You just run 1 insuance of the bot

#

And add the kick command and ban command in one file

#

First learn js

earnest phoenix
#

bro all my commands are working fine, m using repl.it

umbral zealot
#

Theory: You took this ban command from an online tutorial and tried to paste it in ./commands/ban.js

#

All the commands that are working fine are the ones you stole from the original repository with the rest of the bot, don't pretend like you actually wrote anything.

earnest phoenix
#

anyways, after resetting token ban command also worked

umbral zealot
#

Stop copy/pasting shit.

#

Go learn javascript

earnest phoenix
#

n yes, discord.js publically posted an example of ban n kick command

earnest phoenix
umbral zealot
#

Whatever other people do doesn't matter. We're telling you, you need to go learn javascript, we're not going to spoonfeed you when literally all you've been doing is shoveling random code into your bot

earnest phoenix
#

bro m learning ok, not just copypasting it, im understanding each line n fixing on my own

umbral zealot
#

You're 100% absolutely definitely not writing anything right now, stop pretending.

crimson vapor
old cliff
#

Except botghost peeps

umbral zealot
#

If you even remotely knew what you were doing, you'd know you don't copy/paste a full bot with events and login inside a command file built for a command handler.

earnest phoenix
#

m saying i am understanding each line, n thats enough for my knowledge

umbral zealot
#

Go learn JS, you will not get further help from us until you show you at least understand a square peg doesn't go in a round hole.

stable nimbus
mellow kelp
#

that was not very cash money of you

umbral zealot
#

They're just trying to justify their crap shoveled bot by trying to bring other bot devs down, indeed, that's most definitely not kosher.

stable nimbus
#

No dosh for you.

umbral zealot
#

Tylers don't listen until you start becoming harsh. I'm saying this from years of experience.

stable nimbus
#

I can agree to that.

umbral zealot
#

Literally I've said worse to people and they come back and thank me for pushing them to go learn. I will continue to do so in the foreseeable future.

stable nimbus
#

I'm over here with a 600+ server bot that I hand made, barely copy pasted shit and if I did it was because something didn't look right and I couldn't figure out where to put a line.

#

Evie also helped me a bit so props to them.

umbral zealot
#

I mean, obviously if you think I'm wrong, @swift umbra , you're free to DM them fully made code that's working, and keep doing it. Falling victim to a help vampire is nothing to be ashamed of, if you feel you're doing something right by it.

#

You wouldn't be the first one, and not the last, and I've been sucked dry before so I know the feeling ^_^

earnest phoenix
#

module.exports = {
    name: "ban",
    aliases: [""],
    description: "Ban Mention User",
    usage: "<mention|id> [reason]",
    category: "moderation",
    run: async(bot, message, args) => {
        let member =  message.mentions.users.first() || message.guild.members.cache.get(args[0]);

        if(!member) return message.channel.send(`Please Mention A User`);

        let reason = args.join(" ").slice(22);
        if(!reason) reason = "No Reason Specified";

        if(!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send("You Dont have permission to kick member");

        let  paras = new MessageEmbed()
        .setTitle(`${member} ban`)
        .setColor("RED")
        .setDescription(`
            banned User: ${member}\n
            Mods: ${message.author}\n
            Reason: ${reason}
        `)
        .setTimestamp(new Date())
      

        let userE = new MessageEmbed()
        .setTitle(`You've Been banned From **${message.guild.name}**`)
        .setDescription(`
            Mods: ${message.author}\n
            Reason: ${reason}
        `)
        .setTimestamp(new Date())

        message.guild.member(member).ban(reason);
        message.channel.send({paras});
        member.send({userE});
    },
};```
#

can anyone atleast tell me that where it is wrong

crimson vapor
#

what is the issue?

old cliff
#

The peoblem is that

earnest phoenix
old cliff
#

You are nowhere making a command handler

crimson vapor
#

ah

crimson vapor
earnest phoenix
old cliff
#

Hmm

crimson vapor
#

is the user above the bot on the member list?

earnest phoenix
#

i tried editing same code 10times

old cliff
#

Lol

earnest phoenix
old cliff
#

I see the error

earnest phoenix
#

admin perms also

crimson vapor
#

bots can only ban users below them

earnest phoenix
old cliff
#

You are not correctly banning the corrdct member

earnest phoenix
#

means?

stable nimbus
#

@umbral zealot I know you programmed Enmap (at least your take on it for AIG), but could you assist me with something since I'm struggling?

grizzled raven
#

bruh

#

lol

#

the problem is ```js
message.channel.send({paras});
member.send({userE});

earnest phoenix
#

?

grizzled raven
#

do { embed: paras } /{ embed: userE } or even just paras/userE instead

spiral crag
#

guys how can i find the no of servers my top.gg bot is in

rustic nova
#

through your bots code

grizzled raven
#

message.channel.send(paras); member.send(userE);

#

remove the {}

quartz kindle
#

first of all, since you're using repl.it open the terminal and actually read what the error is

earnest phoenix
#

oh

rustic nova
grizzled raven
#

the error's gonna be "cannot send an empty message" which i guess points to where the mistake may be

umbral zealot
stable nimbus
#

Except for tim, tim has been busy.

grizzled raven
#

ask

#

ask the question

#

or point to the question you've already asked

earnest phoenix
#

@grizzled raven i did what u said, but after running that the bot stopped responding to .ban command

grizzled raven
#

@earnest phoenix read the error

stable nimbus
#

I need to be able to cache new commands after adding them to the bot without restarting my bots processes, basically I need to reload an entire command folder.

earnest phoenix
#

no error comng bru

stable nimbus
#

I have it reading the entire folder, but it won't reload the commands or load new ones.

quartz kindle
earnest phoenix
dusky sundial
grizzled raven
#

its the last few characters of the error

lyric mountain
#

expand that console goddammit

grizzled raven
#

exactly

dusky sundial
#

no error comng bru

grizzled raven
dusky sundial
slate oyster
#

Translate is smart
This is not valid JSON, but it is close
And it kept the original JSON keys

lyric mountain
#

look, jsons are either valid or pure trash actually

stable nimbus
#
const folder = args.slice(0).join('');
const files = fs.readdirSync(`${__dirname}/../../commands/${folder}`);
try {
  if(!folder) {
  //return error
}
else {
message.channel.send(`Reloading`);
client.unloadCommand(files);
client.loadCommand(files);
message.channel.send(`Reloaded`);
};
};
earnest phoenix
lyric mountain
#

there it is

#

the error

slate oyster
lyric mountain
#

you must only pass dictionaries to DictType

lyric mountain
#

or escape them

earnest phoenix
slate oyster
lyric mountain
#

or use a locale file

#

instead of json

#

it's a simple key-value file too, but it is delimited by newline

earnest phoenix
quartz kindle
#

reason must be inside an object

lyric mountain
#

the good thing about it is that it treats anything after "=" as a string

#

no need to escape anything

slate oyster
#

Nice
I might eventually switch to that

quartz kindle
#

also shouldnt you be checking for folder errors before and during using fs?

#

that way it will error out anyway

stable nimbus
#

Load Command

async loadCommand (commandPath, commandName) {
        try {
            const props = new (require(`.${commandPath}${path.sep}${commandName}`))(this);
            props.conf.location = commandPath;
            if (props.init){
                props.init(this);
            }
            this.commands.set(props.help.name, props);
            props.help.aliases.forEach((alias) => {
                this.aliases.set(alias, props.help.name);
            });
            return false;
        } catch (e) {
            return `Unable to load command ${commandName}: ${e}`;
        };
    };

Unload Command

async unloadCommand (commandPath, commandName) {
        let command;
        if(this.commands.has(commandName)) {
            command = this.commands.get(commandName);
        }
        else if(this.aliases.has(commandName)) {
            command = this.commands.get(this.aliases.get(commandName));
        }
        if(!command){
            return(`The command \`${commandName}\` doesn't seem to exist.`)
        }
        if(command.shutdown) {
            await command.shutdown(this);
        }
        delete require.cache[require.resolve(`.${commandPath}${path.sep}${commandName}.js`)];
        this.logger.log(`Unloading Command: ${commandName}.`, "warn");
        return false;
    }
lyric mountain
#

can't u just read the file on runtime instead of caching them?

earnest phoenix
#

i tried using code give on
https://discord.js.org/#/docs/main/stable/examples/moderation
Still an error

quartz kindle
#

.file.run is not a function

#

where do you have .file.run in your code?

quartz kindle
#

your load and unload functions dont have anything to treat arrays

stable nimbus
#

My loader on startup

const directories = await readdir("./commands/");
    client.logger.log(`Loading a total of ${directories.length} categories.`, "log");
    directories.forEach(async (dir) => {
        const commands = await readdir("./commands/"+dir+"/");
        commands.filter((cmd) => cmd.split(".").pop() === "js").forEach((cmd) => {
            const response = client.loadCommand("./commands/"+dir, cmd);
            if(response){
                client.logger.log(response, "error");
            }
        });
        client.logger.log(`Loading a total of ${commands.length} commands in ${dir}.`, 'log');
    });
quartz kindle
#

thats not the issue

stable nimbus
#

I know

#

But, it could give me some hints.

#

Cause that uses just plain readdir.

quartz kindle
#

you took files from readdirSync and gave it directly to load/unload as a first parameter

stable nimbus
#

Okay, what should I do then and how would I do it?

quartz kindle
#

look at your loader

#

you get directories from readdir

#

what do you do with it?

stable nimbus
#

I look at each directory and then read whats in each directory.

quartz kindle
#

exactly

#

so logically, you have to do the same thing

#

before you can give the file and path to load/unload

#

look at each directory, read whats in each directory, and use load/unload on each file found

stable nimbus
#

Okay, how would I work that in? Using my loader on startup and using the mentioned directory like in const files?

quartz kindle
#

its not that hard

#

just copy and paste your loader and replace the inside of it with what you need

stable nimbus
#

Oh.

#

Okay.

#

yeets over to VSC

earnest phoenix
grizzled raven
earnest phoenix
quartz kindle
earnest phoenix
#
const members = await message.guild.members.fetch();
    const memberlist = members.filter(x => x.user.flags != null).array();

    for (let index = 0; index < memberlist.length; index++) {
        const m = memberlist[index];
        await m.user.fetchFlags().then((flags) => {


            for (const flag of new UserFlags(flags)) {
             
            console.log(`${m.user.id} ${flag}`)
     
  
            }


        });

    }

This is only returning id of user with his flag, but i want to know how many user get a certain badge, how i can do that?

smoky herald
#

hello ๐Ÿ‘‹ I'm getting to sharding and if I understand the concept correctly, each shard runs duplicate bot code?
so if I'm posting server count on top.gg from the bot.js every 60 minutes, does it mean each shard will post it each hour instead of just once? should I move the post code to the new sharding manager file - index.js then?
same with getting top leaderboards from my db, if I pull from database top players every hour, does it mean it would run the same code 10 times with 10 shards?

misty sigil
#

yea

eager grail
#

I have a domain and a html file, how to host it as a website with tht domain?

smoky herald
# misty sigil yea

ariight, so I should basically move all the interval code parts to the index.js instead right?

rustic nova
#

for example on your vps

eager grail
fluid crown
#

Hihi! I was told to come here for advanced markdown development--the markdown cheat-sheet provided to me in support isn't really what I need. I'm trying to find ways to have automatic counters, coloured/animated backgrounds, etc. For example:
https://top.gg/bot/649604306596528138
or even something as simple as
https://top.gg/bot/646937666251915264

rustic nova
#

or you just buy a webhosting

eager grail
#

I'm new to web development

rustic nova
# eager grail how to set tht domain fr tht html file?

You need some kind of machine to host that webserver on, i suggest reading over https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04 if you have linux experience

DigitalOcean

A 'LAMP' stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server.

eager grail
#

oops, I'm windows

rustic nova
#

One moment

#

or where are you hosting your bot on?

rustic nova
#

repl.it probably has webhosting too, though can't help you with that

eager grail
#

oof kk

stable nimbus
#

@quartz kindle Okay so I have made progress, but now its saying that commands.filter is not a function.

 setTimeout(function() {
                                        client.logger.log(`Loading ${folder} back into the cache.`, "ready");
                                        const commands = readdir(`${__dirname}../../${folder}/`);
                                            commands.filter((cmd) => cmd.split(".").pop() === "js").forEach((cmd) => {
                                                const response = client.loadCommand(`${__dirname}../../${folder}`, cmd);
                                                if(response){
                                                    client.logger.log(response, "error");
                                                }
                                            });          
                                            client.logger.log(`Loading a total of ${commands.length} commands in ${folder}.`, 'log');
                                        }, 5000);
opal plank
#

@lyric mountain are you awake?

earnest phoenix
#
fs.mkdirSync(this.dir);
``` is throwing an error because the directory doesnt exist? i thought it was **m**a**k**e**dir**ectory
quartz kindle
quartz kindle
#

unless you give it recursive:true

earnest phoenix
quartz kindle
#

thats why you got the error

#

your path was wrong

earnest phoenix
#

ah

crimson vapor
#

db/data

#

json?

stable nimbus
#

@quartz kindle Now it says it can't find the modules.

earnest phoenix
#

that makes sense tho ig, i have the db.js in a diffrent folder than the index.js

earnest phoenix
crimson vapor
#

ah

#

do you use a custom package or wrote your own code?

earnest phoenix
#

i wrote my own code

#

im doing a rewrite rn

crimson vapor
#

ok be careful since if you try to read and write the file at the same time it will corrupt iirc

earnest phoenix
#

ik

crimson vapor
#

yep

earnest phoenix
#

thats why im splitting it up

#

and gonna make a queue

#

that way it cant corrupt data for more than 1 member in 1 guild

#

and i could add restart to that queue

crimson vapor
#

you shouldn't have too many files

earnest phoenix
#

so even harder

crimson vapor
#

I understand different files for different purposes, such as settings or stuff

#

but not per guilds

earnest phoenix
crimson vapor
#

ok

#

but much imo but whatever works

lyric mountain
opal plank
#

can u do me a favor rq?

#

simple stuff

crimson vapor
#

favor for erwin poggers

opal plank
#

i need to check if cloudflare is blocking ip's

earnest phoenix
lyric mountain
#

sure

opal plank
#

but it needs to be someone from brazil

lyric mountain
#

which IP should I ddos?

opal plank
#

and iirc you're brazilian, no?

lyric mountain
opal plank
#

and you're in brazil, correct?

lyric mountain
opal plank
#

perfect

earnest phoenix
# crimson vapor lol

okay ๐Ÿ˜ฉ in a moment it will be time to write some code to transfer my old db to the new one

crimson vapor
#

you really should use a real db just so you know

earnest phoenix
#

ik, many people say that but i would prefer this

crimson vapor
#

@umbral zealot enmap is persistent right?

stable nimbus
#

Don't go to MySQL, unless you have no other options.

umbral zealot
crimson vapor
#

use enmap

earnest phoenix
#

ill think on it

lyric mountain
#

why use enmap when you can use json kappa

crimson vapor
#

because I was told to tell people to use enmap

earnest phoenix
crimson vapor
#

ive really got to fix my json database

#

add queues and shit

#

so its not fucking stupid

mellow kelp
#

jason.db

crimson vapor
#

yes

earnest phoenix
crimson vapor
#

wanna add queues for me? @mellow kelp

crimson vapor
#

ive got to maintain it now

#

erwin found a way to break it

mellow kelp
crimson vapor
#

yep

#

no dependencies if possible

earnest phoenix
crimson vapor
#

only 1 im allowing is atomic write

mellow kelp
#

k

crimson vapor
#

thats if the queue system doesn't work

#

well

#

work well

#

@opal plank how should a queue system be implemented?

mellow kelp
#

aight

#

well ill probably start in a couple hours or so

crimson vapor
#

ok

earnest phoenix
quartz kindle
#

what kind of queueing you do need?

crimson vapor
#

nah it needs to be more advanced than a simple array

#

json db

#

try to lower the writes

quartz kindle
#

because if you're splitting into many files, you dont need queueing, unless you need to write to the exact same file at the same time, which you can mitigate by using writeFileSync

earnest phoenix
quartz kindle
#

writeFileSync is blocking but since the files are small, the amount of block time will be pretty much irrelevant

earnest phoenix
crimson vapor
#

iirc I don't use writeFIleSync

earnest phoenix
earnest phoenix
crimson vapor
#
  /**
   * Write to the DB
   * @param data Data to be written
   * @returns {boolean} success
   */
  _write(data) {
    // Check if "data" is the wrong data type
    if (data === undefined) throw new Error('Tried to write to DB without any data');
    if (!['object', 'array'].includes(typeof data)) throw new TypeError('data must be of type "object" or "array"');

    // Write to "tmp/data.json" and rename file. Throws if errors
    try {
      data = JSON.stringify(data);
      fs.writeFileSync(this._tmpFilePath, data, 'utf8');
      fs.renameSync(this._tmpFilePath, this.path);
      return true;
    } catch (err) {
      throw new Error('An error occured when writing to the DB:\n' + err);
    }
  }```
opal plank
crimson vapor
#

I do

crimson vapor
quartz kindle
#

also if you implement the "write temp then rename" you also dont need queueing nor sync, so you get non-blocking as well, best of both worlds

crimson vapor
#

don't just want to rely on blocking

#

idk man, erwin made errors

earnest phoenix
#

hmmm yes

grizzled raven
#

jar

opal plank
#

erwin made errors?

crimson vapor
#

yes

opal plank
#

what errors did i make?

crimson vapor
#

you broke my code

opal plank
#

how come?

crimson vapor
#

while(true) {}

#

idk the code you did

opal plank
#

@lyric mountain it was me being stupid and forgot a ssh tunnel with a fucked up port

crimson vapor
#

when you were testing my package btw

opal plank
#

WHY would you do that shit

#

oh

#

i see

#

yeah

crimson vapor
#

so I need to fix

opal plank
#

good luck

quartz kindle
#

lmao

crimson vapor
#

idk how tho since it works on my computer

mellow kelp
#

the thing is

cinder patio
#

I know a fix but you may not like it

mellow kelp
#

exactly what failed KEKW?

opal plank
#

i dont recall it either, you'd have to check what i sent before

#

i usually send enough info to replicate it

crimson vapor
#

iirc no perms to write file happened

mellow kelp
#

o

#

then just do an access check first

quartz kindle
crimson vapor
#

probably

quartz kindle
#

the name of the temp file should be randomized

crimson vapor
#

which do be dumb

quartz kindle
#

always random

opal plank
crimson vapor
#

LOL

earnest phoenix
#

ptb?

quartz kindle
#

who actually uses the discord app

#

i use discord web

#

:^)

crimson vapor
#

canary > prototype > discord

opal plank
crimson vapor
#

do you actually?

#

tim

opal plank
#

65% of my CPU going to discord

opal plank
#

just the vanilla client

#

no mods, no shit

crimson vapor
#

what cpu?

opal plank
#

spit

#

dunno

quartz kindle
crimson vapor
quartz kindle
#

lazyness

crimson vapor
#

bruh

#

its so easy

#

just download and use qr code

quartz kindle
#

all my chats and social media are always on the browser

crimson vapor
#

makes sense

quartz kindle
#

so yeah

#

im used to look for it in the top tabs, not the bottom tabs :^)

earnest phoenix
#

trk var mฤฑ

ruby orchid
#

how long does it take for a discord bot to be verified?

earnest phoenix
ruby orchid
#

oh

crimson vapor
#

ez fix

earnest phoenix
#

huh ?

ruby orchid
#

what does that have to do with anything

crimson vapor
#

top bar

#

wait what the hell

#

there is a max string length? @quartz kindle

fierce ether
#

Unhandled promise rejection: Error: 502 Bad Gateway this means what?

stable nimbus
#

Bad gateway intent error

fierce ether
#

how do i fix?

stable nimbus
#

Dunno

earnest phoenix
stable nimbus
#
[2021-02-04 12:36:51.710]: ERROR Unable to load command test2.js: Error: Cannot find module '.C:\Users\Administrator\Desktop\betarpbot2\commands\Administration../../dispatch\test2.js'
Require stack:
- C:\Users\Administrator\Desktop\betarpbot2\base\Bot.js
- C:\Users\Administrator\Desktop\betarpbot2\rp.js
#

@quartz kindle This is my current error.

crimson vapor
#

ah yes windows

earnest phoenix
crimson vapor
#

yeah idk how to deal with windows paths

#

I use wsl

earnest phoenix
#

paths are the one linux thing i struggle with

cinder patio
crimson vapor
#

just under 2 ** 28 or something

#

I hit it ez

cinder patio
#

2^53 - 1

#

according to the specification

mellow kelp
#

why 53 tho

crimson vapor
#

o

#

hmm

mellow kelp
#

i find the lack of a power of 2 disturbing

crimson vapor
#

it is to the power of 2

#

53 times

mellow kelp
#

i mean 53

crimson vapor
#

o

cinder patio
#

2 to the power of 53

mellow kelp
#

i mean 53 isn't a power of two pEnSiVe

#

well time to google

stable nimbus
#

53 to the power of 2

#

Literally just reversed.

mellow kelp
#

that's also the max safe integer

earnest phoenix
mellow kelp
#

Number.MAX_SAFE_INTEGER is 2 ** 53

mellow kelp
#

json go brrr

crimson vapor
#

I didn't know there was

cinder patio
mellow kelp
#

meth

earnest phoenix
#

^^^

quartz kindle
earnest phoenix
#

meth class

crimson vapor
quartz kindle
#

ex dee

mellow kelp
#

ex deen't

earnest phoenix
quartz kindle
#

you have administration../

#

instead of administration/../

crimson vapor
#

Tim

mellow kelp
#

you're probably using string concatenation

crimson vapor
#

how can I check if an array is 1, 2, 3, 4, 5

mellow kelp
#

use path.join()

crimson vapor
#

path.resolve > *

mellow kelp
#

yeah or resolve

crimson vapor
#

idk how to use them well tbh

mellow kelp
#

resolve adds the whole path

#

join just

#

joins em

quartz kindle
mellow kelp
#

<Array>.every((e, i) => e === i + 1)

crimson vapor
#

sequence

#

1, 2, 3, 4, 5...

raw ledge
#

is there a modmail in this serever

crimson vapor
#

nope

raw ledge
#

any server that have it

#

any servers that u guys know who have it?

cinder patio
#

why are you looking for a server which has a modmail?

mellow kelp
#

spam KEKW

raw ledge
#

i need to show something

#

to my friend

#

please

#

anyone know

#

send the lin kto my dms

#

the link of the srver

#

server

earnest phoenix
crimson vapor
#

are you doing a class?

quartz kindle
crimson vapor
#

...

#

bruh

#

ex dee

mellow kelp
#

getters and setters are like functions but

earnest phoenix
mellow kelp
#

you don't call them

earnest phoenix
quartz kindle
mellow kelp
earnest phoenix
#

mka

crimson vapor
earnest phoenix
#

there now vscode has shut

mellow kelp
#

wonderful

crimson vapor
#

wait im big brain

#

I think

#

if lines = array.length + 3

#

then it has to be in order ish

#

actually no

#

idk

cinder patio
crimson vapor
#

42k chars

#

lol

#

can't paste it here

#

fuck its not formatted well

#

fixed

cinder patio
#

is the array always sorted

earnest phoenix
#

sometimes

#

js is pain

quartz kindle
#

wait... so the array is a sequnce of numbers ?

#

from 0 to 7334?

#

why exactly?

earnest phoenix
#

just curious

#

im new to fs stuff

#

is there like a way you can get an array of all the files in a dir?

#

(dont put too much effort into it, just give me something to look up)

quartz kindle
#

fs.readdir / fs.readdirSync / fs.promises.readdir

earnest phoenix
crimson vapor
quartz kindle
#

lol

crimson vapor
#

ig I just stopped it then

fierce ether
#

but the default is js // Autorole autorole: { enabled: false, role: null }, // Auto moderation automod: { enabled: false, ignored: [] },

#

so what am i doing wrong?

earnest phoenix
#

HALP

mellow kelp
#

have you tried reading the error

pale vessel
#

no

earnest phoenix
#

wtf is a fs.dirent

#

Ah I'm dumb I forgot

earnest phoenix
earnest phoenix
topaz stirrup
#

hellp how i can send to user just vote in dm using top.gg/sdk pls help me ?

slate oyster
stable nimbus
#

@quartz kindle I got it! I got it working!

earnest phoenix
earnest phoenix
#

try calm down and ask again

slate oyster
earnest phoenix
#

im cheaping out and using d.js

slate oyster
#

lol

topaz stirrup
earnest phoenix
slate oyster
#

Wait

#

You rigged that

earnest phoenix
#

don't call me out like that ๐Ÿ˜ญ

topaz stirrup
earnest phoenix
earnest phoenix
quartz kindle
earnest phoenix
#

close enough

quartz kindle
#

did you try the code from there?

topaz stirrup
#

no

earnest phoenix
#

then i would start with that and ask if you have any questions

pale vessel
mellow kelp
#

not if you're using the namespace iirc

earnest phoenix
#

yes

#

but i include the namespace and a ton of other ones when processing the script

mellow kelp
#

o

earnest phoenix
#

i cba to boot up my ide so you get a cat'd version

crimson vapor
#

kekw

midnight blaze
#

I cannot start my shard again. I get this error.

#

Anyone has an idea=

#

I used for index2 the most simple script..

crimson vapor
#

youve been ratelimited

midnight blaze
#

will that go over after a certain time?

solemn latch
#

iirc, its in the headers when the ratelimit expires.

midnight blaze
#

shit, really

#

ok thanks

fluid crown
#

Hihi! I was told to come here for advanced markdown development--the markdown cheat-sheet provided to me in support isn't really what I need. I'm trying to find ways to have automatic counters, coloured/animated backgrounds, etc. For example:
https://top.gg/bot/649604306596528138
or even something as simple as
https://top.gg/bot/646937666251915264

solemn latch
#

markdown doesnt do animations counters or anything like that

#

its just markdown

#

your looking for css

mellow kelp
#

you have to use css

#

the first link you sent uses an iframe to a custom website

river thistle
#

I was wondering the way I could implement a live web canvas editing system to allow customization of my welcome image (just like the one from https://probot.io). Anyone got an idea how I could do that ?

solemn latch
#

sure, just save any assets/config to a db, and use them when needed.

quartz kindle
#

save the final resulting image in your server

#

and have your bot use that

river thistle
#

I just found konvajs, sounds a good option to me

#

it has a drag and drop method etc.

#

guess I'll be using this

#

thanks alot

drifting wedge
#

when i try to print with color

#

?[31mhello?[0m ?[32mworld?[0m

#

why?

#

print(colored('hello', 'red'), colored('world', 'green'))

blissful coral
#

@delicate zephyr yo you here rn?

#

Actually wait I will just ask

#

So if I want to redirect on a app.get() to a localhost on the server (not the user's pc) can I do redirect('localhost:3029') or will that not work?

crimson vapor
#

I don't think you can do that

blissful coral
#

Is there a way to redirect to a localhost on the server

#

trying to get it to redirect to my mongo db link

crimson vapor
#

you could use nginx

#

just /mongodb goes to the correct link

#

here is luke to correct me

blissful coral
#

I use nginx

delicate zephyr
#

NGINX has proxy pass

blissful coral
#

oh

#

I don't even know how to use nginx chota set it up for me

delicate zephyr
#

Google time

blissful coral
#

pog

earnest phoenix
drifting wedge
#

anyone help me with colored text?

solemn leaf
#

What kind of colored text

#

there is alot with code blocks

blissful coral
#

None of my express routes are listening to 27017

#

My nginx is

misty sigil
#

Why would your Nginx listen to 27017

solemn latch
#

27017 isnt that commonly used for mongo/other db's

blissful coral
#

Yers

#

Yes

#

That's what I am using it for

#

nginx is redirecting the port to 27017 then I am pulling my mongo db from it

#

because that is what port mongo is on

misty sigil
#

but why

#

why would you proxy mongo

blissful coral
#

So I can connect to atlas on my windows pc from my server

#

to view data

misty sigil
#

couldn't you just do that without a proxy

blissful coral
#

How Thonk

#

Oh wait

#

I forgot to upload the new default

hasty mulch
#

Could someone explain to me why this works in @commands.command() but does this in @tasks.loop()? Unhandled exception in internal background task 'weatherembed_loop'. Traceback (most recent call last): File "/home/pi/.local/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop await self.coro(*args, **kwargs) File "/home/pi/Documents/Room_Sealer/cogs/room-sealer-weather.py", line 84, in weatherembed_loop alerts = res3['alerts'] if res3['alerts'] else [{'title': 'None'}] KeyError: 'alerts'

rigid sandal
#

SyntaxError: Unexpected string in JSON at position 186

#

Im trying to launch it with nodemon so i can have it restart as changes are made

quartz kindle
#

your json file is broken

slender thistle
#

Do I want to read code at 5 AM?

#

I don't think I do

hasty mulch
#

Reeeeeeeeeeeee

earnest phoenix
slender thistle
#

Don't question it

hasty mulch
hasty mulch
hasty mulch
# gilded olive Alerts dosent exist

{'country_code': 'US', 'lon': -73.71, 'timezone': 'America/New_York', 'lat': 40.72, 'alerts': [], 'city_name': 'Floral Park', 'state_code': 'NY'}

gilded olive
#

Interesting

#

Now idk if its cuz of an empty list lemme debug

#

nah thats not it, are you sure the api is returning that data?

#

Is it making a request every loop of the task?

#

A lot of factors too why it dosent exist

mellow kelp
#

wait is that a ternary operator?

earnest phoenix
#
client.getAllGuild = async () => {

        const req = await client.shard.fetchClientValues('guilds.cache')

        return req.array()
    }

How can i get an array from all server guilds?

gilded olive
mellow kelp
#

i mean

#

is that really how python does ternary operators

#

thingIfTrue if condition else thingIfFalse?

gilded olive
#

ternary operators in python are like
"Owner" if ctx.guild.owner else "Not Owner"

mellow kelp
#

ew

gilded olive
#

It's fine too me

mellow kelp
#

o

#

aight then

blissful coral
#

weird

gilded olive
#

Like a usecase would be

#some userinfo badge
staff = ":somestaffemoji:" if member.public_flags.staff else " "```
mellow kelp
#

yea i mean that's what a ternary is for

#

ternaries are cool

gilded olive
gilded olive
#

try printing it when you make the req

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

for whatever reason

gilded olive
lyric mountain
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#

See how to compile during runtime, I mean, if there are IDEs made in C# then it can compile during runtime

earnest phoenix
#

has anyone looked at implementing the whole / commands thing with the new update yet?

lyric mountain
#

You mean the slash commands?

earnest phoenix
#

yeah

lyric mountain
#

They're kinda superfluous actually

#

But yeah, some people did migrate to them here

earnest phoenix
#

yeah thought about adding a couple commands to mine

#

like /help /invite and like /report

lyric mountain
#

Note that it'll be a mess if more than one bot uses it

#

Because they will all appear together

crimson vapor
#

don't they separate?

earnest phoenix
#

it categorizes them i think

lyric mountain
#

Like
/help
/help
/help

earnest phoenix
crimson vapor
lyric mountain
#

That if you click, if you type it manually it's a mess

earnest phoenix
lyric mountain
#

Slashbot

#

Oddly specific

crimson vapor
#

agreed

earnest phoenix
lyric mountain
#

Still a mess

earnest phoenix
#

yeah

crimson vapor
#

I might implement it for mine if @slim heart adds it to his basic command handler like a smart dev should

earnest phoenix
crimson vapor
#

but he won't because he sucks

lyric mountain
#

Not going to make a Slashiro

#

The only pog feature is the forms one

earnest phoenix
#

lmao

wheat mesa
#
const blacklistedUsers = new Set()

module.exports = {
    name: 'blacklist',
    description: 'Blacklists a user from WaffleBot commands',
    args: true,
    staffOnly: true,
    CanMentionRole: false,
    execute(message, args) {
        const userMention = message.mentions.users.first()
        if(blacklistedUsers.has(userMention.id)) {
            blacklistedUsers.delete(userMention.id)
            message.channel.send(`User ${userMention.id} removed from blacklist.`)
        } else {
            blacklistedUsers.add(userMention.id)
            message.channel.send(`User ${userMention} added to blacklist`)
        }
    },
}
``` How would I be able to read the IDs in blacklistedUsers in my main index.js file?
crimson vapor
#

no not really

#

the way you are doing this isn't very good

#

it would be easier to do message.client.blacklistedUsers = new Set() but you need to deal with not creating a new set every command

#

also, a Set is not persistant

#

every time the bot restarts, the set would reset

#

assuming you aren't resetting it every time you run the command

wheat mesa
#

Yeah, I'm fine with it resetting. I'd rather not deal with any sort of database storage solutions as this is just a bot for my friends and I to use and mess around with

mellow kelp
#

but it doesn't work that way either

#

you're creating a new set every time the command is executed

wheat mesa
#

Oh

mellow kelp
#

absolutely no data is being saved, not even between commands

wheat mesa
#

I just split my bot into multiple command files so I'm new to this lol

crimson vapor
#

yea its best to use message.client.userBlacklist or something similar

solemn latch
#

^

crimson vapor
#

in the index.js you can <client>.userBlacklist = new Set()

#

then you should be able to access it from any command using message.client.userBlacklist

wheat mesa
#

Oh okay, thanks!

smoky herald
#

what happens if I reach 2500 guilds without sharding? will the invites get temporary blocked as before verification?

crimson vapor
#

iirc your bot won't receive the servers

solemn latch
#

pretty sure the bot wont even start

crimson vapor
#

I think it should start

#

just with 2500 servers

#

only

#

no?

solemn latch
#

i thought it errored requests for more than 2500 servers

crimson vapor
#

perhaps

solemn latch
#

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

smoky herald
#

anyways a big bad bad huh

crimson vapor
#

its best to shard at ~1500

#

then you are prepared for 2500 when it is required

smoky herald
#

I started today when it reached 2k, it gained 200 more since then and I'm lost af kekw

crimson vapor
#

what library do you use?

#

most have built in sharding iirc

#

like easy to use at least

#

ik djs does

smoky herald
#

discordjs, I got the sharding manager working, but I have pieces of code like setLeaderboards, which runs like 1000db reads almost at once each hour and I just can't make it run from one shard

crimson vapor
#

what db do you use?

solemn latch
#

is there a reason you need to do that many reads?
all my leaderboard stuff i would do in one request, and then cache it.

crimson vapor
#

I also do it in one request, granted its a find({ guildID }) using mongoose and mongodb

trim saddle
#

@crimson vapor you

crimson vapor
#

no

#

you

trim saddle
#

yes

#

me

crimson vapor
#

cringe trying to slut shame me

trim saddle
#

how do i do sharding

crimson vapor
#

umm

#

umm

#

add shard number to hello or something

smoky herald
#

it's vanilla MongoDB
wait, am I misunderstanding the definition of read? one request = one read?
I thought each document I get even as part of one query counts as read

crimson vapor
#

one request is one read

smoky herald
#

aka if I make a find request and limit it with 50 returns its 50 reads?

crimson vapor
#

no

#

one request, one read

smoky herald
crimson vapor
#

unless you are looping through a list of guild members

#

then that is many requests

solemn latch
#

which you probably shouldnt be doing

crimson vapor
#

1k reqests would take a few seconds with mongodb

#

I think

smoky herald
solemn latch
#

mongodb at full scale can handle millions of requests an hour iirc.

crimson vapor
#

full scale !== 1 process on a 2 core vps

#

full scale is like a full dedi just for the db

solemn latch
#

well, typically the main slowdown on mongo is memory isnt it ๐Ÿ‘€

smoky herald
crimson vapor
#

perhaps

#

idk

solemn latch
#

you could have one thread and 4+gb and still handle many hundreds of thousands of requests an hour.

#

on properly indexed data of course.

smoky herald
crimson vapor
#

idk if I index properly

#

I think mongoose does it for me but ive got no clue

solemn latch
#

it should

#

i am still learning mongo so ๐Ÿคทโ€โ™‚๏ธ

crimson vapor
#

idk mongo much

#

just basic enough to do what I need

solemn latch
#

pretty much what i use it for currently, just a quick throw in rather than spending the time to use sql.

crimson vapor
#

ah

#

can sql handle more than mongodb?

solemn latch
#

depends on the type of data, a lot of stuff is moving away from sql from what ive heard.

crimson vapor
#

ah

#

ive not done much research into databases

solemn latch
earnest phoenix
#

`@client.event
async def on_message(msg):

try:
     if msg.mentions[0] == client.user:

        with open("prefixes.jsno", "r") as f:
        prefixes = json.load(f)

        pre = prefixes[str(message.guild.id)]

        await msg.channel.send(f"My prefix for this server is {pre}")`

error :-

prefixes = json.load(f) ^ IndentationError: expected an indented block

#

what to correct there ?

crimson vapor
#

looks to me like your formatting maybe wrong

trim saddle
#

you didn't indent properly

earnest phoenix
#

oh

mellow kelp
#

gotta love file type acronyms

#

YAML - YAML Ain't Markup Language

#

TOML - Tom's Obvious, Minimal Languag

crystal wigeon
#

ghost pings

drifting wedge
#
FileNotFoundError: [Errno 2] No such file or directory: 'easy.txt'``` in py
earnest phoenix
#
const members = await message.guild.members.fetch();
    const memberlist = members.filter(x => x.user.flags != null).array();

    for (let index = 0; index < memberlist.length; index++) {
        const m = memberlist[index];
        await m.user.fetchFlags().then((flags) => {


            for (const flag of new UserFlags(flags)) {
             
            console.log(`${m.user.id} ${flag}`)
     
  
            }


        });

    }

This is only returning id of user with his flag, but i want to know how many user get a certain badge, how i can do that?

drifting wedge
#

but i have the file

#

so idk why

mellow kelp
#

maybe it's in a different directory

drifting wedge
#

nope

mellow kelp
#

i just had mario flashbacks KEKW

drifting wedge
#

its in literally same

trim saddle
drifting wedge
mellow kelp
#

does python read directories relative to the script or relative to the command's directory?

lyric mountain
earnest phoenix
#

flags: [UserFlags],

drifting wedge
trim saddle
#

oh lol i forgot not everything is raw

#

read the docs for user flags

drifting wedge
#

it thinks the file doesnt exist

#

but its literally in the same folder

lyric mountain
#

.txt danger danger

glacial pagoda
#
    name: 'memberinfo',
    description: "COMMANDS!",
    execute(message, args, Discord) {
        const usernamemention = message.author.username();
        const avatarmention = message.author.avatarURL();
        const idmention = message.author.id();
        const tagmention = message.author.tag();
        const nicknamemention = guildMember.nickname();
        const permmention = guildMember.permissions();
        const lastmessagemention = message.author.lastMessage();
        const Statusmessagemention = message.author.presence.status();
        






        const infoembed = new Discord.MessageEmbed()
        .setColor('RANDOM')
        .setTitle(`**${usernamemention}'s Information**`)
        .setAuthor(`${usernamemention}`, `${avatarmention}`, `${avatarmention}`)
        .setDescription(`Every Bit Of Detail About <@${message.author.id}>!`)
        .setThumbnail(`${avatarmention}`)
        .addFields(
            {name: '**Server Nickname:**', value: `**${nicknamemention}**`, inline: true},
            {name: '**User Tag:**', value: `**${tagmention}**`, inline: true},
            {name: '**User Id:**', value: `**${idmention}**`, inline: true},
            {name: '**Status:**', value: `**${Statusmessagemention}**`, inline: true},
            {name: '**Server Perms:**', value: `**${permmention}**`, inline: true},
            {name: '**Last Message:**', value: `**${lastmessagemention}**`, inline: true},
            )
      
        .setImage(`${avatarmention}`)
        .setTimestamp()
        .setFooter('I Told You, Every Detail...', `${avatarmention}`);

        message.channel.send(infoembed);
    }

    
}```
#

Help

#

How Do i Make It A Function?

lyric mountain
#

You don't

glacial pagoda
#

Or Fix

lyric mountain
#

Remove ()

glacial pagoda
#

Ok

lyric mountain
#

Remove from all your consts

glacial pagoda
#

kk

lyric mountain
#

None of them are functions

glacial pagoda
#

What Abotu Avatar?

lyric mountain
#

Not a func

#

Except the last one, MessageEmbed is indeed a func

glacial pagoda
#

Yesh

#

lol

#

Ok Im Restarting The Debugger

#

New Error

#

;-;

#

How Do i Fix This?

lyric mountain
#

You didn't define it

#

Do you know javascript?

glacial pagoda
#

Kinda

#

Im A Beginner

lyric mountain
#

Ok, lemme reword that question

#

Did u research about how javascript works or you're following a video/stackoverflow?

glacial pagoda
#

video and some research

#

on strings

lyric mountain
#

Thonk it might sound a bit rough, but try making simple applications before making bots