#development

1 messages · Page 1503 of 1

solemn leaf
#

yeah there inst any args

#

if there isnt*

molten yarrow
#

!args ? message.author.displayAvatarURL({ dynamic: true }) : args.join("")

solemn leaf
#

?

#

I didnt know ? was a logic

molten yarrow
#

is that what you wanted?

#

if there are no args: !args, than take the avatar

solemn leaf
#

so I can do that as a value>?

molten yarrow
#

hm? xD

pale vessel
#

Those two values together don't make sense

#

User input and avatar URL?

solemn leaf
#

if the user sent a link

pale vessel
#

and args joined by "" is weird

solemn leaf
#

you're right

earnest phoenix
solemn leaf
#

look at the image

#

and tell me again

misty sigil
#

...?

earnest phoenix
#

ok

misty sigil
earnest phoenix
#

/*
The following code goes into it's own file, and you run this file
instead of your main bot file.
*/

// Include discord.js ShardingManger
const { ShardingManager } = require('discord.js');

// Create your ShardingManger instance
const manager = new ShardingManager('./YOUR_BOT_FILE_NAME.js', {
// for ShardingManager options see:
// https://discord.js.org/#/docs/main/v11/class/ShardingManager

// 'auto' handles shard count automatically
totalShards: 'auto', 

// your bot token
token: 'YOUR_TOKEN_GOES_HERE'

});

// Spawn your shards
manager.spawn();

// The shardCreate event is emitted when a shard is created.
// You can use it for something like logging shard launches.
manager.on('shardCreate', (shard) => console.log(Shard ${shard.id} launched));

@misty sigil this is shades?

misty sigil
#

no that’s code

crimson vapor
#

this is a fancy djs sharding method

misty sigil
#

that’s the way I use

earnest phoenix
#

where i find a code of shades

crimson vapor
#

shade.toString()

earnest phoenix
#

what

#

i didn't understand how shades work

slender thistle
#

Each shard handles its own set of guilds that are assigned to it

#

Say, shard 1 handles guilds with IDs ranging from 1-2500, while shard 2 handles guilds with IDs from 2501 to 5001

tribal siren
#

what does the public key do?

earnest phoenix
#

the public key

#

there's no context whatsoever to this question

solemn leaf
#

can I do many things a string can end with with string.endWtih()

pale vessel
#

You can use an array find(r => [id1, id2].includes(r.id))

#

The way you're doing is incorrect

earnest phoenix
#

you probably want to create that array outside of the find though

#

micro optimization ™️

solemn leaf
#

cry

earnest phoenix
#

yeah?

solemn leaf
#

can I do many things a string can end with

earnest phoenix
#

i do not understand what you're trying to say

solemn leaf
#

.endwith()

#

can I do like regex in it

haughty vortex
#

yes

#

.endsWith(/myRe/) iirc

solemn leaf
#

if (!x.endsWith(/\.(jpeg|jpg|gif|png)$/))

haughty vortex
#

yea

solemn leaf
#

First argument to String.prototype.endsWith must not be a regular expression

haughty vortex
#

welp

#

maybe not then

#

you could use test()

sick cloud
#

pretty sure i can't improve it anymore

pale vessel
#

yes

#

look very "chrome"ish

solemn leaf
#

edge

sick cloud
#

yeah material design

solemn leaf
#

cringe

haughty vortex
#
"poop.jpg".test(/\.(jpeg|jpg|gif|png)$/)```
sick cloud
#

edge = chrome
chrome = not a pain to dev with

haughty vortex
#

^

#

+1

pale vessel
sick cloud
#

but anyways cool

haughty vortex
#

@pale vessel yep

solemn leaf
#

wdym test isnt a thing

pale vessel
#
/\.(jpeg|jpg|gif|png)$/.test("poop.jpg")```
solemn leaf
#

can I if that

pale vessel
#

yes

haughty vortex
#
if(/\.(jpeg|jpg|gif|png)$/.test("poop.jpg")) ...```
#

I'd do js /\.(jpe?g|gif|png)$/.test("poop.jpg") instead tho

earnest phoenix
#

if you're testing for file names to verify they're actually that type... sorry to break your bubble but that doesn't do that

haughty vortex
#

it's just extensions he wants to test

#

filenames

earnest phoenix
#

you can rename a file to have any extension you want

pale vessel
#

you can even fake mimetype right?

earnest phoenix
#

yup

haughty vortex
#

yea yuou can

pale vessel
#

cringe

haughty vortex
#

but linux type shows true type lol

solemn leaf
#

how can I test if the website url doesnt end with a .jpeg etc

earnest phoenix
#

the only reliable way to verify the file type is downloading the first few bytes and checking the file header

earnest phoenix
#

what do you actually want to do

solemn leaf
#

I want like a function maybe that will return if the link contains an img tag

pale vessel
earnest phoenix
#

correct

earnest phoenix
pale vessel
#

interesting

solemn leaf
#

sure

earnest phoenix
#

you need to make a request to the url and check the mime type of the content

#

it's not 1995 anymore, images can be served without the extension

solemn leaf
#

yes they can

earnest phoenix
#

i know they can

#

lol?

solemn leaf
#

ok

#

cry

haughty vortex
#

@earnest phoenix whats the problem

pale vessel
#

Make your role ids strings

haughty vortex
#

ah alright

#

gotcha

pale vessel
#

Member or roles?

haughty vortex
#

roles

#

he said above

earnest phoenix
#

instead of numbers, make them strings

pale vessel
#

what

#

i didn't say tuples

earnest phoenix
#

js cant handle unsigned longs

haughty vortex
#

lol

earnest phoenix
#

LOL

#

Lmfdo

harsh blade
summer torrent
#

what is wrong?

dusky sundial
#

It looks like it's sending it twice when a member joins?

#

Do you have two instances of the bot running?

harsh blade
#

Yeah

#

a music server and a main server

#

also its sharded

dusky sundial
#

Well it looks like both instances are reacting to the same event

harsh blade
#

How can i stop it?

#

Im new to discord.js

dusky sundial
#

Do you need the event on both instances? I'm not too familiar with shards

harsh blade
#

just in the main server

#

the music server is just for music

dusky sundial
#

Well, I think someone more experienced in JS will have to help you out, sorry ^^

harsh blade
#

aw oki

opal plank
#

member.user.send()

harsh blade
#

ill try

cinder patio
#

you can send a membr

summer torrent
cinder patio
#

I don't think that's the issue

summer torrent
#

Message @DynamicBot

pale vessel
#

you can send to a member, it implements textbasedchannel

dawn blade
opal plank
#

actually, my bad

#

you CAN send members a message

#

i wasnt aware of that one

solemn leaf
#

@harsh blade you could try to return

harsh blade
#

?

solemn leaf
#

if you want it to stop

#

use return

harsh blade
#

uhhhhhh

#

hm

autumn bolt
#

Hola

harsh blade
solemn leaf
#

then stop making discord bot

#

rn

#

like rn

harsh blade
#

?

solemn leaf
#

and do something else for beginners

#

if you dont know what return is

harsh blade
#

no

#

im just trying to add 1 feature

solemn leaf
#

your loss

harsh blade
#

to a bot my friend helped with me

solemn leaf
#

noob

harsh blade
#

says you?

solemn leaf
#

yeah

harsh blade
#

😂

#

okay kid

solemn leaf
#

if you dont know js you shouldn't be making a discord bot

harsh blade
#

ok

#

now i cry

solemn leaf
#

that uses js for the api

#

like come on

earnest phoenix
harsh blade
slender thistle
#

He's not wrong

tribal siren
#

i have this huge problem

#

so not a lot of time ago i started to have this of a mess when systematic guildMemberAdd messages didn't work

#

my code looks like this:

#
bot.on('guildMemberAdd', async member => {
  let welcomeChannel = await db.get(`welchannel_${message.guild.id}`);
  let welcomeRole = await db.get(`constRole_${message.guild.id}`);
  member.roles.add(welcomeRole)
  if(!welcomeChannel) return;
  const embed = new Discord.MessageEmbed()
    .setAuthor('New Member!')
    .setTitle(`Member ${member.user.username} has joined!`)
    .setDescription(`Hello ${member}, have a great time in ${message.guild}!`)
    .setColor('#5f18ff')
    .setImage('https://images-ext-1.discordapp.net/external/4c13WC2375LbsiTq1pbtXLlMjkHzHGOBb179EX1wt98/https/media2.giphy.com/media/j1soPQE95y0eXhMwKT/source.gif')
    .setThumbnail(member.user.avatarURL())
    .setFooter(`Have a nice day and enjoy your time in ${message.guild}!`)
    .setTimestamp();
  bot.channels.cache.find(welcomeChannel).send(embed);
  member.roles.add(welcomeRole);
});
#

oh wait

summer torrent
#

use get() instead of find() for ids

#

find takes function as parameter

tribal siren
#

nonono that's not the error

#

MY LORD

#

i found the error

misty sigil
#

@tribal siren still use get

tribal siren
#

yes that was the problem

#

still thank you

lusty quest
#

if you use the channel frequently maybe load it once on Startup with fetch into the cache

misty sigil
#

i think you should check if theres a role before you try to add it too @tribal siren

tribal siren
#

don't worry i fixed it

#

works noice noice

misty sigil
#

it'll cause an error tho

solemn leaf
#

how can I get the url of an emoji that is in a message not reacted

neat harness
earnest phoenix
#

there is no concept of law on discord unless you're doing actually illegal shit lol

solemn leaf
#

what code edittor is that

neat harness
solemn leaf
#

brb gonna rewrite some c of vs

neat harness
earnest phoenix
#

you have to alert your users of what data you're collecting

#

otherwise you're breaking the tos

solemn leaf
#

cry

earnest phoenix
#

?

solemn leaf
#

how get emoji url if it is put in a message?

#

🙂

#

like that url

earnest phoenix
cinder patio
#

That emoji doesn't have a url cause it's a default one

cinder patio
#

only custom emojis do

neat harness
#

And may return an error

solemn leaf
#

https://discord.com/assets/da3651e59d6006dfa5fa07ec3102d1f3.svg

earnest phoenix
#

there's probably some lib you can find that parses the unicode into a twemoji github url

neat harness
#

BRUH

#

Going to the assets

earnest phoenix
neat harness
#

Is not possible for the bots

earnest phoenix
#

yes it is

#

stfu

solemn leaf
#

https://cdn.discordapp.com/emojis/${emoji.id}./* extension of the emoji e.g: .png */

neat harness
#

m

solemn leaf
#

how should I get the id

neat harness
#

I may be stoopid

#

Idk

earnest phoenix
#

check out the url i sent

#

it's a map of every emoji on discord

solemn leaf
#

if (mB[1].endsWith(">")) {
try { ... }
}};

#

\<a:\wallah:795429292405424138>

earnest phoenix
#

you will never receive emojis in the colon representation

#

always their unicode string

solemn leaf
#

I did

earnest phoenix
#

only for custom emojis shall you receive colon representation

solemn leaf
#

so if it is 🙂 I cant get the assest link

#

its impossible

earnest phoenix
#

bitch

solemn leaf
#

ayo chill

earnest phoenix
#

it's stan twitter language

#

i didn't actually call you a bitch

#

lmfao

solemn leaf
#

can I get the emoji name?

solemn leaf
#

:smiley\:

gilded olive
#

If you tell them that you are

#

Then it's not

solemn leaf
#

it breaks tos to log thing like that I think

gilded olive
#

Not if the users know

solemn leaf
#

yeah but why log it

gilded olive
#

Who knows

solemn leaf
#

you gonna be api blocked

neat harness
gilded olive
#

How would that throw an error

neat harness
earnest phoenix
#
//pseudo code

if(arg.match(/^<a?:(\w+):(\d+)>$/))
  //it's a custom emoji here
else if(emojiMap.find(x => x.surrogates === arg)
  //it's a unicode emoji here
else
  //it isn't an emoji at all here
neat harness
#

And it bugs

gilded olive
#

Uh huh

neat harness
#

And my bot crashes

gilded olive
#

They use a command and it bugs?

#

Sounds like a you problem

neat harness
#

And I need to know what command bugs

neat harness
#

Wait...

solemn leaf
#

I seen

neat harness
#

That's so frikkin mean

solemn leaf
#

how can I get the id of the custom emoji

gilded olive
#

Theres no event that tells you when an error occurs?

#

🤣🤣🤣🤣

solemn leaf
#

process.on()

earnest phoenix
solemn leaf
#

make your own error handler

neat harness
#
const emojis = require('https://static.emzi0767.com/misc/discordEmojiMap.json');
if(emojis.map(r => r.emojiDefinitions.primaryNameWithColons).filter(r => r == mB[1)) {
  let emojiUrl = emojis.filter(r => r.emojiDefinitions.primaryNameWithColons == emojis.map(r => r.emojiDefinitions.primaryNameWithColons).filter(r => r == mB[1))
}
#

Lol

earnest phoenix
#

that is wrong

neat harness
#

Overcomplicating stuff is my part

earnest phoenix
#

on so many levels

#

that code isn't correct at all

neat harness
#

It was a joke imo

solemn leaf
#

what ht fuck

#

I can just do

neat harness
#

People who doesn't understand would literally laugh

gilded olive
#

don't*

earnest phoenix
#

you aren't being helpful, you aren't being funny, you're just being annoying

solemn leaf
#

gottem

gilded olive
#

No "."

stuck pike
#

cant we clone a repo in replit

gilded olive
#

Iirc yes

stuck pike
#

it shows to subscribe for plan

gilded olive
#

LOL

#

tough

#

You can if its yours

#

I think

stuck pike
#

its mine

#

but it aint working

gilded olive
#

Are you sure

#

When you need to create a new repl

#

Dosent it give an option to use a github repository

stuck pike
#

but when i click on it

gilded olive
#

Uh huh

stuck pike
#

says subscribe

solemn leaf
#

so cry

gilded olive
#

That's tough

#

nom 1 example why you dont use repl

stuck pike
#

i dont have any other decent host lol]

#

i have 12 users and 40 servers

lusty quest
#

get a decent Paid VPS

gilded olive
#

digital ocean

lusty quest
#

or the 1 year free plan from AWS Google

solemn leaf
#

@earnest phoenix how do I pass through the match then>?

earnest phoenix
#

what do you mean

dusky sundial
#

Vultr is pretty okay for its price, $5/month

copper coral
#

hak

lusty quest
#

Digital Ocean is actually pretty Decent Priced if you plan to use K8 Clusters

copper coral
#

yas

distant cobalt
#

how do you make a channel specific command using javascript?

earnest phoenix
#

compare channel ids

lusty quest
#

check the current channel id with the id of the spezific channel

solemn leaf
#

cry like um

#

so I dont have to do the regex twice

#

and just make the thing a value

distant cobalt
#

no, like something like p!lock #support

earnest phoenix
#

think about how you would do that @solemn leaf

distant cobalt
#

and if we dont mention a channel it'll tell you to mention a channel

lusty quest
#

get the channel id from the mention

#

check if the command contains a channel mention

distant cobalt
quartz kindle
#

if youre using discord.js, you have message.mentions.channels

distant cobalt
#

okay

distant cobalt
quartz kindle
#

if you want the first mention, yes

distant cobalt
#

ok

tight plinth
lusty quest
#

should be a client option

tight plinth
#

the msg.s is a custom function but it take the smae options as .channel.send

pale vessel
#

you can also provide it to the send method

tight plinth
#

yes ik

#

but it doesn't work either

pale vessel
#

why not

tight plinth
#

it's set to client.options.disableMentions by default

earnest phoenix
#

how to create page for bot pretty nice

lusty quest
#

use some html/css

#

if you want a dashboard i can recomend MERN stack

mellow kelp
#

yes

#

MERN stack gang

solemn leaf
#

@earnest phoenix its saying .find isnt a function

earnest phoenix
#

what's your code

lusty quest
#

isnt find deprecated? atleast for the managers

solemn leaf
#

} else if (emojiMap.find((x) => x.surrogates === mB[1])) {
URL = emojiMap.find((x) => x.surrogates === mB[1]).assetUrl

earnest phoenix
#

emojiMap refers to the actual object

#

you need emojiMap.emojiDefinitions

distant cobalt
#

How do you have the author's avatar in the footer?

tight plinth
#

@pale vessel tried to set the client.options.disableMentions to "everyone", apparently didnt worked

pale vessel
#

try allowedMentions

#

channel.send("s", { allowedMentions: { parse: [] } })

tight plinth
#

hmm

solemn leaf
#

k thnaks it worked

tight plinth
#

worked

solemn leaf
#

can you help me fix my ifs?

#
    if (mB[1] && mB[1].match(/^<a?:(\w+):(\d+)>$/)) {
        URL = `https://cdn.discordapp.com/emojis/${mB[1].match(/^<a?:(\w+):(\d+)>$/)[2]}.png`
    } else if (emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1])) {
        URL = emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1]).assetUrl
    } else if (!message.attachments.array()[0]) {
        URL = mB[1]
    } else if (message.attachments.array()[0]) {
        URL = message.attachments.array()[0].url
    }
tight plinth
#

but why is disableMentions not working

pale vessel
#

idk

#

it probably adds a zws, which is weird as to how it didn't work

solemn leaf
#

disableMentions: "everyone"

tight plinth
#

i just wanna make the bot not ping @everyone and still ping users

solemn leaf
#

that wont work

#

lol

tight plinth
#

but discors.js is being wack

solemn leaf
#

cancel the ping

tight plinth
solemn leaf
#

with a \

tight plinth
#

@\everyone?

solemn leaf
#

@everyone

tight plinth
#

@everyone

#

hm

#

ig that works too

pale vessel
#

don't

#

you can still use the guild id and role mention

tight plinth
#

but it does not work

earnest phoenix
solemn leaf
#

got it

shadow crag
#

for my ping command i use client.ws.ping but for api latency for whatever reason i get NaNms

message.channel.send(`Pong! Latency is ${Date.now() - message.createdTimestamp}ms
API Latency is ${Math.round(client.ws.ping)}ms`)

earnest phoenix
#

you can also make this prettier with ternary operations if you want to

solemn leaf
#
    if (mB[1]) {
        if (mB[1].match(/^<a?:(\w+):(\d+)>$/)) {
            URL = `https://cdn.discordapp.com/emojis/${mB[1].match(/^<a?:(\w+):(\d+)>$/)[2]}.png`
        } else if (emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1])) {
            URL = emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1]).assetUrl
        } else if (!message.attachments.array()[0]) {
            URL = mB[1]
        } else if (message.attachments.array()[0]) {
            URL = message.attachments.array()[0].url
        }
    }
tight plinth
solemn leaf
#

but the last 2 ifs didnt work

earnest phoenix
#

you didn't do over half of what i said to do

solemn leaf
#

I did that before I seen your message

pale vessel
#

@tight plinth use ```js
string.replace(/@everyone/g, "@\u200beveryone");

earnest phoenix
#

the last replace is useless

#

it's a ping of the actual @everyone role

#

it doesn't work

solemn leaf
#
    const mB = message.content.split(" ");
    const match = mB[1].match(/^<a?:(\w+):(\d+)>$/)
    let URL = message.author.displayAvatarURL({
        dynamic: true,
        size: 1024,
        format: 'png'
    });
    if (mB[1]) {
        if (match) {
            URL = `https://cdn.discordapp.com/emojis/${match[2]}.png`
        } else if (emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1])) {
            URL = emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1]).assetUrl
        } else if (message.attachments.array()[0]) {
            URL = message.attachments.array()[0].url
        } else {
            URL = mB[1]
        }
    }
tight plinth
pale vessel
#

they're different?

earnest phoenix
#

yup

pale vessel
#

i'm so retarded

#

i thought it was the same shit

solemn leaf
#

@earnest phoenix what else

earnest phoenix
#

?

tight plinth
#

ig imma use this

tight plinth
#

ty for help

last geyser
#

How do I style the description's CSS to be different for light/dark users?

#

so

stuck pike
#

(node:273) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.

#

i use env file

#

idk why this is comming

solemn leaf
#

@earnest phoenix how am I supposed to make match a value

#

if its nil

earnest phoenix
#

huh?

solemn leaf
#

ypeError: Cannot read property 'match' of undefined

#

const mB = message.content.split(" "), match = mB[1].match(/^<a?:(\w+):(\d+)>$/);

earnest phoenix
#

you're trying to match before verifying that mB[1] exists

pale vessel
#

i still don't know what you mean by nil

#

this is js

solemn leaf
#

ok

#

didnt errror

#

now to fix this

#
        } else if (message.attachments.array()[0]) {
            URL = message.attachments.array()[0].url
        } else {
            URL = mB[1]
        }
#

I dont know why it doesnt do it

earnest phoenix
#

share your current code

solemn leaf
#
    const mB = message.content.split(" ")
    let URL = message.author.displayAvatarURL({
        dynamic: true,
        size: 1024,
        format: 'png'
    });
    if (mB[1]) {
        const match = mB[1].match(/^<a?:(\w+):(\d+)>$/);
        if (match) {
            URL = `https://cdn.discordapp.com/emojis/${match[2]}.png`
        } else if (emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1])) {
            URL = emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1]).assetUrl
        } else if (message.attachments.array()[0]) {
            URL = message.attachments.array()[0].url
        } else {
            URL = mB[1]
        }
    }
pale vessel
#

you can easily make this one line with ?. and ||

solemn leaf
#

I dont want to do it on line and how

#

cry you good

pale vessel
#

no he's dead

earnest phoenix
#

i had to go restart my router

#

anyway

pale vessel
signal estuary
#

How can a bot react to a message in the bot dms? So if i dm a bot with "Hello" he answer with "Hi".
Pls help me

earnest phoenix
#

that's a mess but it seems it should work

solemn leaf
#

it doesnt

#

I can screenshare

#

if you dont belive me

signal estuary
#

thx for answers :I

manic osprey
#

@solemn leaf Hangout

solemn leaf
#

?

#

I dont got booster I cant stream in there

manic osprey
#

The developer special help you

quartz kindle
manic osprey
#

@solemn leaf donate nitro

solemn leaf
#

what

slender hamlet
#

I'm sorry if this is a bit of a dumb question, but when I'm editing the detailed description on my bot's page, I'm not able to force a theme. I'm using an external stylesheet, but I don't think its recognized as "highly customized" CSS. Is there anything I can do about this?

solemn leaf
#

im confused

solemn leaf
#

@manic osprey see

earnest phoenix
#

you don't need to screeenshare

signal estuary
earnest phoenix
#

just screenshot the result of the command

solemn leaf
quartz kindle
signal estuary
quartz kindle
#

i'll take that as a no

pale vessel
#

where did it even get that image

earnest phoenix
# solemn leaf

because you check if mB[1] exists, in this case it doesn't, so it never gets to the attachments

signal estuary
#
client.on('message', async (msg) => {`
} 
solemn leaf
#

wsait

signal estuary
#

That doesnt work in dm

solemn leaf
#

I never check that

#

in the if statements

quartz kindle
#

if you dont use intents, it does work in dm

solemn leaf
#

I put it in a if that does

#

wait

earnest phoenix
#

are you high

solemn leaf
#

ohhh

signal estuary
solemn leaf
#

yes I am

pale vessel
quartz kindle
summer torrent
quartz kindle
#

but if you dont use intents, you can ignore that

pale vessel
#

Ok

solemn leaf
#
    const mB = message.content.split(" ")
    let URL = message.author.displayAvatarURL({
        dynamic: true,
        size: 1024,
        format: 'png'
    }), match;
    if (mB[1]) {
    match = mB[1].match(/^<a?:(\w+):(\d+)>$/);
    }
    if (match) {
        URL = `https://cdn.discordapp.com/emojis/${match[2]}.png`
    } else if (emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1])) {
        URL = emojiMap.emojiDefinitions.find((x) => x.surrogates === mB[1]).assetUrl
    } else if (message.attachments.array()[0]) {
        URL = message.attachments.array()[0].url
    } else {
        URL = mB[1]
    }
slender hamlet
#

an alternative that I could think of is channel.awaitMessages

#

although I'm not sure if that's practical

earnest phoenix
#

what even is that code anymore

earnest phoenix
#

refactor it

pale vessel
#

make it one line if you were to refactor it

solemn leaf
#

wha

stuck pike
#

TOKEN=NzU1OTg1Mjc2ODczOTk4NDg2.X2 rest of tokrn

slender hamlet
#

uh

earnest phoenix
#

one liner for this amount of checks is super ugly

stuck pike
#

proccess.env.TOKEN

slender hamlet
#

you probably dont wanna share your token

pale vessel
#

that's just the bot id in base64

slender hamlet
#

ok

urban pelican
stuck pike
#

why isnt the env working

slender hamlet
pale vessel
#

how did you set it

solemn leaf
#

why dont work bcs file sint declared

stuck pike
slender hamlet
#

'file' is not a variable

solemn leaf
#

process.env.TOKEN.toString('utf8')

urban pelican
#

so what should i put there?

manic osprey
#

Hello

slender hamlet
#

you should define file

stuck pike
manic osprey
#

I’m good developer 🙂 xD

solemn leaf
#

ok

sterile lantern
#

also its client.login(process.env.TOKEN)

pale vessel
sterile lantern
#

if you're logging into a discord bot

slender hamlet
urban pelican
earnest phoenix
#

looks okay

#

thought it would be worse

slender hamlet
#

that's because when you do ${thing} the program will look for a variable called 'thing'

#

if you removed the ${} it would work

#

but only for that one file

#

but let me help you here: do you think you could vc?

#

i won't spoonfeed but i will try to guide you through it

#

@urban pelican ?

stuck pike
slender hamlet
#

ik

urban pelican
#

sorry but I don't really understand English I can only write 😦

slender hamlet
stuck pike
#

lol

slender hamlet
#

ok, so in that case

#

lets step through your code

#

what does the first line (the fs.readdirsync) do

#

before anyone responds, i know what he has to do but im tryna show him

shadow crag
#

for my ping command i use client.ws.ping but for api latency for whatever reason i get NaNms

message.channel.send(`Pong! Latency is ${Date.now() - message.createdTimestamp}ms **API Latency is ${Math.round(client.ws.ping)}ms**`)

slender hamlet
#

I believe that you may have quotes around that

#

potentially something like this: '``'

#

when you want this: ``

runic lantern
#

for mine i immediately send a response message and then get the time difference between the command and the response

slender hamlet
#

yeah, but his braces arent being parsed

#

its just outputting a string

#

not replacing the var

#

i think he might have the `${var}` surrounded in quotes

pale vessel
#

@shadow crag can you show your code inside a codeblock

slender hamlet
#

ok

#

ye

stuck pike
#

can anyone help me with .env

pale vessel
#

use ```

slender hamlet
#

ss or paste more code I think hes saying

#

yeah

stuck pike
#

it seems to not working for me on replit

shadow crag
#

oh yes

urban pelican
#

ok i'm back 🙂

slender hamlet
#

I'll let you handle this flazepe sorry

umbral zealot
slender hamlet
#

also verko

#

so lets run through ur code line by line starting from the fs.readdirsync

#

tell me what that does first

slender hamlet
#

lmao yep

umbral zealot
#

It's literally placing THING=blah in the .env and then doing process.env.THING in your code, it shouldn't require that much time to get working

stuck pike
#

it works on my pc

#

pc

pale vessel
#

why?

slender hamlet
#

yep there we go

shadow crag
#

oh because i wanted them to be shown but that was before i made them in a code block

#

its not like that in the actual code

pale vessel
#

ah

shadow crag
#

now its how it should be

urban pelican
#

well make the path to the folder from the command
(for info I am not a good programmer I started yesterday) 😦

#

xD

stuck pike
#

idk whats wrong on replit

pale vessel
umbral zealot
#

It most definitely should work on repl.it as I've used this method multiple times

slender hamlet
urban pelican
#

great I'm glad

slender hamlet
#

so essentially, that first line is getting all files in ./commands/ that end in .js

shadow crag
stuck pike
#

TOKEN=NzU1OTg1Mjc2ODczOTk4NDg2.X2LQJw.CWdrx rest of prefix

#

process.env.TOKEN

#

not works

crimson vapor
#

is that your full token?

shadow crag
#

You shouldnt have your token in here

crimson vapor
#

its not a full token

umbral zealot
slender hamlet
umbral zealot
pale vessel
#

hmm

slender hamlet
#

now what does the next line do, @urban pelican?

pale vessel
#

@shadow crag add console.log(client.ws.ping) somewhere in your code

slender hamlet
#

(the for loop)

umbral zealot
#

And I can access process.env.CLIENT_TOKEN anytime I want.

#

And also const prefix = process.env.PREFIX; works fine

shadow crag
umbral zealot
#

No, you do'nt need that

shadow crag
urban pelican
umbral zealot
#

I mean it's fine if you have those (though, "normal quotes" not “these fucking word versions”) but it's not necessary to have quotes.

slender hamlet
#

yes

#

what does it do?

wicked sapphire
#

Is there a developer build of discord.js as an npm package? something like discord.js-dev?

slender hamlet
umbral zealot
slender hamlet
#

step by step

crimson vapor
#

no you need to use npm i discordjs/discord.js

wicked sapphire
umbral zealot
shadow crag
umbral zealot
#

I mean if you want to just repeat what the guide says that's fine, but it's properly explained in there 😛

slender hamlet
#

alrighty, I just wanted to offer a person to person thing 😅

pale vessel
#

try restarting your bot

umbral zealot
shadow crag
#

do you mean just off and then back on

slender hamlet
#

but @urban pelican, here's a hint: look very very closely at the for loop, and then look at the code inside it. notice anything?

#

you can use the guide that evie gave, just letting you know

pale vessel
shadow crag
#

ok i did that and still got NaN

pale vessel
#

that's really weird

shadow crag
#

yeah

urban pelican
#

I do not know 😢

slender hamlet
urban pelican
#

no 😦 but I noticed that I missed commandfile with s

lament rock
#

The fact that they can access client.ws.ping and have it be NaN is a start. That's not supposed to be correct unless they were trying to access it before the client entered a ready state

#

pretty sure WebsocketManager.ping is a getter

urban pelican
#

is online

slender hamlet
#

your for loop says for constfile of commandFiles
the code in your for loop says const command = require('./commands/${file}.js\')

lusty quest
slender hamlet
#

you had a different problem, but you solved both

solemn leaf
#

@pale vessel links dont work anymore

urban pelican
lament rock
#

readdirSync returns Array<string> of file names, not paths

pale vessel
#

why not

#

log your variables

slender hamlet
#

you did write commands.name instead of command.name, but you also wrote constfile instead of const file!

#

good job on figuring it out!

#

I'm glad I could help to some extent

lament rock
#

suggestion for developers which use vscode: turn on checkJS in settings

slender hamlet
#

cant believe i lived without it for so long

urban pelican
solemn leaf
#

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'assetUrl' of undefined
when trying to do !invert link

lament rock
#

show code

solemn leaf
#

URL = match ? `https://cdn.discordapp.com/emojis/${match[2]}.png` : emojiMap.emojiDefinitions.find(x => x.surrogates === mB[1]).assetUrl || message.attachments.first().url || mB[1];

lament rock
#

Your find is returning undefined. You should not attempt to access properties of potentially undefined accessors. If you're using node 14, you can use optional chaining to remove the necessity to check for if the value of the find is undefined

pale vessel
#

you removed the ?

lusty quest
pale vessel
#

on the attachment too

lament rock
#

It would be under TypeScript settings since VSC uses TS for checkJS

slender hamlet
#

run node --version

pale vessel
#

i'm assuming they are since they removed the ?s

slender hamlet
#

its not unlikely

solemn leaf
#

yep

#

do I do node update

slender hamlet
#

yep as in youre below v14

lapis hound
#

whats up

slender hamlet
#

or yep as in it works once you update

#

?

lament rock
#

Does VSC even look at a jsconfig by default unless a setting which would require some config is turned on?

haughty vortex
#

it does

#

always

slender hamlet
#

yeah pretty sure

haughty vortex
#

jsconfig only applies to .js files tho, of course

lament rock
#

Strange. All of the supported config values would at least have to have checkJS turned on for any of the config to be there to make sense

haughty vortex
#

tsconfig for good .ts users

lament rock
#

of course

solemn leaf
#

how do I update node

slender hamlet
lament rock
#

Pretty sure. Only config value I can think of is actually checkJS: boolean

slender hamlet
lament rock
#

other than that, what comes to mind is strictNullChecks amongst other things checkJS related

solemn leaf
#

do I uninstall my old?

#

will i have to redo my projects?

slender hamlet
#

i think it auto uninstalls

#

no

#

node's just the thiing that runs your project

slender hamlet
#

its like uninstalling vsc

#

your js still works

haughty vortex
#

VSCode reads JSConfig in a directory, regardless of anything else

#

jsconfig.json is tsconfig.json with "allowJs" attribute set to true

solemn leaf
#

should I select this?

slender hamlet
#

i'd recommend it just to be safe

#

itll be annoying in the future potentially

pale vessel
#

if you use native modules yes

solemn leaf
#

kk

haughty vortex
#

in short: yes

#

unless you want node-gyp to bitch at you

solemn leaf
#

pls do

lament rock
#

I have read that before. All of the config values it states there would make sense if checkJS is turned on in settings. If not, it wouldn't make sense to try to do any of those config settings unless it was checking in the first place. Unless it just shadow turns it on and ignores it's other features and only provides what you the file declares

solemn leaf
#

let node be my bitch

#

wonder if node is cute

slender hamlet
#

normal people: yes
programmers: y

haughty vortex
#

checkJs: Enable type checking on JavaScript files.

#

it can be turned off and you'll still get type references regardless

lament rock
#

Yes. I did mention that config property existed which would make sense

#

it won't yell at you though

lusty quest
#

ohh its the type check thing. it where already enabled for me

lament rock
#

Very helpful feature

#

can be lazy

haughty vortex
#

yea, it's type checking for the lazy (read: no ts)

lament rock
#

Statically typed JS is my wet dream

#

Do not suggest Java

lusty quest
#

use C#

lament rock
#

fair

haughty vortex
#

coffeescript

lament rock
#

never heard of it

haughty vortex
#

coffeescript + typescript

lusty quest
#

its quite popular iirc

lament rock
#

Is it building off of TypeScript or is it it's own thing

haughty vortex
#

it's its own thing

slender hamlet
#

c# is pretty good, my favorite next to js

#

javas ok

lusty quest
#

but if you want some more efficent resource usage i guess you wont get around using a compiled language

haughty vortex
#

Rust is much nicer imo

slender hamlet
#

c is good to know but soo annoying to code in

lament rock
#

Rust syntax is kinda horrific

haughty vortex
#

lmfao

slender hamlet
#

oml dont get me started on rust

#

lmao

haughty vortex
#

ouch

#

I got a Rust bot with commands written in JS

lusty quest
#

tryed to learn GO, failed at step 1, Setup a Enviroment

slender hamlet
#

LMAO rip

haughty vortex
#

Go is budget Rust

lusty quest
#

GO is nice, not bound to any platform, and some other nice stuff

haughty vortex
#

budget Rust is bad

slender hamlet
#

I also think that angular is pretty nice

#

really good framework

haughty vortex
#

Angular is just fancy Pug

#

if you want a good framework, Vue or React are nice

slender hamlet
#

but is that a bad thing..?

haughty vortex
#

yes it is

#

it's bloody Pug

#

Pug from 2010 loldog

lament rock
#

Pug is good

haughty vortex
#

good is objective

lament rock
#

doesn't require an absurd install size

haughty vortex
#

lacks decency though

lusty quest
#

hmm
Rust = I am Speed
GO = I can compile faster

crimson vapor
#

JS =

haughty vortex
#

bad

lament rock
#

It's more comparable to scss imo

crimson vapor
#

no programing language is bad

haughty vortex
#

yea, but the only people who use scss are psychopaths

crimson vapor
#

im just joking about how it doesn't compile nor is fast

lament rock
#

Guess I'm psychopathic

haughty vortex
#

they eat icecream holding the chocolate dip instead of the cone

haughty vortex
lusty quest
#

Rust got faster Running Code over GO, while GO is more towards faster Creation of code / compiling, Rust Compiler always try to get the most Efficent Machine Code while GO just goes for fastest compile speed

solemn leaf
#

my node no workie

haughty vortex
solemn leaf
lusty quest
#

hmm maybe i should give up on learning C# and learn Rust instead.

#

or atleast postpone C#

lament rock
mellow kelp
haughty vortex
#

pug CRYBABY

crimson vapor
#

amanda is open sourced?

lusty quest
#

only Psychopaths write extremely clean code.

haughty vortex
lament rock
#

Yes

solemn leaf
#

shift alt f

crimson vapor
#

amanda pog code

lament rock
#

Needs a core framework rewrite. Somewhat messy ever since I moved from discord.js to modular interfaces.

#

The multithreading gains too strong though

solemn leaf
#

node doesnt work anymore

lusty quest
#

did you get an error?

solemn leaf
lusty quest
#

did you copy the node_modules folder somewhere else and then ran it?

haughty vortex
solemn leaf
#

no

lusty quest
#

anyways just delete the node_modules folder and run npm install

slender hamlet
#

just run npm install

solemn leaf
#

didnt owkr

slender hamlet
#

you dont need to delete node_modules

solemn leaf
#

I did that already

lusty quest
#

deleting the folder is just for preventing stupid errors

lament rock
slender hamlet
#

do npm install canvas@latest

#

see what happens

haughty vortex
#

thrown

slender hamlet
#

wait thats not a library

#

is it?

haughty vortex
#

framework

#

really bad framework

#

but still

lament rock
#

This awfully looks like mixin

haughty vortex
#

I only started developing it like

#

3 days ago lol

lusty quest
#

i gift someone 1 year Discord Nitro if he writes a Working Discord bot with atleast 5 Commands in COW

haughty vortex
lament rock
#

I saw. Just the nature sounds a lot like mixin bytecode injection

haughty vortex
#

eh

#

¯_(ツ)_/¯

solemn leaf
#

My download speed is 10 bytes a sec

haughty vortex
#

no idea what that means

#

I don't use java

lusty quest
#

all the time?

solemn leaf
#

so much stuff

#

broke

#

(node:17692) Warning: Accessing non-existent property 'func' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)

lusty quest
#

if you have this slow speed all the time it can cause npm to timeout

solemn leaf
#

it was a joke

#

my download is 1000 mb

lusty quest
#

does it say if its a module?

solemn leaf
#
(node:17692) UnhandledPromiseRejectionWarning: Error: Could not locate the bindings file. Tried:
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\build\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\build\Debug\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\build\Release\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\out\Debug\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\Debug\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\out\Release\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\Release\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\build\default\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\compiled\14.15.4\win32\x64\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\addon-build\release\install-root\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\addon-build\debug\install-root\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\addon-build\default\install-root\better_sqlite3.node
 → C:\Users\Owner\Desktop\Idk\node_modules\better-sqlite3\lib\binding\node-v83-win32-x64\better_sqlite3.node
#

¯_(ツ)_/¯

slender hamlet
#

ok, one sec

lusty quest
#

yea sqlite is fucked

solemn leaf
#

can I update

lusty quest
#

you got Build Tools installed right?

solemn leaf
#

yea

#

should I repair

lusty quest
#

rebuild sqlite

solemn leaf
#

npm rebuild?

lusty quest
#

or just delete the entire node_modules folder and install all dependencies new (if you havent done this)

solemn leaf
#

idk

#

how

#

can we like screens hare

slender hamlet
#

wait

restive furnace
#

learn nodejs and js™

slender hamlet
#

aki needs to update all of their modules

#

i know one way

solemn leaf
#

js has nothing to do with node not working

lusty quest
#

bcs this is the stuff i know that happens if you try to fix one damaged package. for some reason npm fucks it up and you get more modules that are done

slender hamlet
#

no its that your modules are all outdated

solemn leaf
#

ok

restive furnace
umbral zealot
#

Deleting the node_modules folder can indeed help

solemn leaf
#

c path?

umbral zealot
#

in your project folder

slender hamlet
#

it should be in ./

#

yeah

solemn leaf
#

ok

#

then do npm i discord.js canvas e.g.

umbral zealot
#

no just npm i

solemn leaf
#

okay good

umbral zealot
#

your dependencies should be in your package.json

solemn leaf
#

ik

lusty quest
#

usually if i get a broken node module i dont brother with trying to repair it. i just delete the entire folder and get them all new and fresh.

solemn leaf
#

this gonna take a bit

lament rock
#

npm ci

solemn leaf
#

this is just my test bot

lusty quest
#

usually is faster than trying to search throu 10 years old Stackoverflow pages in why this one module breaks

solemn leaf
#

my main bot has so much

lusty quest
#

what is the issue, preferably add your Language to it (Programming Language)

haughty vortex
#

he wants to delete a channel

slender hamlet
#

that specific channel?

lament rock
#

Is this discord.js v11 or Eris?

solemn leaf
#

isnt djs11

lusty quest
#

store the channelid in a database if you want to delete it later. if you want to Delete the channel get or fetch the Channel and call .delete() on the Channel object.

solemn leaf
#

messagechannel is 11

slender hamlet
#

you may want to cache/store the channel id inside the .then

lament rock
#

oh nvm. I looked at the create thinking it was a cache op but it isn't

slender hamlet
#

youll need to introduce a db

#

sql or mongo i'd say

#

my go to

#

unless you already have one

lusty quest
#

you could store in memory but it will be gone if the Process restarts

slender hamlet
#

yeah

#

if its another command i'd assume he wants it persistent

haughty vortex
#

json

slender hamlet
#

no, but you'd want to store the id

#

when it was created

haughty vortex
#

use $create Test

lusty quest
#

well did you want to be able to delete the channel after your Bot Restarted?

haughty vortex
#

it creates #Test

#

use $delete #Test

#

it deletes #Test

#

so just do that

lusty quest
#

ok then you dont need a database

solemn leaf
#

re

lament rock
#

You don't need to store since channel data is sent over GUILD_CREATE which is emitted for each guild your client is in on gateway READY. You can just filter over cache by channel name

slender hamlet
#

you can also just do a channels.fetch where name = argument

#

thats what i did for one of my comands

lusty quest
#

i would get the channel id from the mention

slender hamlet
#

yeah

lusty quest
#

using names is flaky

slender hamlet
#

i have an option for both

#

if you give an id it parses it

#

otherwise it searches by name

lament rock
#

channels.fetch is completely useless unless you delete stuff from the cache. Discord.js handles all cache ops and stuff is guaranteed to be cached unless affected by intents

slender hamlet
#

yeah intents is kinda screwy so i use fetch

lusty quest
#

vanilla d.js should get all guilds and channels with the ready event

slender hamlet
#

if its possible without intents then i generally do it w/o

lament rock
#

Like I mentioned, GUILD_CREATE data includes complete channel data

umbral zealot
#

guilds, roles, channels and emojis are 100% always cached if you're using discord.js

lusty quest
#

unless you use a modified d.js version

#

that handles cache differently

slender hamlet
umbral zealot
#

That would not Be using discord.js

slender hamlet
#

my user cache didnt work correctly until i chose the intent for it

lusty quest
#

some stuff that requires intends

umbral zealot
slender hamlet
#

huh.

umbral zealot
#

User cache is not part of the list I mentioned

slender hamlet
#

ok then

#

my bad

lusty quest
#

or just dont use any framework and connect barebones over Gateway and API

solemn leaf
#

does this mean it is done?

lament rock
#

users and member caches are impacted by intents. You need the GUILD_PRESENCES intent if you want access to full user/member caches

lusty quest
slender hamlet
#

then i'd probably do something like message.guild.channels.cache.foreach

lusty quest
#

it just started to build a module

solemn leaf
#

ok

haughty vortex
#

you don't need indents if you only fetch one user though

solemn leaf
#

never seen it like this

umbral zealot
#

Then it's a good sign

#

building sqlite can take a few minutes

slender hamlet
#

yep

solemn leaf
#

cool

#

bru

slender hamlet
#

lmao

lusty quest
#

but not as long as installing Build Tools on a Potato

solemn leaf
#

what kind of modules do I have on my main bot

lament rock
#

generally speaking, GUILD_MEMBERS and GUILD_PRESENCES is useless unless you absolutely need to track membership status such as moderation/dashboard

slender hamlet
#

sudo rm -rf node_modules

solemn leaf
#

BRUH

slender hamlet
#

lmao

solemn leaf
#

its been minutes

slender hamlet
#

nice

solemn leaf
#

WHAT

umbral zealot
#

you're trying to install at the same time as you're trying to delete?

#

that's not gonna help

solemn leaf
#

im installing for my testing bot rn

slender hamlet
#

well you're hardcoding the deletable channels

solemn leaf
#

im deleting the modules for my main bot

slender hamlet
#

and youre creating a channel instead of deleting it

lament rock
#

having the folder open in another program would give that message. I forget if terminals hold locks on dirs

lusty quest
#

looks like a list of Users with permissions

lament rock
#

fantastic

haughty vortex
#

he's not using Linux so ofc they do

#

or macos

solemn leaf
#

just to delete this

slender hamlet
#

i read that as macros lmao

solemn leaf
#

smh

lament rock
lusty quest
#

did you have your work directory in your Boot drive?

slender hamlet
#

lmao

lusty quest
#

on the root directory?

trim saddle
#

@lament rock just thought of something

lament rock
#

Lets hear it

trim saddle
#

there's always a chance discord could reuse a channel id per guild right

solemn leaf
#

im going to have to switch users

#

to delete a folder

#

I crated on this user

#

what

slender hamlet
#

you'll wanna fetch a channel from the channel cache that has the id the user gave, and delete it instead of creating it

lament rock
#

No. Never will any resource have the same ID

trim saddle
#

oh

trim saddle
#

well you're cute

slender hamlet
#

rn you have message.guild.channels.create(msgArgs)

lusty quest
#

until they run out of ids i guess

slender hamlet
#

me when i have 32 billion channels

lament rock
#

They'll overflow the ID character count. They'll never run out

slender hamlet
#

me when i have 32 billion infinity channels

lament rock
#

Which is why I dislike it when devs specify ID lengths in regular expressions

lusty quest
#

this will delete the message channel. get the channel you want to delete by its name and or id then call delete on the channel you get

lament rock
#

delete accepts an ID or a GuildChannel instance

#

not a string name

#

You have to filter over the guild channel cache

slender hamlet
#

message.guild.channels.delete is not a method

#

youll have to resolve a channel from the id

#

then call channel.delete

#

so youll get an id from the user

#

find a channel with that id

#

and call delete() on it