#development

1 messages Β· Page 1460 of 1

earnest phoenix
#

Just

#

function

river oracle
#

yeah it throws an exception if a member turned off dm but you can just continue the loop and dm other unprotected users

outer perch
#

k sir

hollow sedge
#

"unprotected"

#

you arent unprotected if you have random dms on

mellow kelp
#

not epic

hollow sedge
#

also yeah IK that

#

but you can still get ratelimited

river oracle
hollow sedge
#

yeah

river oracle
gilded olive
#

Unless the users consent to being mass dmed

hollow sedge
#

i literally said you'll get banned and ratelimited

earnest phoenix
#

DMing random members is not something you can easily get away with, users can report and bot and get both the bot and the owner's account suspended

gilded olive
#

The thing is tho

#

If the guild is huge

#

Youll get ratelimited

mellow kelp
#

node just

#

dies

#

too

earnest phoenix
#

The process won't die

mellow kelp
#

i mean if the guild is huge

hollow sedge
#

honestly i dont think its that big of a problem anyway

earnest phoenix
#

You'll just easily get ratelimited

mellow kelp
#

yea

hollow sedge
#

AT MOST you'll be dming/attempting to dm 10,000 users (i think thats the amount of requests you can make)

gilded olive
#

Yikers

#

With no cooldown?

outer perch
#
function getUserFromMention(mention) {
            if (!mention) {
                return message.reply(lang.error.noMention).then(msg => msg.delete({ timeout: 5000 })).catch();
            }

            const matches = mention.match(/^<@!?(\d+)>$/);

            if (!matches) return;

            const id = matches[1];

            return bot.users.cache.get(id);
        }

so doing this in a single file, I'll need to import message for example, right?

hollow sedge
#

yeah obviously its going to take some time to do that

river oracle
earnest phoenix
#

Max amount of requests you can make is unknown

#

It's dynamic

hollow sedge
#

oh

hollow sedge
#

whichever one comes first πŸ˜†

river oracle
gilded olive
#
REST:
        POST Message |  5/5s    | per-channel
      DELETE Message |  5/1s    | per-channel
 PUT/DELETE Reaction |  1/0.25s | per-channel
        PATCH Member |  10/10s  | per-guild
   PATCH Member Nick |  1/1s    | per-guild
      PATCH Username |  2/3600s | per-account
      |All Requests| |  50/1s   | per-account
WS:
     Gateway Connect |   1/5s   | per-account
     Presence Update |   5/60s  | per-session
 |All Sent Messages| | 120/60s  | per-session```
earnest phoenix
river oracle
#

possible banned from discord for life if you continue with a different bot account

earnest phoenix
gilded olive
#

D

#

F

mellow kelp
#

poggersn't

mellow kelp
#

oh i like regex

#

lets see

#

I think it would be /^<@!?[0-9]{18}>$/

queen needle
#

voltrex is regex god

hollow sedge
#

I hate regex

mellow kelp
#

a number from 0-9 repeated 18 times

hollow sedge
#

its so confusing

mellow kelp
#

with the enclosing stuff

river oracle
gilded olive
#

regex notlikethis notlikethis

earnest phoenix
mellow kelp
#

wait till you see the longest email validation regex

hollow sedge
#

lol i saw that when i was working on email validation

#

you can never truly validate emails tho

queen needle
outer perch
earnest phoenix
#

Best mention regex is

hollow sedge
queen needle
#

voltrex made a 3k line regex to detect if a user is on mobile on a website

earnest phoenix
#

/^<@!?(\d{17,19})>$/

mellow kelp
hollow sedge
#

wth

#

3k line??

mellow kelp
#

lmao yes

gilded olive
#

????

hollow sedge
#

i mean

#

generated tho right?

earnest phoenix
#

It's actually one line, just seperated

hollow sedge
#

lol

#

was it generated tho

queen needle
earnest phoenix
#

πŸ—Ώ I write every function in one line because of my good coding skills

#

Mad?

gilded olive
#

Spit

queen needle
mellow kelp
#

i used to write some really ugly one-liners

queen needle
#

all of voltrexs one liners are readable

earnest phoenix
#

My one liner codes are readable enough if you understand most of JS

river oracle
mellow kelp
#

well k

hollow sedge
#

also isnt that regex for checking the user agent

queen needle
outer perch
#

should I create a folder called functions for all the functions I have, or just leave them inside /source

queen needle
#

up to you

outer perch
hollow sedge
#

@earnest phoenix what is the purpose of that regex

river oracle
earnest phoenix
hollow sedge
#

lol

earnest phoenix
mellow kelp
#

ah yes

earnest phoenix
#

@outer perch I would suggest you leave them in the functions folder for cleaner stuff

#

πŸ—Ώ

mellow kelp
#

yet another symptome of the programmer syndrome we all have

outer perch
#

should /functions be inside /source or in root?

earnest phoenix
#

Yes

mellow kelp
#

all the code should go in /source

#

yea

outer perch
#

wot

hollow sedge
#

i just looked at the regex

#

most of that is actually ors

earnest phoenix
#

Bruh, did you just actually name it source

earnest phoenix
#

src > source

outer perch
#

it's the exact same thing xD

hollow sedge
#

oh yeah

mellow kelp
outer perch
hollow sedge
#

why not call Node.JS Node.Javascript then

earnest phoenix
lucid prawn
outer perch
earnest phoenix
outer perch
#

ikr, I used them a lot

hollow sedge
#

cmds
imgs
langs
src

outer perch
#

L m A o

hollow sedge
#

look at how much simpler it is

#

jk

mellow kelp
#

how about moving all images and langs to assets

hollow sedge
#

lol

mellow kelp
#

keep code in src

#

other files in assets

earnest phoenix
#

Bruh my username's acronym is VM, meaning virtual machine

outer perch
#

do you read 'el em ay oh' or 'le mao'?

mellow kelp
#

um

earnest phoenix
#

None

mellow kelp
#

neither

gilded olive
#

el em ay oh

earnest phoenix
#

Bismillah

outer perch
hollow sedge
gilded olive
#

We know

gilded olive
outer perch
mellow kelp
#

cri

outer perch
#

cuz I didn't let it

hollow sedge
#

you have to turn on the thing

#

i dont understand how people can live without file extensions

mellow kelp
#

imagine editing a minecraft server without extensions on

outer perch
#

I don't even know why it's now showing, I know I forgot but

#

why

mellow kelp
#

server .properties

hollow sedge
#

literally everything looks the same

#

and im not going to be a regular user

#

looking at the icon

earnest phoenix
#

This man just exported every property of the guild

#

Chill out

hollow sedge
#

lol

lucid prawn
earnest phoenix
#

As i said, the guild is not in the cache

gilded olive
#

"How to put guild in cache discord.js"

twin urchin
#

fetch it

earnest phoenix
#

No need to fetch a guild

#

Every guild is cached by default

#

I suspect the ID is wrong

#

Or the bot isn't in that guild

gilded olive
#

Wouldnt that throw a different error

earnest phoenix
#

Nope

#

It returns undefined when the guild isn't in cache

#

Same as the other managers

gilded olive
earnest phoenix
#

Uhh, error for what

south sinew
#

you may as well use fetch, it'll just grab from the cache if it's there otherwise it'll send an api request

earnest phoenix
#

No

#

You're using it correctly

#

Just the ID is incorrect

gilded olive
earnest phoenix
#

Nah

gilded olive
earnest phoenix
#

I mean, he's just trying to get the guild so why would that throw a different error if the bot isn't in that guild

gilded olive
#

I wouldnt say the guild is more "undefined" more like its none

#

But hey Shrug

earnest phoenix
#

Something "none" is undefined in JavaScript

#

Lmao

gilded olive
#

Oh πŸ—Ώ

#

Why tho πŸ—Ώ:moyai:

mellow kelp
#

πŸ—Ώ

earnest phoenix
#

πŸ—Ώ Because JavaScript isn't Python

pure lion
#

Javascript null = no exist

gilded olive
#

Ik but still

#

Like

#

WhyπŸ—Ώ

pure lion
#

It's nul

#

l

#

Null means no

#

!

earnest phoenix
#

Literally

mellow kelp
#

in javascript there's null and undefined

earnest phoenix
#

null == undefined

pure lion
#

Basically it has no value

mellow kelp
#

null is like

#

a bit more defined that undefined

pure lion
#

yeah

#

Just a bit

#

Wait

#

You're that troll

#

:(

#

Stinky

mellow kelp
#

wat

pure lion
#

The readme troll

mellow kelp
#

LMAO yes

pure lion
#

You're not funey>(

outer perch
#

I'm still questioning
should /lang, /fonts and /img be also inside /src?

earnest phoenix
#

typeof(undefinded) = null

mellow kelp
#

nope

gilded olive
#

assets/

mellow kelp
#

those aren't code

#

src is for source code

outer perch
#

aight

mellow kelp
#

ight

outer perch
#

what about /commands

earnest phoenix
#

If it needed for the src to run then put it in src

mellow kelp
outer perch
earnest phoenix
#

Both null and undefined means void, wanna know the difference between null and undefined?

undefined (Daniel) - null (Cooler Daniel)

outer perch
#

just to organize

outer perch
mellow kelp
earnest phoenix
#

But can someone explain

distant cobalt
#
const avatar1 = await Canvas.loadImage(ship1.displayAvatarURL({ format:'png' }));```
earnest phoenix
#

nulldefined (coolest daniel)

#

@outer perch yeah

outer perch
#

star it

#

now

distant cobalt
#

how do i fix that

earnest phoenix
#

Why the fuck is the type of null

mellow kelp
earnest phoenix
#

object

distant cobalt
#

wowie

#

lol

mellow kelp
#

wat

#

um

#

"visible confusion"

pure lion
#

I feel like there's a third one

distant cobalt
#

lol

pure lion
#

Null, undefined and something else

mellow kelp
#

void

earnest phoenix
#

@outer perch basiclly

mellow kelp
#

never

#

unknown

earnest phoenix
#

Anything that the src need to work should be in src for organizing

pure lion
#

Oh

#

Any kinda counts

mellow kelp
#

yea

pure lion
#

Kinda

earnest phoenix
#

No

mellow kelp
#

i still dont understand never tho

earnest phoenix
#

void is undefined

outer perch
distant cobalt
earnest phoenix
#

πŸ—Ώ My guy just tried to get array of users from a collection

#
const [ship1, ship2] = message.mentions.users.first(2);```
distant cobalt
#

ok

pure lion
#

Wait

#

@earnest phoenix

earnest phoenix
#

Hmm

pure lion
#

Is there a way I could just do that for the entire len

#

.first(collection len)

earnest phoenix
#

len?

#

Oh

pure lion
#

Len

earnest phoenix
#

Yes

pure lion
#

gth

#

Pog

earnest phoenix
#

<Collection>.array()

distant cobalt
#

thanks it works

pure lion
#

Wait is that a function

#

The more you know

earnest phoenix
#

Yes

outer perch
#

I am once again askin'

#

.json files should be inside /data or something?

mellow kelp
#

what are they used for?

outer perch
#

for certain commands

#

like fact.js has an array of facts in facts.json

earnest phoenix
#

Well yea they can go in data directory

mellow kelp
#

yeah i guess

outer perch
#

like, I have itemlist.json, where everything which can be bought in shop.js is stored

#

seems like data to me πŸ™‚

#

well, I guess I have nothing left to organize

wind vault
#

How do I make the servers command to show how many servers the bot is on? in discord.py

trim saddle
#

@quartz kindle wake up and stop eating maple syrup

#

@wind vault len(bot.guilds)

wind vault
#

Can you give me a complete script from the bot.command please, I don't know how to use the guides

earnest phoenix
#

nobody will spoonfeed you

#

"amazing docs"

#

well

#

better than most mmLol

wind vault
#

None have worked for me so far, but I will try them

earnest phoenix
#

you should stop copypasting then

#

docs exist as a reference exactly for this reason

wind vault
#

JAJJAJAJAJAJAJA

#

Yes

wind vault
earnest phoenix
#

tfw you blame your incompetency to navigate a doc site on the actual docs

#

Well can't blame discord.py users, it's docs is like

#

...

#

i never used dpy or python for that matter

#

and i could find what i'd need for their goal

#

within a minute

mellow kelp
earnest phoenix
#

I mean, it's docs is not that bad but a little harder to navigate through rather than discord.js one

#

πŸ—Ώ

wind vault
#

Why?

outer perch
#

today is my day of questions, holy shit I'm already tired of questioning, but I need to

mellow kelp
#

poggers

wind vault
#

iΒ΄m from colombian,

#

And

#

I live in U.S now

outer perch
#

2 questions

#

any guide on file organization you may know?

#

and

#

how do I know/remove unused Node modules?

earnest phoenix
#

ctrl+backspace until the line is gone

merry shuttle
#

or

#

npm remove module

outer perch
#

but, how do I know if it's not used?

earnest phoenix
#

do you not use an editor?

outer perch
#

like, any command, any tip?

earnest phoenix
#

your editor should highlight modules that are used

outer perch
#

I mean, remove the dependencies too

earnest phoenix
#

so just go through your code and uninstall modules you don't need

outer perch
#

thought there was a lazy way 😭

earnest phoenix
#

there's maybe a vscode addon πŸ€·β€β™‚οΈ

outer perch
earnest phoenix
#

what do you mean by that

#

just organize it however you want

mellow kelp
#

pretty much yes

#

but try to put stuff in src/

outer perch
#

not that

#

like

#

naming

#

and ideas

mellow kelp
#

well

#

i like to use idk-what-this-case-was.js

#

unless im working with react but thats another thing

outer perch
#

wat

mellow kelp
#

nvm the second one

#

i meant

lyric mountain
#

Intellij does that

#

Unused modules will become grey

mellow kelp
#

oh cool

outer perch
#

god Sora

earnest phoenix
#

so does vsc

lyric mountain
#

Idk if community edition has that tho

mellow kelp
#

is that with the free intellij?

earnest phoenix
#

that's why i asked do you not use an editor

mellow kelp
#

dang its with the paid version

outer perch
lyric mountain
#

I said idk

outer perch
#

but never noticed any grey

lyric mountain
#

Give it a try

earnest phoenix
#

vsc highlights unused modules

#

well

#

greys it

#

anything unused is greyed out

outer perch
#

in the hierarchy?

mellow kelp
outer perch
#

cuz, everything is grey

earnest phoenix
mellow kelp
#

i think he meant unused imports

#

yea

lyric mountain
outer perch
#

no

mellow kelp
#

for entire node packages you should manually check

lyric mountain
#

But yeah, community is mostly java

outer perch
#

imagine I installed moment.js

mellow kelp
#

you can search stuff like = require('your-package-name')

outer perch
#

but I am not using it

lyric mountain
#

I mean, if your project is open source you can just request OS dec license

mellow kelp
lyric mountain
#

It's free

mellow kelp
#

oh cool

#

gotta try it some day

lyric mountain
#

All you need is a 3 month old open-source project

outer perch
lyric mountain
#

I got mine 1 year ago

mellow kelp
outer perch
#

how do I remove only, unused node_modules

mellow kelp
#

to search for times when you require the module

#

get it?

outer perch
#

ok I found something

#

npm prune

#

command in the console

mellow kelp
#

whats that for tho

outer perch
#

run the npm prune command to remove unused or not required node packages from Node.js.

mellow kelp
#

hmm

#

sounds kinda too good

#

but try it

sudden geyser
mellow kelp
#

yea

sudden geyser
#

If you have a student pack you can get it for free.

mellow kelp
#

thats why i use vscode for non-java stuff

#

its intellisense is pretty good tho ngl (intellij)

lyric mountain
sudden geyser
#

What is OS dev

lyric mountain
#

Open-source dev

#

You need a 3 month old project which you work actively at, and have major understanding of it

#

One of the perks of using github ig lul

mellow kelp
#

bruh what would it be of coding without github

sudden geyser
#

but what is OS dev in relation to πŸ˜–

lyric mountain
#

If you have an open-source project, you're an open-source dev

#

OS = open-source

mellow kelp
#

but it has to be 2 months old and active

#

dang

lyric mountain
#

Or operational system depending of context

lyric mountain
mellow kelp
#

dang it

sudden geyser
#

yes I understand that, but what does having 3 months of an old project relate to.

lyric mountain
lyric mountain
#

Idk their reasons

mellow kelp
#

some guy once wanted to share code with me

#

the guy freaking sent a zip file

sudden geyser
lyric mountain
#

project.rar
final-project.rar
fixed-final-project.rar
now-i-got-it-fixed-final-project.rar

mellow kelp
#

final-final-final-project.rar

lyric mountain
mellow kelp
#

final-final-final-with-build.rar

lyric mountain
#

Everything you can eat

sudden geyser
#

ah

outer perch
#
npm WARN gumball-and-penny@1.0.0 No repository field.
npm WARN gumball-and-penny@1.0.0 No license field.
#

what does this mean?

mellow kelp
#

wat

earnest phoenix
#

you have no license and repo field in your package.json

lyric mountain
#

Did u configure repository and license fields?

mellow kelp
#

well it means that package doesn't have a license or repository linked to its package.json

lyric mountain
#

Do it then

outer perch
#

why would I do that btw?

lyric mountain
#

Idk, it's asking for it

outer perch
#

it's my bot's package file

lyric mountain
#

Did u copy it from somewhere else?

#

Don't lie

earnest phoenix
#

it's meant for open source projects

outer perch
#

I don't want my bot open source

earnest phoenix
#

so don't create the fields

#

lol

outer perch
lyric mountain
#

The code

earnest phoenix
#

it's just a warning

#

not an error

outer perch
lyric mountain
#

That's what I'm asking

#

Was it you who wrote ur bot?

outer perch
#

yes

#

100%

#

k I'm lyin' 98%

lyric mountain
#

Remove those fields then

outer perch
#

some tips and functions are from StackOverflow

#

xD

earnest phoenix
#

const brr = [null, undefinded]
if (brr.contains(null));

#

hey

#

how can i make my bot listen ONLY the response after the command

#

?

#

.awaitMessage

mellow kelp
#

you can use message collectors to wait for the next message on the channel

#

yea

earnest phoenix
#

?

#

No

#

how?

#

Read docs lol

#

link

#

Google

mellow kelp
#

found the best github repo ever

odd stratus
#

Does anyone know how I can update everything in one MongoDB column at once? Trying to change these strings to numbers but there's too many

hollow sedge
#

you can just do $set with the dict of the fields and their new values

#

so something like this:

user = user_col.find_one({"user_id" : ctx.author.id})
       
reward = randint(50, 100)
user["balance"] += reward

user_col.update_one({"user_id" : ctx.author.id}, {"$set" : user})
#

Keep in mind this is Python syntax

#

@odd stratus

odd stratus
#

Mkay

main elk
rustic nova
#

commands is not iterable

#

you cannot loop through it

terse finch
#

can i do both

client = discord.Client()
bot = commands.Bot(command_prefix="$")
...
...
client.run(DIS_TOKEN)
bot.run(DIS_TOKEN)
``` is one better than theother? which one should i be doing
earnest phoenix
#

im guessing this is dpy

terse finch
#

ye

earnest phoenix
#

if you want to use dpy commands, use the Bot class

#

Bot is a subclass of Client

terse finch
#

do both on_message and on_ready work with bot

earnest phoenix
#

yes

#

from the docs:
This class is a subclass of discord.Client and as a result anything that you can do with a discord.Client you can do with this bot.

terse finch
#

so bot is inheritated from Client

earnest phoenix
#

correct

terse finch
#

so do i change all my @client.event to @bot.event?

earnest phoenix
#

if you name it bot, yes

terse finch
#

sweet

#

thanks

hoary junco
#

Can anyone hel

#

Can anyone help me

sudden geyser
#

Explain your issue please

hoary junco
#

I made this button something like this <a href=β€œmybotlink” class=β€œbutton”>Invite me</a>

#

But the text is not showing

sweet matrix
#

hello

hoary junco
sweet matrix
earnest phoenix
#

Webhook

sweet matrix
#

message thanks for voting only

earnest phoenix
#

Yes

sweet matrix
#

how ?

hoary junco
#

I made this button something like this <a href=β€œmybotlink” class=β€œbutton”>Invite me</a>

But the text is not showing

earnest phoenix
#

@sweet matrix google "how to make webhook server"

#

As its hard for me and idk how t9 do it

#

Apso search how webhoom work too

celest sphinx
hoary junco
#

what about my issue 😭

sweet matrix
#

webhooks

#

discord webhooks

#

?

#

or no

earnest phoenix
#

No

hoary junco
#

actually ignore that

#

So

#

I did .p { color: #00ed3f }

#

And it didn’t work

#

Anyone know why

earnest phoenix
#

Md not html

#

Wait wait

#

Nvm

hoary junco
#

k also did ; to it and other things

#

But it doesn’t work :/

#

I did that to

umbral zealot
#

you need to use awaitReactions instead

earnest phoenix
#

ok thank u

#

@umbral zealot no tbh

umbral zealot
#

?

earnest phoenix
#

It should be outside of command

umbral zealot
#

no...

earnest phoenix
#

Its reaction role

umbral zealot
#

it should be a reaction collector.

#

I mean there's other ways to deal with this

earnest phoenix
#

Its reaction role

umbral zealot
#

but really the important thing is to never have an event handler inside another

#

the rest comes later

hoary junco
#

Hmmm

#

Why isn’t this working

#

So any idea why?

earnest phoenix
#

what's your issue in the first place

terse finch
#

so im trying to do a simple ping command with discord.py

@bot.command()
async def ping(ctx):
    if ctx.author.id == ME:
        await ctx.channel.send(f"pong")
#

when i run my command $ping

#

it doesnt work

#

but other aspects of it work

#
bot = commands.Bot(command_prefix='$')
``` bot declaration
earnest phoenix
#

Idk about Python but

#

You used commands.Bot

#

Oh wait

#

Nvm

terse finch
#

yeah

gilded olive
#

@terse finch can i see the traceback?

#

Ah i see

#

Its just ctx.send

#

Also i hope ME is an int of your id

terse finch
#

there is no traceback. but the issue was i had a on_message and forgot to add the bot.process_commands() there

#

also yeah its an int of my id its just there

#

as place holder

gilded olive
#

Ahhhh that would do it

terse finch
#

nope not working lol

gilded olive
#

Traceback this time?

terse finch
gilded olive
#

You spelt ping wrong

sudden geyser
#

so you typed it wrong

terse finch
#

no i didnt tho

sudden geyser
#

doubt

terse finch
sudden geyser
#

If you run it again are you 100% sure that error is happening when it shouldn't.

#

also you probably don't need the bot.process_commands(...) at the bottom.

terse finch
#

100% sure

#

hold on

#

yeah restarting doesnt do anything

#

any other suggestions

gilded olive
#

And theres no traceback you say?

terse finch
#

so its processing the command its just not sending to the channel

gilded olive
#

ctx.send

#

if you wanr a channel

#

get the object using get_channel

hoary junco
#

Not ctx.channel.send

gilded olive
#

I told him that

terse finch
#

ctx.send() doesnt do anthing either

hoary junco
gilded olive
#

Whats dist?

terse finch
#

my id

hoary junco
#

Let me see the me var

gilded olive
#

Can i see the variable?

terse finch
#

yeah 1 sec

#

109314596484939776

hoary junco
#

109314596484939776

#

Hmmm

hoary junco
gilded olive
#

Wait a minute

terse finch
#

its just a fun bot for a private server

#

i got it figured out

#

my key file i import all the private stuff

#

wasnt saving on the server properly

gilded olive
#

πŸ€”

terse finch
#

so reuploading the file to my server fixed it

#

which is weird

#

but whatever

#

thanks for the help everyone

gilded olive
#

This is why i use cogs

#

on_message dosent f you up there

gilded olive
terse finch
#

cogs?

#

like what?

gilded olive
#

if the person isnt what you specify you can return None

terse finch
#

yeah i get that

#

how do i fix that?

gilded olive
#
else:
      return None```
#

On mobile so indents may be wrong

terse finch
#

yeah

#

ok

gilded olive
terse finch
#

have any resources i can read on that?

gilded olive
terse finch
#

thanks

gilded olive
#

Like for me

#

Let me get something

#
    def load_extensions(self, reraise_exceptions: bool = False) -> Tuple[Tuple[str], Tuple[str]]:
        """Loads all extensions
        Parameters
        ----------
        reraise_exceptions : bool, optional
            Weather or not to silently continue on error, or raise the exception, by default False
        Returns
        -------
        Tuple[Tuple[str], Tuple[str]]
            A tuple containing a tuple of extensions that loaded successfully,
            followed by a tuple of extensions that failed to load
        Raises
        ------
        commands.ExtensionFailed
            There was an error during loading the extension, you can use the 'original'
            atrribute of this exception ot get more details
        commains.NoEntryPointError
            The extension didn't have a setup function visible at the global scope level
        commands.ExtensionAlreadyLoaded
            The extension was already loaded
        commands.ExtensionNotFound
            The path provided contained no valid extensions
        """
        loaded_extensions = set()
        failed_extensions = set()
        for file in map(lambda file_path: file_path.replace(os.path.sep, '.')[:-3], glob(f'{self.extensions_dir}/**/*.py', recursive=True)):
            try:
                self.load_extension(file)
                loaded_extensions.add(file)
                print(f'{file} loaded')
            except Exception as e:
                failed_extensions.add(file)
                print(f"Failed to load cog {file}")
                if not reraise_exceptions:
                    traceback.print_exception(type(e), e, e.__traceback__)
                else:
                    raise e
        result = (tuple(loaded_extensions), tuple(failed_extensions))
        return result```
#

this is something where if there is something like -> cogs/folder/file.py it would load it

#

My bot is in a class but you could fix that obviously

#

and a quick real life example of a cog would be something like ```py
import io

import discord
from discord.ext import commands
from gtts import gTTS

class TTS(commands.Cog):
def init(self, bot):
self.bot = bot

@commands.command(aliases=["t2s", "text2"])
@commands.guild_only()
async def tts(self, ctx, *, text: str):
    mp3_fp = io.BytesIO()
    tts = gTTS(text, lang="en")
    tts.write_to_fp(mp3_fp)
    mp3_fp.seek(0)
    await ctx.send(file=discord.File(mp3_fp, "text.mp3"))

def setup(bot):
bot.add_cog(TTS(bot))```

#

hopefully this helps

#

(what that does is take text and output it as tts to a file then sends it, feel free to use it) <- @terse finch

hoary junco
#

I prefer not to use cogs because you have to put a lot of unnecessary stuff

sudden geyser
#

What alternative do you use?

#

Cogs handle a lot for you.

hoary junco
#

Just put it in one file

gilded olive
#

Put a lot of unecessary stuff???

#

Like what???

hoary junco
#

Werite the class tts(commands.cog)

gilded olive
#

Yea?

hoary junco
#

Import write __ initial and setup

gilded olive
#

what?

sudden geyser
#

I don't want a 300 line bot.py file 😟

hoary junco
#

why

gilded olive
#

So youd rather have 1 file with 7k lines of every command

hoary junco
#

mine is already over 300

gilded olive
#

Rather than a few files

#

Seperated by 1k lines

#

For the desired category

sudden geyser
#

It's good practice to split up your code into multiple files.

#

It's a matter of organization and the structure of your code.

earnest phoenix
#

It breaks every time someone joins it doesnt give or remove the role any ideas?

sudden geyser
#

Instead of having a giant glob you have to visit and have your IDE load.

#

which will be hard for other developers to read your code, but if you're the only one working on it, you probably don't care.

earnest phoenix
#

(sorry for interupting :( )

sudden geyser
#

why are you still adding new events when a command is run

earnest phoenix
#

?

sudden geyser
#

the client.on() stuff. is execute not called when a user runs a command?

#

e

earnest phoenix
#

well this is a rr

sudden geyser
earnest phoenix
#

it works but i have to retpye it

#

oh

#

but where do i put awaitReactions

sudden geyser
#

Read the docs on how to use it

carmine summit
#

@earnest phoenix That code only runs if someone sent a message.

#

you cannot put an event inside an event

earnest phoenix
#

so what do i need to do

carmine summit
#

Move the event outside

earnest phoenix
#

so below const verifyNotifyRole = message.guild.roles.cache.find(role => role.name === "Members");

carmine summit
#

No

#

Outside the message evnt

earnest phoenix
#

im brain dead rn

#

ohhhhhhhhhhhhhhhhhhhh ok

near stratus
#

Why am i getting this error ? TypeError: Cannot read property 'message' of undefined

carmine summit
#

@near stratus because you don't show us your code

near stratus
#

My code is```js
help() {
try {
ref.embedDes(this.message, "Welcome mortals", helpMessage.normal);
} catch (err) {
console.log(err);
}
}

near stratus
carmine summit
#

its either helpMessage or this is undefined

near stratus
carmine summit
#

Then define it

near stratus
#

but i defined it in my class constructor```js
constructor(message, args, client) {
this.message = message;
this.args = args;
this.client = client;
}

slender thistle
#

COGS ARE GREAT FOR PROPER ORGANIZATION

carmine summit
#

Smh

near stratus
carmine summit
#

Where is this located

#

Nvm

#

JDA

earnest phoenix
carmine summit
earnest phoenix
#

ok

#

tysm

terse finch
gilded olive
#

Oh well in that case

#

1 file is fine

terse finch
#

yeah file size is probably gonna be at most 75 lines of code

gilded olive
#

I see

terse finch
#

2-3 commands, a couple fun things for roles 🀑 and just a simple loging file

gilded olive
#

logging? Hmmm

terse finch
#

like a log of peoples roles that are added and removed along with some other stuff

#

as well as a simple ban log

gilded olive
#

ahhh

#

well youd have to add that in yourself

#

Tip to ban its just member.ban()

#

Extra tip roles is either audit log entries or on_member_update

#

But id prefer on_member_update

opal plank
#

Alright, library finished. 2 days of work and its done

earnest phoenix
#

any ideas?

module.exports = {
    name: 'vrr',
    description: "Sets up a reaction role message!",
    async execute(message, args, Discord, client) {
                const channel = '||';
                const verifyNotifyRole = message.guild.roles.cache.find(role => role.name === "Members");   

                const verifyNotifyEmoji = 'βœ…';

                let messageEmbed = await message.channel.send(embed);
                messageEmbed.react(verifyNotifyEmoji);

                let embed = new Discord.MessageEmbed()
                    .setColor('#77dd77')
                    .setTitle('Verify')
                    .setDescription('Please react to the message to gain access to the server.');


                client.on('messageReactionAdd', async (reaction, user) => {
                    if (reaction.message.partial) await reaction.message.fetch();
                    if (reaction.partial) await reaction.fetch();
                    if (user.bot) return;
                    if (!reaction.message.guild) return;

                    if (reaction.message.channel.id == channel) {
                        if (reaction.emoji.name === verifyNotifyEmoji) {
                            await reaction.message.guild.members.cache.get(user.id).roles.add(verifyNotifyRole);
                        }

                    } else {
                        return;
                    }

                });
opal plank
earnest phoenix
#

it breaks everytime someone joins the server

earnest phoenix
opal plank
#

hehe thanks

#

dont

#

do that

earnest phoenix
#

do what?

opal plank
#

dont put a listener inside a command

#

BAD BAD BAD idea

#

thats how you get leaks

earnest phoenix
#

?

opal plank
#

i assume you know whats an event listener

earnest phoenix
#

no i am kinda new to this

opal plank
#

everytime you call the command, you'll add another listener

#

run the command 11 times and you'll get yourself a node crash

earnest phoenix
#

oh

opal plank
gilded olive
#

Oh

#

Thats nice

opal plank
gilded olive
#

I wanna try making my own lib one day

#

Actually

#

Imma try that tomorrow

opal plank
#

cant wait to flex on this tomorrow once the whole 9 people who are working on ourcord are online

earnest phoenix
opal plank
#

imma bonk on every single one of them for publishing a broken module

opal plank
#

not literally

earnest phoenix
#

the entire thing or just that part

opal plank
#

you gotta fix a lot of stuff, no

earnest phoenix
#

oh

opal plank
#

from reaction you can get the message, user, and all that crap you want

#

also

#

Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:

  • proper syntax
  • debuging code
  • basic features (vars, arrays, objects, functions)
  • read and understand docs
  • nodejs module system

As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.

Here are good resources to learn both Javascript and NodeJS:

Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/

Please take a couple of weeks/months to get acquainted with the language before trying to make bots!

#

take a look at that ^^

earnest phoenix
#

ok

#

discord out ranged again?

opal plank
#

wot

sudden geyser
opal plank
#

cuz i have a tag

#

you dont think someone as lazy as me would actually search in chat for it right?

sudden geyser
#

mmlol

opal plank
#

thats kinda funny though, how'd you even find that out?

earnest phoenix
#

can anyone say what will be the first code to the bot to come online

earnest phoenix
#

then

gilded olive
#

So he lead me there instead

opal plank
#

you do know what i did, no?

gilded olive
#

nope

opal plank
#

check who's making this

#

and what it does

#

if you implementing genshin impact onto your bot, you welcome for making your life 10000x easier lmao

#

i just finished implementing a queue for ratelimiter and a constructor promise

earnest phoenix
#

ye

#

you're welcome

gilded olive
#

Ayo

opal plank
#

going to be pushing an update tomorrow hopefully on the npm module

#

but that version already is functioning fine, just doesnt have the extra features i added

#

the github repo is the updated one if you wish to check the new updates and add it yourself until the main branch catches up

inner stump
#

Hey guys

hollow sedge
#

Is it typical to name everything index?

opal plank
#

yes

inner stump
#

Have you seen the new bot i made

opal plank
#

ads

earnest phoenix
#

nobody cares

hollow sedge
#

Lol that's weird but cool

inner stump
#

I am asking

gilded olive
#

no

hollow sedge
#

Of course we have

gilded olive
#

No one did

#

Oh

#

Well

#

Yea we did

hollow sedge
#

its the best bot on discord

#

Wdym you haven't

gilded olive
#

My b

#

πŸ˜ͺ

inner stump
#

Its currently on early access

opal plank
#

mee6 who? too small for frenzy bot

hollow sedge
#

I can't wait for the release! @inner stump

opal plank
#

@inner stump how old are you?

inner stump
#

13 and a half

gilded olive
#

Pog

opal plank
#

hmmm aight

hollow sedge
#

and a half

#

pls don't forget the half guys

earnest phoenix
#

mom im not a kid anymore 😠

gilded olive
opal plank
#

but anyway, check that if you plan on implementing that API onto your bot Ghoul

inner stump
#

Its basically like a among us bot

opal plank
#

should make dealing with that api a lot easier

inner stump
#

I have a testing server

gilded olive
#

Yea ill check it out

hollow sedge
#

dude thats totally original

opal plank
#

not another among us bot

hollow sedge
#

wdym

#

WE NEED MORE AMONG US

opal plank
#

more corona bots

#

more music bots

#

more among us bots

#

more level up system bots

hollow sedge
#

wonder why there arent too many genshin impact bots πŸ€”

inner stump
hollow sedge
#

oh god

gilded olive
#

Just waiting till someone makes an actual game

opal plank
#

cuz the few people who know how to interact with genshin are busy coding stuff thats more worth

hollow sedge
#

oh lol

opal plank
#

i have one of the few genshin bots out there

earnest phoenix
#

wow an embed 😱

#

dude you're a genius!

gilded olive
#

WOW

hollow sedge
#

wait how did you do that

#

thats gamechanging

opal plank
#

and currently just finished writting one of the few wrappers for a genshin API

inner stump
#

does gifs work

gilded olive
#

😱😱😱

hollow sedge
#

dude you should try it

#

let us know

hollow sedge
#

none of us have worked with an embed before

celest sphinx
hollow sedge
#

this is new ground

earnest phoenix
#

LMFAO

hollow sedge
#

OH NO

gilded olive
#

LMFAOOOOOOOO

#

😭😭😭😭

inner stump
#

i know

gilded olive
#

Top 10 anime plot twists

opal plank
#

oh god

inner stump
#

but its actually a code website

opal plank
#

botghost of course

hollow sedge
#

no

#

botghost is not coding

#

wait doesnt it actually have a gui

inner stump
#

umm

hollow sedge
#

how can that be considered coding in the slightest

opal plank
#

botghost is telling your users you dont give 2 fucks about your bot

inner stump
#

atleast i have a good bot

hollow sedge
#

no you dont

#

it doesnt even do anything

opal plank
#

^^

gilded olive
#

No you dont

opal plank
#

a among us bot with an empty embed command

gilded olive
#

Isnt bot ghost just clicking what command you want

hollow sedge
#

yeah

#

im pretty sure

weary widget
inner stump
hollow sedge
#

probably need to include GET params @weary widget

#

are you using aiohttp

opal plank
#

a among us bot that does moderation

#

makes sense

gilded olive
#

use aiohttp

hollow sedge
#

LOL

weary widget
hollow sedge
#

ok you can pass in parameters to the url then

#

look at the docs

inner stump
#

do i pass

hollow sedge
#

for this website

#

api*

weary widget
#

ok

#

in the URL?

inner stump
#

do i pass the fake bot test

weary widget
#

I tried that

opal plank
hollow sedge
#

yeah it uses GET

gilded olive
#

Use aiohttp.
requests and urllib are blocking. Do not use these libraries within your asynchronous code.
(http://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean)

discord.py uses aiohttp, so it should already be installed. An example of code using aiohttp and discord.py:

async with aiohttp.ClientSession() as cs:
    async with cs.get('https://httpbin.org/json') as r:
        res = await r.json()  # returns dict
        await ctx.send(res['slideshow']['author'])β€Š```


For more help, see aiohttp's documentation: http://aiohttp.readthedocs.io/en/stable/
hollow sedge
#

they are using aiohttp lol

opal plank
#

if you applied to get your bot on top.gg, chances are it wont pass. it needs at least 5 custom commands iirc to even pass

gilded olive
#

I take tags and copy paste

#

Brrrr

hollow sedge
#

lol

gilded olive
hollow sedge
#

i mean the docs are really nice

#

@weary widget

#

im taking a look at them rn

weary widget
#

ok

sudden geyser
#

You need to apply the avatar, username and comment query parameters.

weary widget
#

yea I know

inner stump
#

i know im a bad developer. i just wanna say this, i dont ||actually|| know scripting

hollow sedge
#

are you a developer?

opal plank
#

let me get you docs

#

nobody starts knowing all dude

#

we all start somewhere

weary widget
#

yea

gilded olive
#

how to learn how to code as an ex google ex facebook ex netflix ex apple tech lead

#
  1. You dont
opal plank
#

@inner stump
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:

  • proper syntax
  • debuging code
  • basic features (vars, arrays, objects, functions)
  • read and understand docs
  • nodejs module system

As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.

Here are good resources to learn both Javascript and NodeJS:

Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/

Please take a couple of weeks/months to get acquainted with the language before trying to make bots!

hollow sedge
#

reported for spam

gilded olive
#

^

inner stump
#

ill learn later

hollow sedge
#

will you tho

inner stump
#

yes

hollow sedge
#

promise me

celest sphinx
inner stump
#

i promise'

hollow sedge
#

pinky promise

inner stump
#

yes

hollow sedge
#

ok

#

we good then

gilded olive
#

Coding is fun when you know what youre doing

weary widget
#

the basics of code is more useful than discord bot

gilded olive
#

Other than that i wanna kms

hollow sedge
#

nah

#

that part is fun too

weary widget
gilded olive
weary widget
#

dani

hollow sedge
#

without that frustration you cant feel as satisfied when it all begins to work

gilded olive
#

Feel like youre on crystal meth

weary widget
#

TRUE

hollow sedge
#

exactly

#

wait how would you know

tribal siren
#

bot.user.hasPermission() is wrong

hollow sedge
#

πŸ‘€

tribal siren
#

what is correct?

weary widget
#

has_permission

gilded olive
hollow sedge
weary widget
#

oh

tribal siren
#

ye

weary widget
#

I don't know js😎

gilded olive
#

^

hollow sedge
#

well you should πŸ™‚

weary widget
#

I know πŸ˜”

hollow sedge
#

not necessarily node

#

but JS

gilded olive
#

I know blobpain

hollow sedge
#

its pretty useful

weary widget
#

but python is ez

#

and simple

hollow sedge
#

uhh

#

its also slow

tribal siren
gilded olive
#

What

hollow sedge
#

thats not true?

tribal siren
#

ye that's not

hollow sedge
#

you can make a ton of stuff with python

weary widget
#

I mean it's not as effective as js

hollow sedge
#

in fact that makes it easier

weary widget
#

but it's fine for what I do