#development

1 messages · Page 1459 of 1

earnest phoenix
#

You change the bot's prefix on top.gg by changing the bot's prefix on top.gg

#

Big brain

mellow kelp
#

so how do we contribute to ourcord

#

can i edit the docs

hard ivy
#

Small How ؟

crimson vapor
#

no im doing that

earnest phoenix
#

Add anything that's helpful

mellow kelp
#

k

opal plank
#

@earnest phoenix

earnest phoenix
#

I didn't publish it to npm, either mattthew did or krista

#

We need to work on it a lot

hard ivy
#

How to make a small writing of the word ؟

crimson vapor
#

@earnest phoenix what are the defualts for caching?

#

true or false?

opal plank
#

remove duplicate typings for ts
remove the package from public, its not ready nor you should be posting unfinished packages
add colaborator keys for the ones who will be editing it, keep main repo in github, not npm
remove those shit commits and add some consistency onto it with proper descriptive commits
Dont push shit that doesnt work, if its work in progress, keep it stashed in local and merge them once its fully finished

If yall keep going like that its going to turn into a meme and bring bad pr dude, its already bad as is

river peak
#

hehe

crimson vapor
#

wait its null

earnest phoenix
#

@crimson vapor The caching properties are not defined by default on startup so it's undefined which would also be considered as false

crimson vapor
#

they are null no?

opal plank
#

@earnest phoenix if yall got a discord server you guys talk into, send that message above there

outer perch
#

well, this ain't about development, kinda is and not at the same time:
I like Firefox, and how it consumes less RAM than Chrome, but Chrome has more ways to see customized JS. My PC isn't good enough to handle Chrome + Discord + Spotify + League of Legends all open

#

but with Firefox it handles quite nice

earnest phoenix
outer perch
#

is there any alternative for a browser?

mellow kelp
#

well

#

make your own browser

opal plank
#

then foward that to the members who are actively contributing, thats constructive critisicm,

misty sigil
#

we do and I was against publishing it

earnest phoenix
misty sigil
#

or was it someone else

outer perch
#

I need another answer 😦

crimson vapor
#

matthew

#

what is the default for caching? false?

#

since it is a boolean in ts

earnest phoenix
#

It's an optional property which is not defined on start up, so undefined or in other words false

crimson vapor
#

alr

#

making pr

#

wait

#

should I add myself to collaborators?

#

or nah since im not working

earnest phoenix
#

The users with write access will add you to contributors so not needed

#

Man

crimson vapor
#

alright

#

time to pr

earnest phoenix
#

I really wonder if we should start rewriting the whole thing

mellow kelp
#

dang

restive furnace
#

discussion about ourcord here? cool

mellow kelp
#

well maybe not throw away everything

earnest phoenix
#

Yea i mean like, as we first knew what was wrong when starting the project now we would know how to make it better

#

Or maybe

crimson vapor
#

where do I add the emojis?

#

im confused

earnest phoenix
#

What emojis

crimson vapor
earnest phoenix
#

I didn't make that pull request template so idk, i think misly made that template

#

But it's optional

crimson vapor
#

made pr pog

pale vessel
earnest phoenix
#

Million

mellow kelp
#

loggers

earnest phoenix
#

Null => null

crimson vapor
#

bruh

#

should I add a commit to the pr

earnest phoenix
#

Yea, just edit the original commit

summer torrent
#

where is intents

crimson vapor
#

idk im not dev

earnest phoenix
#

The lib is not ready yet, so it's not there

crimson vapor
#

ok I edited the file

earnest phoenix
#

Guys, its weird. i can't use commands, only moderation commands.
But my code is ok

merry thunder
#

My bot started to lag out of nowhere. What can I do? I can't find the problem either.

merry thunder
#

nott

#

16ms

#

we use azure

#

900mb download 1200 upload

#

imposible

past needle
#

if you're running the bot locally it's shard may disconnect and won't respond until it's connected again

#

q-p

#

but yea it's only a possiblity

merry thunder
#

@past needle guilds appear incomplete in stats if not connected

eternal osprey
#

hey guys!

past needle
#

hey

eternal osprey
#
 if (name != "Egg") {
              let var5 = Boolean(raid.ex_raid_eligible)
              if (var5 = "true"){
              let varz = reactionEmoji9
            
             
              
              if (var5 = "false"){

                let varz = 
              
            
              let text = `**${name}** | **${varz}**  | **Boosted: **` + `${weatherString}` + "\n"```so i have written this code. I want the varz to not show if it isn't an ex raid. How would i do this?
#

because now it checks whether it is true, and it will send an emoji. If it is false i want it to be blanco.

#

i thought about writing: let varz = null

crimson vapor
#

@misty sigil make an ourcord discord server please

eternal osprey
crimson vapor
misty sigil
#

read me

#

the readme

crimson vapor
earnest phoenix
eternal osprey
#

appreciate it.

crimson vapor
#

also you don't need to check if it is equal to "true" since you can just do if(varz)

eternal osprey
#

okay but,.. how do i set it to 0 once it is false?

glass nacelle
earnest phoenix
#

Please help

eternal osprey
#
if (name != "Egg") {
              let var5 = Boolean(raid.ex_raid_eligible)
              if (var5 == "true"){
              let varz = reactionEmoji9
            
              }
              else if (var5 == "true"){
                let varz = ""
              
                }

  
              
              
              let text = `**${name}** | **${varz}**  | **${weatherString}**` +  + "\n"```this would ofc give varz is undefined.
#

but i don't know how to do it otherwise?

crimson vapor
#

define it before the if statements

eternal osprey
#

i cannot wrap the one statement in the other.

crimson vapor
#

let varz = ''

eternal osprey
#

ooowh okay got it

brittle copper
#

Ah yes

#

You just gotta love the API

#

Thanks, discord

crimson vapor
glass nacelle
merry thunder
#

Hello, this question will be a little more outside the code, but. About two weeks ago my bot started to be added to big servers eg 247k etc. recently an incredible lag appeared, even if the bot ping shows 16, it has an incredible delay. We cannot tolerate even a 1 second delay in our bot because everything happens in seconds, does anyone know or guess what a solution or problem is? Because we cannot detect the problem.

pale vessel
#

wait what why did they define the type again in the websocket file?

#

shouldn't you just import it from the d.ts file?

brittle copper
eternal osprey
# glass nacelle You don't need to redefine it remove the let just change the value varz = ""

okay, i have issues fixing it tho. js if (name != "Egg") { let varz = "" let var5 = Boolean(raid.ex_raid_eligible) if (var5 == "true"){ let varz = reactionEmoji9 let text = `**${name}** | **${varz}** | **${weatherString}**` + "\n" + `**${raid.gym_name}**` + "\n" + `*${lat1}, ${lng1}*` + "\n" + `**${reactionEmoji5}: ** ${raid.level} | **${reactionEmoji4}: ** ${raid.cp}` + "\n" + `**Distance From Last Raid: ** ${lastcoordinatez}` + " KM" + "\n" + `**${reactionEmoji7} **${move1[1]} | ${move1[2]}` + "\n" + `**Starts: **${getFormattedTime(raid.raid_start)} | **Ends: **${getFormattedTime(raid.raid_end)}\n` + `${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}ⓅⓄⓀⒺⒽⓊⒷ${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}` + "\n" let rawdata = fs.readFileSync("./data.json"); let channel1= JSON.parse(rawdata); let msg = await message.channel.send(text); await msg.react(reactionEmoji1); await msg.react(reactionEmoji2); await msg.react(reactionEmoji3);} } look, the problem is that it doesn't send an embed at all. It comes because the if statement is wrapping the whole code. I have no clue how to fix it.

pale vessel
#

@opal plank Don't know ts but you should do this right? Instead of declaring it again in the websocket.ts file #development message (context: ourcord)

fierce ether
#
                        <li class="nav-item">
                            <a class="nav-link" href="/me">Profile</a>
                        <li class="nav-item">
                            <a class="nav-link" href="/dashboard">Dashboard</a>
                        <li class="nav-item">
                            <a class="nav-link" href="/servers">Servers</a>
                        <li class="nav-item">
                            <a class="nav-link" href="/authorize/logout">Logout</a>
                        </li>
                    </ul>
            <% }``` how do i remove the points
opal plank
glass nacelle
pale vessel
#

oh

#

so you have to declare it twice

#

as d.ts is entirely separate?

eternal osprey
#

would work right

#

because it has a space

eternal osprey
#

with nothing to it

#

still didn't work

#

even after addin text it did not work

glass nacelle
eternal osprey
#

i fixed it already

#

thanks for the help bro

restive furnace
mellow kelp
#

they add types to stuff like javascript files

misty sigil
#

d.ts is types

mellow kelp
#

thats how you get intellisense and type checking for js packages

brazen lion
#

Setting up bot keeps telling me Something went wrond while seting you role?

#

wrong

opal plank
#

its types for ts to be imported

restive furnace
#

ah ok

#

i thought u were talking about discord**.ts**

pale vessel
misty sigil
#

bro

pale vessel
#

JSON?????????

misty sigil
#

JSON?!

sudden geyser
#

Json > JSON

pale vessel
#

is it not Promise<Object>

misty sigil
#

or Promise<Array>

pale vessel
#

Promise<Array<Object>>

#

ol;fjd

odd stratus
#

Just started happening randomly

novel snow
#

how would I be able to add a message to a embed

#

so like

#

message here
{cool af embed here}

#

so it can mention things'

odd stratus
#

message.channel.send("text here", embed)

novel snow
#

oh ok thx

distant cobalt
#
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'approve.png')
const embed = new Discord.MessageEmbed()
    .setTitle(`${canvaUser.tag} got approved!`)
    .attachFiles([attachment])
    .setColor('#72e429')
message.channel.send(embed)``` why isn't the image in the embed? How do i fix this?
mellow kelp
#

you gotta set the image to the attachment

#

i think it was something like

#

.setImage('attachment://approve.png')

distant cobalt
#

oh ok

#

i'll try that

mellow kelp
#

aight

distant cobalt
mellow kelp
#

oh dang

#

hmm

jaunty marlin
#

How get approval

distant cobalt
jaunty marlin
#

in how many days get approval

#

Ok

mellow kelp
#

about 1 month

distant cobalt
#

about 9 days

mellow kelp
#

wait what

#

mine took 1 month KEKW

distant cobalt
#

for me it kinda took 9

#

lol

mellow kelp
#

dang u lucky

jaunty marlin
#

15 year old child bot

distant cobalt
distant cobalt
#

anyways, help my embed problem

outer perch
#

using dotEnv, got this: UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.

stable eagle
#

Grundstücksvehrkehrsgenehmigungszuständigkeitsübertragungverordnung

mellow kelp
#

it loads the .env file

mellow kelp
#

so

#

um

distant cobalt
#

my code

eternal osprey
outer perch
#

🤦🏻‍♂️

mellow kelp
#

oh lmao

eternal osprey
#

i can't find where they are getting boosted from.

distant cobalt
#
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'approve.png')
const embed = new Discord.MessageEmbed()
    .setTitle(`${canvaUser.tag} got approved!`)
    .attachFiles('attachment://approve.png')
    .setColor('#72e429')
message.channel.send(embed)```
mellow kelp
mellow kelp
#

wait

#

the embed is not like that lmao

jaunty marlin
distant cobalt
pale vessel
#

you just had to add setImage()

jaunty marlin
#

I am indian

distant cobalt
pale vessel
#

don't change that attachFiles()

jaunty marlin
distant cobalt
#

i did set image

mellow kelp
#
// More stuff
.attachFiles([attachment])
.setImage('attachment://your-file.png')
#

with both

pale vessel
#

yes

distant cobalt
#

oh okay

outer perch
#

workin' fine now @mellow kelp. Time to test on Live ver.

mellow kelp
#

thats poggers

jaunty marlin
#

Self role

mellow kelp
jaunty marlin
#

Of bot

mellow kelp
#

you just gotta wait

jaunty marlin
#

Ok

#

Which country form you

distant cobalt
pale vessel
#

poggers

mellow kelp
#

noice

#

yea poggers

outer perch
mellow kelp
#

yea

outer perch
#

👌🏻

pale vessel
#

you leaked your token

#

not epic man

mellow kelp
#

poggersn't

outer perch
#

btw, do I need quotes for the value?

mellow kelp
#

nah

outer perch
#

I did it in the local file

mellow kelp
#

if you do they will actually appear on the variable itself

#

.env files have that syntax

#

but on heroku you set it just like that

outer perch
#

well I tried to execute the Dev version with and without quotes

#

it's working the same

mellow kelp
#

well quotes are more for readability

#

i use them too on .env files

eternal osprey
#

i tried parsin the json but i couldn't find anythin useful.

odd stratus
mellow kelp
#

wdym the boosted?

jaunty marlin
#

Can I give link to of my bot to bot viewer se in this server

eternal osprey
mellow kelp
odd stratus
#

It was working before I ended up doing some configuring

#

How do I authenticate it?

jaunty marlin
#

$$help

mellow kelp
#

just make the connection

#

make sure nothing is queried before the connection is complete

tardy hornet
#

i already have FFmpeg installed on my pc

#

and its still saying

eternal osprey
tardy hornet
#

Error: FFmpeg/avconv not found!

pale vessel
#

when did you install it

tardy hornet
#

long time ago

eternal osprey
#

and i wanna know how they check the weather and add boosted.

odd stratus
pale vessel
#

try typing ffmpeg in your command line

#

if it works then it's installed properly

tardy hornet
#

wdym

pale vessel
#

literally that i guess

tardy hornet
#

just to put ffmpeg in the code?

odd stratus
#

Just run ffmpeg in console

tardy hornet
eternal osprey
crimson vapor
tardy hornet
#

i did

#

from their web

pale vessel
thick gull
#

add a path to

#

console

#

system variable

#

i think

crimson vapor
#

fucking powershell

mellow kelp
#

lmfao

eternal osprey
tardy hornet
#

i did that as well

crimson vapor
#

you shouldn't have to

eternal osprey
crimson vapor
#

what is this

summer torrent
#

anyone know what is !.

eternal osprey
#

and they are adding weathername + (boosted)

#

and i am trying to figure out how to check if it's boosted.

tardy hornet
#

i downloaded it, it shows it in the modules and still not working

crimson vapor
tardy hornet
#

i had to restart vsc after installing

#

so it will show it

crimson vapor
eternal osprey
tardy hornet
#

and

eternal osprey
#

i only want the boosted to show

tardy hornet
#

from the web

eternal osprey
#

used 2 links from where they are taking info from

crimson vapor
#

try reinstalling ffmpeg

eternal osprey
#

no variable named boosted

#

because the weather doesn't concern me, i just need the boosted text to show.

odd stratus
#

@tardy hornet Try npm i ffmpeg-static

crimson vapor
#

thats not how you install ffmpeg

odd stratus
#

That's how I did it so yes that's one way

#

lol

crimson vapor
#

hmmmm

eternal osprey
odd stratus
#

Idk though its weird since there's different ways

eternal osprey
#

it will also directly save it in your dir.

crimson vapor
#

the error is "FFMPEG/something else not found"

#

right

little anvil
#

anyone know how to make the embed thumbnail show as the pinged user is discord.py?

odd stratus
#

If you're on Linux you gotta install ffmpeg with sudo apt or something

eternal osprey
#

anyways, none knows the answer yet on the question i sent?

pale vessel
#

Nope

tardy hornet
#

do i need to do

#

npm i discordjs/opus

#

@odd stratus

#

as well

odd stratus
#

🤔

#

Idk

#

Try without it and see if it works

tardy hornet
#

ty worked

odd stratus
#

Nice

little anvil
#

omg

#

anyone know how to make the embed thumbnail show as the pinged user? (discord.py)

eternal osprey
#

you could just hit npm install tbh

pale vessel
#

Get the pinged user

little anvil
#

does anyone do python

eternal osprey
elder loom
#

i did

#

do python

#

give me a second

little anvil
#

alr

pale vessel
#

Get the mentioned member

odd stratus
#

Why the hell does this still happen even though I authenticated it

#

._.

little anvil
#

are they in the correct directory

#

and it may be a windows problem

#

LMAO

elder loom
#

yeah i had some random problems today too

#

which worked before

#

randomly stopped working

#

didn't update anything

#

just stopped working 😳

little anvil
#

that happens

#

it's weird

elder loom
#

i replaced 'const' with 'var' and it worked

#

strange

little anvil
#

lol

elder loom
#

but before it worked with const

#

very strange

little anvil
#

maybe the language you were using had changes

little anvil
crimson vapor
quiet arch
#

hey guys when i deploy i get an error on heroku

pale vessel
#

"Prebuilt detected"

#

You committed your node_modules folder?

little anvil
quiet arch
#

w8

#

yes

#

i did

little anvil
#

heroku should be easier to work with

#

and support more languages

pale vessel
quiet arch
#

o

#

huh

opaque laurel
#

bad practice to commit your node_modules. package-lock.json and yarn.lock are accepted.

quiet arch
#

so i just delete it?

pale vessel
#

Yes

quiet arch
#

k

pale vessel
#

Heroku installs modules for you

quiet arch
#

o

#

ok thx

#

but i cant

#

ok i did

#

i just cant delete the folder

little anvil
#

what should i put here to fix message.mentions[0].mentions

opaque laurel
#

what does vscode tell you? there should be a little modal that shows up explaining the error (correction: not a modal but a "popup")

sudden geyser
#

hover over the red underline

quiet arch
#

yay thank u flaxepe

#

but flaze now when i do

node .```
it says this
#

PS D:\github\pepe-bot> node .```js

internal/modules/cjs/loader.js:834
throw err;
^

Error: Cannot find module 'discord.js'
Require stack:

  • D:\github\pepe-bot\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (D:\github\pepe-bot\index.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ 'D:\github\pepe-bot\index.js' ]
    }
    PS D:\github\pepe-bot> ```
pale vessel
#

discord.js needs to be inside dependencies

quiet arch
#

where?

#

o

pale vessel
#

Can you find a file named package.json?

quiet arch
pale vessel
#

yes

quiet arch
#

so how do i put it

pale vessel
#

Do you know what module your bot needs?

opaque laurel
#

how have you installed your packages? have you used npm or yarn

quiet arch
#

nope

pale vessel
#

Check your code

#

Use npm i <module name>

#

That will put the module in your package.json folder

#

But you shouldn't push node_modules to your repo

#

For example npm i discord.js

quiet arch
#
}
PS D:\github\pepe-bot> npm i <module name>
At line:1 char:7
+ npm i <module name>
+       ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported
pale vessel
#

That will add discord.js to your dependencies in package.json

quiet arch
#

?

#

o

distant cobalt
opaque laurel
#

the <module name> was a placeholder

pale vessel
#

That is not where the error came from

#

Check line 384

solemn latch
quiet arch
#

thx

opaque laurel
#

for the "module name" of the installs you will make

quiet arch
#

so i have ```js
client.on('voiceStateUpdate', (oldMember, newMember) => {
let newUserChannel = newMember.channelID;
let oldUserChannel = oldMember.channelID;

if(newUserChannel === "779010277823741972") 
{ 
    
    console.log((`${newMember.member.user.username} Joined the vc `))
    client.channels.cache.get('783262951955103754').send((`<@&785521742030307328> ${newMember.member}  (${newMember.member.user.username}) has knocked on the office door`))    }
else{
    console.log("Left vc")
    client.channels.cache.get('783262951955103754').send((`no one opened the door so ${newMember.member}  (${newMember.member.user.username}) left`))    }

}

)```

but i wanna make it if i drag it it doesnt send the ```js
client.channels.cache.get('783262951955103754').send((no one opened the door so ${newMember.member} (${newMember.member.user.username}) left)) }

elfin tulip
#

is it possible to "Replace the last result"?

nimble mantle
#

@clever pewter

pale vessel
#

If you drag, newMember won't be null

quiet arch
#

ok but u have to explain me how that works

pale vessel
#

When a member DC, newMember will be null since they left the VC

#

If you drag a member, newMember will exist since they only changed VC

quiet arch
#

o

pale vessel
#

So you would only say "member left" when newMember is null

quiet arch
#

aight

#

thx

midnight viper
#

So that picture is my console. Im trying to make a music bot well command I have it working joining the vc and then it stops working I Have ffmpeg installed but idk
ty in advance

const Discord = require('discord.js');
const { connect } = require('snekfetch');
const ytdl = require('ytdl-core');

module.exports = {
    name: 'play',
    description: 'play command',
    execute(message, args){
        const voiceChannel = message.member.voice.channel
        if(!voiceChannel) return message.channel.send("You need to be in a channel to play music")
        const premissions = voiceChannel.permissionsFor(message.client.user)
        if(!permissions.has('CONNECT')) return message.channels.send('I dont have the permissions to connect to the voice channel')
        if(!permissions.has('SPEAK')) return message.channel.send('I dont have permissions to speak in the channel')

        try{
            var connection = await voiceChannel.join()
        }catch (error){
            console.log(`There was an error connecting to the voice channel: ${error}`)
            return message.channel.send(`There was an error connecting to the voice channel: ${error}`)
        }

        const dispatcher = connection.play(ytdl(args[1]))
        .on('finish', () => {
            voiceChannel.leave()
        })
        .on('error', error => {
            console.log(error)
        })
        dispatcher.setVolumeLogarithmic(5 / 5)
    } 
}
pale vessel
#

Make your execute function async

#

async execute

midnight viper
#

wait wat where do i put it?

pale vessel
midnight viper
#

ah ty

eternal osprey
#
 let z = ""
            if (isRaidBoosted(raid)) {
              let z = "BOOSTED"
           let text = `**${name}** | **${varz}**  | **${z}**` + "\n"
                + `**${raid.gym_name}**` + "\n"
                + `*${lat1}, ${lng1}*` + "\n"
                + `**${reactionEmoji5}: ** ${raid.level}  |  **${reactionEmoji4}: ** ${raid.cp}` + "\n"
                + `**Distance From Last Raid: ** ${lastcoordinatez}` + " KM" + "\n"
                + `**${reactionEmoji7} **${move1[1]}  | ${move1[2]}` + "\n"
                + `**Start: **${getFormattedTime(raid.raid_start)} | **Ends: **${getFormattedTime(raid.raid_end)}\n`
                + `${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}ⓅⓄⓀⒺⒽⓊⒷ${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}` + "\n"
                let rawdata = fs.readFileSync("./data.json");
                let channel1= JSON.parse(rawdata);
              let msg = await message.channel.send(text);
              await msg.react(reactionEmoji1);
              await msg.react(reactionEmoji2);
              await msg.react(reactionEmoji3);
     }
            }
}``` it doesn't send the text because of the if let z statement
#

does anybody know how to fix this

distant cobalt
# solemn latch whats on line 384
const user1 = message.mentions.users.first()
const user2 = message.mentions.users[1]``` i want the author to mention 2 people. how?
midnight viper
#

how do u get ffmpeg on heroku?

quiet arch
#

but now the stuff doesnt work

misty sigil
mellow kelp
quiet arch
#

am i doing something y this keeps hapening

midnight viper
#

well im fucked

mellow kelp
#

here it is

crimson vapor
mellow kelp
#

add that to buildpacks

misty sigil
#

It won’t work well

crimson vapor
#

should work

misty sigil
#

I’m warning you

distant cobalt
mellow kelp
#

it worked for me tho

distant cobalt
#

it works

crimson vapor
#

never destructured an array before KEKW

mellow kelp
#

array destructuring is pretty epic

#

check this out

crimson vapor
#

I do it for objects

mellow kelp
#
const [command, ...args] = message.content.split(/\s+/);
little anvil
#

how do we

#

print the server thumbnail

little anvil
#

in a command

quiet arch
#

so i have ```js
client.on('voiceStateUpdate', (oldMember, newMember) => {
let newUserChannel = newMember.channelID;
let oldUserChannel = oldMember.channelID;

if(newUserChannel === "779010277823741972") 
{ 
    
    console.log((`${newMember.member.user.username} Joined the vc `))
    client.channels.cache.get('783262951955103754').send((`<@&785521742030307328> ${newMember.member}  (${newMember.member.user.username}) has knocked on the office door`))    }
else{
    console.log("Left vc")
    client.channels.cache.get('783262951955103754').send((`no one opened the door so ${newMember.member}  (${newMember.member.user.username}) left`))    }

}

)```

but i wanna make it if i drag it it doesnt send the ```js
client.channels.cache.get('783262951955103754').send((no one opened the door so ${newMember.member} (${newMember.member.user.username}) left)) }

eternal osprey
#
 let z = ""
            if (isRaidBoosted(raid)) {
              let z = "BOOSTED"  
              let text = `**${name}** | **${varz}**  | **${z}**` + "\n"
                + `**${raid.gym_name}**` + "\n"
                + `*${lat1}, ${lng1}*` + "\n"
                + `**${reactionEmoji5}: ** ${raid.level}  |  **${reactionEmoji4}: ** ${raid.cp}` + "\n"
                + `**Distance From Last Raid: ** ${lastcoordinatez}` + " KM" + "\n"
                + `**${reactionEmoji7} **${move1[1]}  | ${move1[2]}` + "\n"
                + `**Start: **${getFormattedTime(raid.raid_start)} | **Ends: **${getFormattedTime(raid.raid_end)}\n`
                + `${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}ⓅⓄⓀⒺⒽⓊⒷ${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}${reactionEmoji6}` + "\n"
                let rawdata = fs.readFileSync("./data.json");
                let channel1= JSON.parse(rawdata);
              let msg = await message.channel.send(text);
              await msg.react(reactionEmoji1);
              await msg.react(reactionEmoji2);
              await msg.react(reactionEmoji3);
          }
}
}```this does't send the text. It is coming from the  if (isRaidBoosted(raid). If i close the }, it will send, but as you can see i moved it all the way under the code.
quiet arch
#
else if (!newMember){
        console.log("Left vc")
        client.channels.cache.get('783262951955103754').send((`no one opened the door so ${newMember.member} (${newMember.member.user.username}) left`))    }

    }
 )```
eternal osprey
#

it doesn't send anymore

quiet arch
#

and this doesnt work

earnest phoenix
#

Hey, so i was just coding my bot. The code worked just fine minutes ago. I did npm i that updated some packages and i started getting this error.
Half of my code just doesn't work now and throws this error 😦

crimson vapor
#

do you use mongoose?

earnest phoenix
#

yeah

crimson vapor
#

make sure you're not assigning a variable to the wrong type

earnest phoenix
#

where?

#

In schema or the code

#

only change in the schema i've made today is this and i don't see any issues with it

crimson vapor
#

when you save a doc

earnest phoenix
#

ah

#

let me see

midnight viper
#

I go here and then paste the link for ffmpeg on heroku right? am I dumb or am I super dumb

earnest phoenix
#

no?

earnest phoenix
hot topaz
outer perch
#

created methods in single files should be called into other files with module.exports right? JS btw

earnest phoenix
#

Aight yeah i think i messed up my document

#

I tried in another guild with another guild config document

#

it worked fine

crimson vapor
#

module.exports => export
require() => get

outer perch
#

ikr

earnest phoenix
#

Deleted and created the document all working! Thanks million

crimson vapor
mellow kelp
#

loggers

cinder patio
#

Typescript is acting crazy... it says "player is possibly undefined" but it cannot be...

mellow kelp
#

module.exports and interopability is very confusing lmao

mellow kelp
#

you sure Player always returns a player?

crimson vapor
#

new Player() might return null likely

mellow kelp
#

Or undefined

#

that makes the type Player | undefined

cinder patio
#

It's a constructor... constructors always return an instance of a class...

mellow kelp
#

Yea i guess

cinder patio
#

it's just wrong

crimson vapor
#

can't you return something else in it

mellow kelp
#

but isnt it possible otherwise

cinder patio
#

no

mellow kelp
#

well

crimson vapor
#

hmm

mellow kelp
#

id say just add a ? beween player and id

#

or a !

crimson vapor
#

are the typings correct?

cinder patio
#

yea

#

Player is a class I created so yea

little anvil
#

anyone know how to send the discord server's thumbnail in an embed? discord.py

crimson vapor
#

check the docs

cinder patio
#

oh 🤦‍♂️

mellow kelp
#

hmm

#

just add a !

#

null assertion operator

#

player!.id

cinder patio
#

player.id might be undefined and I cannot compare undefined to a number

mellow kelp
#

well

#

the magic of javascript

#

im testing and it always returns false lmao

#

so in case user is undefined i guess youre good to go anyways

main trench
#

Yes quick.db can push arrays however when words are pushed its already in an array form so if I push 2 words it doesn't separate them so I would need to say "word1,word2,word3" for the bot to detect it

little anvil
main trench
#

Maybe but I'm not sure how

#

Since by default the db logs them like that

#

They get logged as [ 'word1', 'word2' ]

#

And I guess the word no gets logged as null for some reason

little anvil
#

do yall know how to send server icons in embed

midnight viper
#
2020-12-16T19:30:44.280859+00:00 app[Worker.1]: (node:4) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
const Discord = require('discord.js');
const { connect } = require('snekfetch');
const ytdl = require('ytdl-core');

module.exports = {
    name: 'play',
    description: 'play command',
    async execute(message, args){
        const voiceChannel = message.member.voice.channel
        if(!voiceChannel) return message.channel.send("You need to be in a channel to play music")
        const permissions = voiceChannel.permissionsFor(message.client.user)
        if(!permissions.has('CONNECT')) return message.channels.send('I dont have the permissions to connect to the voice channel')
        if(!permissions.has('SPEAK')) return message.channel.send('I dont have permissions to speak in the channel')

        try{
            var connection = await voiceChannel.join()
        }catch (error){
            console.log(`There was an error connecting to the voice channel: ${error}`)
            return message.channel.send(`There was an error connecting to the voice channel: ${error}`)
        }

        const dispatcher = connection.play(ytdl(args[1]))
        .on('finish', () => {
            voiceChannel.leave()
        })
        .on('error', error => {
            console.log(error)
        })
        dispatcher.setVolumeLogarithmic(5 / 5)
    } 
}

Im just trying to fix my .play command I think its .play command idk if its play or stop command

crimson vapor
#
  1. get the server icon
#
  1. send it in the embed
#

check the docs

little anvil
#

gosh damnit ive tried

#

why do you think im asking yall

crimson vapor
#

good point

main trench
#

In js its message.guild.iconURL so it may be similar to that for py? @little anvil

#

@crimson vapor do you have any ideas for how to solve my problem?

crimson vapor
#

split the words before you push to the db

main trench
#

Hmm

#

That may work

little anvil
main trench
#

But it may log them as an array again

#

So splitting before logging wouldn't work

#

I need to split during the fetching part

little anvil
#

yeah

main trench
#

Gotta figure that out somehow

little anvil
#

thats the issue

crimson vapor
#

split them then forEach push

main trench
#

Aight

little anvil
#

How do we split with embeds?

#

I forgot I haven't had to do it in a while

main trench
#

Whatcha mean?

little anvil
#

this is an embed

#

I'm trying to make the thumbnail into the top right corner

#

but it wont make it the server icon

#

and it's recognizing guild as apart or icon_url

main trench
#

What do the docs say?

little anvil
#

the docs don't really say things about it

main trench
#

Hmm

little anvil
#

they just mention the variable once or twice

slender thistle
#

Try to str() icon_url

little anvil
sudden geyser
#

show your code pls

quiet arch
#

so i have ```js
client.on('voiceStateUpdate', (oldMember, newMember) => {
let newUserChannel = newMember.channelID;
let oldUserChannel = oldMember.channelID;

if(newUserChannel === "779010277823741972") 
{ 
    
    console.log((`${newMember.member.user.username} Joined the vc `))
    client.channels.cache.get('783262951955103754').send((`<@&785521742030307328> ${newMember.member}  (${newMember.member.user.username}) has knocked on the office door`))    }
else{
    console.log("Left vc")
    client.channels.cache.get('783262951955103754').send((`no one opened the door so ${newMember.member}  (${newMember.member.user.username}) left`))    }

}

)```

but i wanna make it if i drag it it doesnt send the ```js
client.channels.cache.get('783262951955103754').send((no one opened the door so ${newMember.member} (${newMember.member.user.username}) left)) }


```js
else if (!newMember){
        console.log("Left vc")
        client.channels.cache.get('783262951955103754').send((`no one opened the door so ${newMember.member} (${newMember.member.user.username}) left`))    }

    }
 )``` ^^doesnt work
earnest phoenix
#

what's wrong???

little anvil
#

@bot.command(name='serverinfo', help='Information on your current server.')
async def support(ctx, *args, user: discord.Member = None):
if user is None:
user = ctx.author

icon_url = ctx.guild.icon_url

embed = discord.Embed(title="**Server Information**", color=0x0d48a6)
embed.set_footer(text=f"ID: {user.id}")
embed.set_thumbnail(url=str(icon_url)(format="png"))

removed portion

await ctx.send(embed=embed)

#

@sudden geyser

sudden geyser
#

str(icon_url)(format="png")

little anvil
#

alr

sudden geyser
#

You're trying to call a str. The first set of parentheses initializes the str class.

solemn latch
#

@earnest phoenix it would be easier if you provided more context, any errors you have, whats supposed to happen and isnt happening etc.

sudden geyser
#

The second one is to call it like a function, which a class instance isn't one.

little anvil
sudden geyser
#

I already explained the issue.

little anvil
#

:/

main trench
#

@earnest phoenix it doesn't have permission to send a message to that user

solemn latch
#

looks like the user has your bot blocked, or dms off @earnest phoenix

earnest phoenix
#

i'm that user.

solemn latch
#

do you have dms off?

earnest phoenix
#

No.

#

he can DM me with all other commands

#

🤔

little anvil
sudden geyser
#

May I ask if you have a good understanding of Python.

little anvil
#

im sort of new

slender thistle
#

I'm about to lose my mind

little anvil
#

arent we all

sudden geyser
#

don't worry you can always buy a new one

little anvil
#

🥰 yes indeed

slender thistle
#

Not when my ass is poorer than the entirety of Africa

mellow kelp
#

mood

earnest phoenix
#

oh wait i found what's wrong

#

i used client.user.fetch();

#

lol

#

i fetchs the bot's ID

#

i believe

misty sigil
#

what

slender thistle
#

str() returns a string, which can't be called as a function

you could use guild.icon_url_as

misty sigil
#

"hi"()

honest perch
#

hey nerds

misty sigil
#

misly wtf is that pfp

little anvil
honest perch
little anvil
#

guilds undefined

slender thistle
#

Yeah well no shit

main trench
#

Message.guild

misty sigil
#

😹

slender thistle
#

No Goose

misty sigil
#

python works like that?

slender thistle
#

You're wrong too

honest perch
#

lets do some poothon code

little anvil
#

@main trench it recognizes .guild. as apart of icon_url

sudden geyser
#

Mr. dootdoot you may want to spend more time learning Python.

slender thistle
#

It's ctx.guild

honest perch
#

pythons

honest perch
#

@misty sigil wanna watch me do python

slender thistle
#

Oh no

misty sigil
#

ok

slender thistle
#

I'm out of here, bye

honest perch
#

go to palace

main trench
little anvil
#

ugh

hollow sedge
#

its just the argument name lol

honest perch
little anvil
#

i give up

#

omg

slender thistle
#

Oh cool

boreal iron
#

Just google how to use str()

honest perch
#

shivaco im great python developer

slender thistle
#

Another Python dev giving up because they didn't take their time to learn Python

earnest phoenix
#

how can i display an users ID when them use any command?

#

on another guild

slender thistle
#

I'll fucking murder you Misly

boreal iron
#

I'm out of here, bye
Why are you still here?

#

Shoo

slender thistle
#

True

#

Bye

boreal iron
#

gonna watch you

pure lion
#
/* eslint-disable require-jsdoc */
module.exports = {
  name: "redeem",
  aliases: [],
  async execute(client, message, args) {
    const timer = new Map();
    if (timer.get(message.author.id) < Date.now() || !timer.get(message.author.id)) {
      timer.set(message.author.id, Date.now() + 86400000);
      return getPrize();
    } else if (timer.get(message.author.id) > Date.now()) {
      return message.channel.send("cooldown message");
    }

    function getPrize() {
      const counts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
      const prizes = ["prizes here"];
      const ran = Math.floor(Math.random() * counts.length);
      switch (ran) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
          message.channel.send(prizes[0]); // the least rare prize
          break;

        case 6:
        case 7:
        case 8:
          message.channel.send(prizes[1]); // the second rarest prize
          break;

        case 9:
        case 10:
          message.channel.send(prizes[2]); // the rarest prize
          break;
      }
    }
  },
};
```super tired right now, but can someone tell me why its not returning because of the cooldown? (ignore the getPrize function, i know the array has a len of 0 but my client is putting more stuff, thats not the issue right now)
sudden geyser
#

You shouldn't create the timer inside the execute function.

#

You need it to live longer than the command's execution.

main trench
sudden geyser
#

So you should move it to a higher scope.

#

You should also check if the user is in the timer before you see if the time is before the current date in ms.

honest perch
#

@pure lion do ourcord

pure lion
#

@honest perch i need help

honest perch
#

yes so do ourcord

pure lion
#

fine

honest perch
#

and your focus and definition of help will change

pure lion
#

fiNe

#

poo >:(

honest perch
#

start rest

midnight viper
#
const Discord = require('discord.js');
const { connect } = require('snekfetch');
const ytdl = require('ytdl-core');

module.exports = {
    name: 'play',
    description: 'play command',
    async execute(message, args){
        const voiceChannel = message.member.voice.channel
        if(!voiceChannel) return message.channel.send("You need to be in a channel to play music")
        const permissions = voiceChannel.permissionsFor(message.client.user)
        if(!permissions.has('CONNECT')) return message.channels.send('I dont have the permissions to connect to the voice channel')
        if(!permissions.has('SPEAK')) return message.channel.send('I dont have permissions to speak in the channel')

        try{
            var connection = await voiceChannel.join()
        }catch (error){
            console.log(`There was an error connecting to the voice channel: ${error}`)
            return message.channel.send(`There was an error connecting to the voice channel: ${error}`)
        }

        const dispatcher = connection.play(ytdl(args[1]))
        .on('finish', () => {
            voiceChannel.leave()
        })
        .on('error', error => {
            console.log(error)
        })
        dispatcher.setVolumeLogarithmic(5 / 5)
    } 
}
2020-12-16T20:07:00.201215+00:00 app[Worker.1]: (node:4) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined

Im trying to make a music bot but im getting an error on my !play command and no music plays :L

next ridge
#

I'm using mongoose and I want to save something like this in schema
{
userid: "someid",
items: [name: "Name", qty: "Quantity"]
}

Basically, add items and their Quantity

earnest phoenix
#

why it doesn't work when i put an message after the command?

next ridge
#

Or

Items: { item1 , item2 }
main trench
#

@midnight viper does the module you use have docs?

earnest phoenix
#

someone help me

#

!

midnight viper
#

I dont think so?

lone ermine
#

how do i get that page

midnight viper
#

rn im just trying to make it work and then understand what the code does

#

that my plan rn

main trench
#

Since the error is saying it needs to receive a string but it received nothing

#

@lone ermine what page?

#

@earnest phoenix whats the error

lone ermine
#

the umm the programing and how to make a bot

earnest phoenix
#

it doesn't work when i put any message after the command

main trench
lone ermine
#

Yes please

#

it will help me alot

honest perch
#

every developer knows notepad is the best editor

lone ermine
#

lol

limpid bear
#

kinda sus

#

how do i get my bot to check user id before sending the command

earnest phoenix
#

message.author.id

sudden geyser
#

Depends on the library you're using.

earnest phoenix
#

ya

#

lite

#

help me pls

limpid bear
#

discord.js. but that makes sense

earnest phoenix
#

idk why it doesn't work when i put any message after the command

sudden geyser
#

Check if the message starts with the string.

earnest phoenix
sudden geyser
#

Not if the message content is the string.

earnest phoenix
#

ah?

sudden geyser
earnest phoenix
#

o wait

#

lol

#

i didn't use startsWith

#

lmao

main trench
#

Lmao

cerulean ingot
pure lion
#

it cant find the file its looking for

slender wagon
#

const rolePermissions = role.permissions.serialize();
is there a way i could check if for example KICK_MEMBERS is true and then proceed a statement

pure lion
#

ENOENT
E: error
NO: no
ENT: entry

#

@slender wagon you want to check if KICK_MEMBERS is true and then do something?

slender wagon
#

yes

little meteor
#

anyone here kind enough to give me ideas for a command that will allow me to get the bot whitelisted for SERVER MEMBERS INTENT 1hanami_cry

pure lion
#

if (member.hasPermission("KICK_MEMBERS")) { /* code */ }

slender wagon
#

like

#

check the role if it has certain permissions

pure lion
#

yeah

#

the permissions of a role are applied to the member

#

oh

#

ohhh

knotty obsidian
#

how do i make a deny permission override on a channel for a role

slender wagon
#

lol

pure lion
#

you mean the role without the user

slender wagon
#

yes

#

it is for a lock command i am doing, basically i need to check if the channel is already locked and then send a message

#

but it doesn't look that easy, (i don't wanna use a database)

#

just wanna see if there is a way i could fetch a role and see if it has certain permission

pure lion
#

role.permissions.has()

slender wagon
#

i think i tried that

#

but i'll give it another try

#

thanks

#

bruh, before i was trying hasPermission

#

@pure lion thanks a bunch

pure lion
#

@slender wagon no worries

lone ermine
#

@main trench i did it but i cant do it ahhhh. Can someone try do it for me please.

#

Can someone code a bot for me pls

#

@everyone

past needle
#

did you just try to-

lone ermine
#

i tried to code one but i cant do it

twilit geode
twilit geode
# lone ermine i tried to code one but i cant do it

First 500 people will get 2 months of Skillshare free: https://skl.sh/polymatter4

Patreon: https://patreon.com/polymatter
Twitter: https://twitter.com/polymatters
Reddit: https://reddit.com/r/PolyMatter
Discord: https://discord.gg/polymatter

It’s become popular to encourage anyone and everyone to code. But there simply won’t be unlimited deman...

▶ Play video
fallow swallow
main trench
#

No its facts @fallow swallow

twilit geode
fallow swallow
#

I was joking tho

#

...

main trench
#

Clearly weirdsip

fallow swallow
#

...

twilit geode
#

can somone answer my question and not argue with each other

slender wagon
#

#lazy js if (message.channel.name.includes(':lock:')){ return message.channel.send(`#${message.channel.name} has already been locked!`) } i ended up using this after i got tired of trying lmao

odd stratus
#

Anyone know what the best cloud service provider is for a MongoDB Atlas?

sudden geyser
smoky quartz
#

can anyone help me make a vote command

sudden geyser
#

What do you need with about it?

smoky quartz
#

trying to use get_user_vote and its just not going past that line of code

#

it runs but doesnt error and just sits on that line doing nothing

#

well its more voterewards i wanna do than vote

hollow sedge
#

I would recommend AWS though

#

I think they have different free tier regions tho

odd stratus
earnest phoenix
#

Anyone wanna make a bot with me?

sudden geyser
#

nah

misty sigil
#

no

outer perch
#

whats the method to remove more than one element at the start of an array?

sudden geyser
#

What language.

outer perch
#

.shift() only takes off one

#

JS

sudden geyser
#

.splice(index, amount, ...elementsToAdd)

outer perch
#

aight

#

what does it return?

#

the new array?

sudden geyser
#

It mutates the array.

#

So it doesn't return a new one.

#

Just modifies the existing one.

earnest phoenix
#

Array.prototype.splice() returns the elements removed

outer perch
#

ah

earnest phoenix
#

And modifies the original array

outer perch
#

that's the answer I was looking for

#

oh wait @earnest phoenix

#

.slice() (not splice), actually returns the array without the removed elements

#

I just checked my code, and I actually forgot I had used it once

earnest phoenix
#

Omegalul

outer perch
#

but it'll remove the number of elements always from index 0

#

like .slice(2) removes 0 and 1 index values

#

🤦🏻‍♂️ xD

earnest phoenix
#

what does this mean?

#

"Missing access"

#

@sudden geyser are you there?

sudden geyser
#

You tried to do something you don't have access to. The stacktrace is not helpful so you'll have to debug your way through it step-by-step.

earnest phoenix
#

that's the code

#

what's wrong?

pure lion
#

Missing access is a variation of discordapierror, it's thrown when a bot can't read a certain channel

sudden geyser
#

Duck type your way through it. Log the state (either with breakpoints or console.log) and see if something is erroring before the log is produced.

ancient thunder
#

if GuildMember.premiumSinceTimestamp changed would it trigger a guildMemberUpdate event?
I can't test it as I've already spent $12 on boosts within the past few days

analog tinsel
#

Are there any invisible spacing symbols?

#

i need for my !help command

ancient thunder
#

\u200b

ancient thunder
#

epic

shut nimbus
#

Having issues with Gateway intents and discord.py, I have enabled intents in my code as well as on the developer pannel. My current intents code is ```py
intents = discord.Intents().all()
intents.members = True

bot = commands.Bot(command_prefix= ".", case_insensitive=True, Intents= intents)``` I get no errors although the members command gives the members from the last bot restart. Does anyone know why this is, I am using {ctx.guild.member_count} to fetch member counts.

hollow sedge
#

i think its intents=intents

#

not capital Intents

shut nimbus
#

op, ok that did error

hollow sedge
#

fixed?

shut nimbus
#

ah ok, yes that makes sense, the error is I dont have all of the intents enabled on the dev portal, thankyou! (you where right about the caps)

hollow sedge
#

oh ok

outer perch
#

why the heck is Method and Function the same but with different terms??

mellow kelp
#

method is when the function belongs to an object

hollow sedge
#

I think method is for functions called from classes and functions are not attached to anything

mellow kelp
#

function is for some random function out there

hollow sedge
#

no not really

#

you just didnt understand the term

outer perch
#

that's why

mellow kelp
#

it'd make more sense if u come from some language like java

#

everything there is methods

hollow sedge
#

i dont think that would make more sense

outer perch
#

that's why I'm confused

#

I always call them methods

hollow sedge
#

sounds like that would make less sense lol

outer perch
#

and then when I use function in JS, boom, mind blow

mellow kelp
#

lmaoo

#

basically

hollow sedge
#

i think he understands what it is now

mellow kelp
#
function poggers() {
   // This is a f
}
#

well yea

#

nvm

outer perch
#

"this is a F", lmao

mellow kelp
hollow sedge
#

F for that function

outer perch
#

ok, my lmao is actually a big LMAO

#

so, how do i create a function in a single file?

mellow kelp
#

wdym?

hollow sedge
#

i mean, you just create a function

hollow sedge
outer perch
#

but I'm using the same for different files

outer perch
#

aight

#

cuz I used module.exports for the commands

#

don't know if it works the same way

earnest phoenix
outer perch
#

the declaration need to be before

#

wait a min. no

#

forget what I just said

carmine summit
#

you mean message.member.hasPermission()

outer perch
#

yep, he didn't import member

earnest phoenix
#

so do put
message.member.hasPermission()

outer perch
#

yes

earnest phoenix
#

before

carmine summit
#

you replace

outer perch
#

not that

carmine summit
#

the

#

thing

outer perch
#

yeah

earnest phoenix
#

oh ok ty you

carmine summit
#

add message

#

to the front

#

of the

#

member.hasPe

earnest phoenix
#

ok

carmine summit
#

also let member = message.mentions.members.first()

outer perch
#

@hollow sedge I have a problem

hollow sedge
#

what

outer perch
#

I used exports inside the function file

#

then I used require in the command

#

and says it's not a function

#

maybe I got confused

mellow kelp
#

whats ur code

outer perch
#
function slugify(str) {
    const map = {
        '-' : ' ',
        'a' : 'á|à|ã|â|ä|À|Á|Ã|Â|Ä',
        'e' : 'é|è|ê|ë|É|È|Ê|Ë',
        'i' : 'í|ì|î|ï|Í|Ì|Î|Ï',
        'o' : 'ó|ò|ô|õ|ö|Ó|Ò|Ô|Õ|Ö',
        'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü',
        'c' : 'ç|Ç',
        'n' : 'ñ|Ñ',
    };

    for (const pattern in map) {
        str = str.replace(new RegExp(map[pattern], 'g'), pattern);
    }

    return str;
}

exports = { slugify };
earnest phoenix
#

Maybe show us the error + stacktrace

outer perch
#

this is slugify.js

mellow kelp
#

hold on

earnest phoenix
#

What in the god's name

mellow kelp
#

you gotta do module.exports = slugify

earnest phoenix
carmine summit
#

@earnest phoenix also let member = message.mentions.members.first()

mellow kelp
#

you got two variables with the same name

earnest phoenix
#

i did

carmine summit
#

youlle get an error

#

and its constant

outer perch
earnest phoenix
#

oh

mellow kelp
#

i meant the other guy

carmine summit
#

remove it

earnest phoenix
#

ok ty

#

ok i removed it i will test it now

carmine summit
earnest phoenix
#

ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

ok ill try that

outer perch
mellow kelp
#

hmm probably

#

same here

outer perch
#

I just started learning it in June

mellow kelp
#

ESmodules are so much simpler tho

#

export default slugify

#

import slugify from './slugify';

#

but they don't work straightforward with node

outer perch
mellow kelp
#

yea those don't work on commonjs modules

#

if you wanna do that you have to change the extension

#

.mjs

outer perch
#

didn't work

#

still the exact same error

#

it only works when I change it to .ts

mellow kelp
#

yeah well typescript works with es modules

earnest phoenix
#

export keyword works differently in js and ts

mellow kelp
#

i'd say just stick to module.exports and require while using node

#

its about es modules and commonjs

earnest phoenix
#

Either use module.exports or just exports

mellow kelp
#

do both work the same way?

#

that had me kinda confused

earnest phoenix
#

Both are the same

mellow kelp
#

oh cool

outer perch
#

is
module.exports = { foo };
the same as
module.exports = foo;
?

earnest phoenix
#

No

outer perch
#

why?

mellow kelp
#

you're exporting an object on the first one

#

on the second one it's just foo

earnest phoenix
#
let foo = "bar";
module.exports = { foo }; // { foo: 'bar' }

module.exports = foo; // bar```
outer perch
#

ah yes, makes sense

mellow kelp
#

yea

outer perch
#

so what about module.exports = foo();?

mellow kelp
#

you would be exporting the return value of that function

outer perch
#

since I have a function

mellow kelp
#

so imagine

#
function foo() {
  return 'bar';
}

module.exports = foo(); // 'bar'
outer perch
#

after writing the function I could just do module.exports = function();, right?

earnest phoenix
#
let foo = () => "bar";

module.exports = foo(); // bar```
mellow kelp
outer perch
#

yeah

river oracle
#

i may have found a way to DM random users of discord

earnest phoenix
#

If you want to export the function itself to use it in other files

river oracle
#

using a bot

earnest phoenix
#

Export it without invoking it

mellow kelp
#

or what is it

hollow sedge
#

what

outer perch
hollow sedge
#

how would you randomly dm people

mellow kelp
hollow sedge
#

randomly build an ID?

river oracle
mellow kelp
#

you can export functions to use them on another file

hollow sedge
#

i think everyone could do that

river oracle
#

but it works and it's possibly a discord bug

hollow sedge
#

bruh

#

you did not find a discord bug lol

earnest phoenix
#

Using random snowflakes is not a discord bug

river oracle
hollow sedge
#

you wouldnt be able to

earnest phoenix
#

How is a user, using random snowflakes to make API requests a discord bug?

hollow sedge
#

actually you might be

earnest phoenix
#

That makes no sense

#

🗿

hollow sedge
#

but this is why you can turn off random dms

#

its not a BUG tho

queen needle
hollow sedge
#

you can call it an oversight but not a bug

#

(its not even an oversight)

earnest phoenix
#

Using a snowflake doesn't matter from where it's, it's not a discord bug

outer perch
#

so that means I am invoking the function while exporting when doing module.exports = function();

earnest phoenix
#

Yes

outer perch
#

so i should still use module.exports = { function };

hollow sedge
#

i mean you'll get banned from discord and probably get ratelimited

earnest phoenix
#

No