#development

1 messages · Page 1869 of 1

sick fable
#

💀

#

no eror

#

it shows:

#

I have logged into the bot

clever agate
#

'-'

sick fable
#

'-'

sick fable
#

👍

clever agate
#

@sick fable I forgot to make it public

sick fable
#

K

shy turret
#

Little question, is Cassandra use JSON/BSON database like MongoDB? (ik Cassandra supports JSON, but idk if it is stored in BSON like mongodb) If not, what does it use? (ping me pls)

#

CQL ok

lyric mountain
#

wtf is bson

quartz kindle
#

binary json

lyric mountain
#

and what is a binary json?

quartz kindle
#

BSON (/ˈbiːsən/) is a computer data interchange format. ... It is a binary form for representing simple or complex data structures including associative arrays (also known as name-value pairs), integer indexed arrays, and a suite of fundamental scalar types. BSON originated in 2009 at MongoDB.

#

BSON has a published specification.[4][5] The topmost element in the structure must be of type BSON object and contains 1 or more elements, where an element consists of a field name, a type, and a value. Field names are strings. Types include:

Unicode string (using the UTF-8 encoding)
32 bit integer
64 bit integer
double (64-bit IEEE 754 floating point number)
decimal128 (128-bit IEEE 754-2008 floating point number; Binary Integer Decimal (BID) variant), suitable as a carrier for decimal-place sensitive financial data and arbitrary precision numerics with 34 decimal digits of precision, a max value of approximately 106145
datetime w/o time zone (long integer number of milliseconds since the Unix epoch)
byte array (for arbitrary binary data)
boolean (true and false)
null
BSON object
BSON array
JavaScript code
MD5 binary data
Regular expression (Perl compatible regular expressions ("PCRE") version 8.41 with UTF-8 support)[6]

An important differentiator to JSON is that BSON contains types not present in JSON (e.g. datetime and byte array) and offers type-strict handling for several numeric types instead of a universal "number" type. For situations where these additional types need to be represented in a textual way, MongoDB's Extended JSON format[7] can be used.

lyric mountain
#

so basically a json but encoded in binary?

#

is there any advantage over json at all?

quartz kindle
#

smaller size

lyric mountain
#

ic

boreal iron
#

I smell Wikipedia… somewhere

lyric mountain
#

tim has wikipedia downloaded on his pocket hdd

quartz kindle
#

lel

small tangle
#

Wikipedia downloaded tims knowledge

split hazel
#

tfw v8 engine is on v9.4

pale vessel
#

wtf

earnest phoenix
#

Is there a way define multiple embeds
like
let x && y = new Discord.MessageEmbed()

boreal iron
#

let x = { description: "embed" };
let y = x;

split hazel
#

assuming you just want to make an alias since js by default will reference objects

pale vessel
#

do you want y to be a reference or a completely new instance

earnest phoenix
#
let help = new Discord.MessageEmbed()
    let mod = new Discord.MessageEmbed()
    let info = new Discord.MessageEmbed()
    let fun = new Discord.MessageEmbed()
    let giveaway = new Discord.MessageEmbed()
    let music = new Discord.MessageEmbed()
    let cs = new Discord.MessageEmbed()
    let embeds = [help, mod, info, fun, giveaway, music, cs]
    embeds.forEach(x => x.setColor(client.color.green) && x.setThumbnail(client.user.displayAvatarURL({dynamic: true})) && x.setTimestamp())
split hazel
#

Lord almighty

#

welcome to discord.js

pale vessel
#

Wey not create the embed inside .map()

wheat mesa
#

ew

#

forEach

#

🤮

earnest phoenix
wheat mesa
#

slow

split hazel
#

map wasn't even designed to be a standalone iterator

earnest phoenix
#

I just want to point out that x y and z are embed

coarse topaz
#

Hi, I'm trying to check if the user who reacted to a message doesn't have a specific role, I've got this
!user.member.roles.cache.has(votesRole) but I get an error in the console saying that it can't read property roles of undefined
Could someone tell me how should I set up my code, please?

#

d.js btw

earnest phoenix
#

user.user

#

Not member

#

message.member.user

wheat mesa
#

User objects aren't associated with guilds

#

Member objects are

rose warren
#

message.member.roles

quartz kindle
#

actually no, do this instead: ```js
let [a, b, c, d, e, f] = Array(6).fill().map(() => new Discord.MessageEmbed())

pale vessel
#

didn't know it works like that

quartz kindle
#

actually no they arent

pale vessel
#

Thought one references the other

quartz kindle
#

yeah you're right

earnest phoenix
#

The other is just merging all embeds

quartz kindle
earnest phoenix
#

A.setTitle is not funciton bc this isnt defined as embed

quartz kindle
#

?

earnest phoenix
#
let a = something 
a.setTitle("Some Title")

setTitle() is not function

#

Did you understand?

quartz kindle
#

?

earnest phoenix
#

Hmm

quartz kindle
earnest phoenix
#

Oh okay

#

I probably forgot to change the array count

#

Thanks for help

pale vessel
#

poor embed

coarse topaz
near grotto
#

my bot isn't responding when I'm reacting

#
const embed = new discord.MessageEmbed()
                        .setTitle('Are you sure about that ?')
      const messg = message.channel.send(embed).then((messg) => {
        messg.react('❌').then(reaction => reaction.message.react('✅'))
        const filter = (reaction, user) => (reaction.emoji.name === '✅' || reaction.emoji.name === '❌') && user.id === message.author.id;
        const collector = messg.createReactionCollector(filter, {time: 10000});
        collector.on('collect', r => {
          if(r.name === '✅'){
            message.channel.send('✅')
          } else if(r.name === '❌'){
            message.channel.send('❌')
          }
        });})```
wheat mesa
#

reaction collectors are fine, but I'm pretty sure your problem lies in the fact that you didn't await sending the embed

#

You have to resolve promises

pale vessel
#

the collector is created after the message is sent though

wheat mesa
#

Oh

near grotto
#

how?

wheat mesa
#

Still, isn't the value of messg Promise { <pending> }?

pale vessel
#

now I'm starting to wonder why they assigned it to a variable

coarse topaz
# coarse topaz Thanks for the heads up, I've fixed it <:KoGaMa_ThumbsUp:420947163162607616>

Actually nvm, it's executing the if statement regardless I've the role or not

if (!user.member.roles.cache.has(votesRole)) {
            reaction.users.remove(user.id);
            message.channel.send(`<@${user.id}> You must get the **${message.guild.roles.cache.get(votesRole).name}** before participating in this vote.`).then(message => message.delete({ timeout: 10000 }));
}``` This code is inside a Reaction Collector btw, so "user" is actually referring to the user who added the reaction to the message
grim arch
#

can u attach videos on MessageAttachment?

lyric mountain
#

no

snow urchin
tulip ledge
#

pretty sure u need to install a package

#

not sure what it's called tho

crimson vapor
#

wdym

wheat mesa
#

Good one @crimson vapor KEKW

crimson vapor
wheat mesa
#

🤐

balmy root
#
  if(!message.guild.me.hasPermission("EMBED_LINKS")) {
    return message.channel.send('oh no looks like i dont have embed permission :<, for commands to work right please give me \`EMBED_LINKS\` permission to continue to use the bot')
#

the bots not checking if it has embed perms

#

how does one do it

quartz kindle
#

that only checks for role permissions

#

channel permission overwrites can disable it on specific channels

balmy root
#

thank you

pallid jungle
#
        try{
            data = await schema.findOne({
                userID: message.author.id
            })
            cuser = await schema.findOne({
                userID: mentionsuser.id
            })
            if(!data) {
            data = await schema.create({
                userID: message.author.id
            })
            }
        } catch(err) {
            console.log(err)
        }
            data.credits -= credits
            cuser.credits += credits
#

It's not editing for cuser

lyric mountain
#

mentionsuser

coarse topaz
#

How can I use user from a reaction collector to know if they have a specific role

#

Basically, I want to know if the user who adds a reaction to a message has a specific role
d.js

lyric mountain
#

you can get the member obj from a reaction

#

just check if member has desired role

azure lark
#

how do i wait for a function to finish, without using setTimout ot .then

lyric mountain
#

await it

azure lark
#

how

lyric mountain
#

await <stuff>

azure lark
#

so just await myFunction()

lyric mountain
#

if it is async, yes

#

if it isn't async you don't even need to wait since it'll block execution until it finishes

azure lark
#

its not working

coarse topaz
lyric mountain
#

check the docs to see how to properly get member object from it

quartz kindle
#

you have to get the member object from the guild using the user's id

snow urchin
#

when using baseUrl to import files without ../../ I get this error message. It also loads the scss file correctly but not all the css loads?

#

nextjs ^

quartz kindle
lyric mountain
snow urchin
#

well, I dont, there is just the one

lyric mountain
#

does that file contain same-name stuff?

snow urchin
#

what

lyric mountain
#

multiple modules with same name

snow urchin
#

nope

lyric mountain
#

idk then, did u try running at debug level?

snow urchin
lyric mountain
#

no, I mean, inside the file

snow urchin
lyric mountain
#

try running at debug level to see if anything useful appear in the log

snow urchin
#

next:jsconfig-paths-plugin moduleName did not match any paths pattern styles/Pages/Auth.module.scss +224ms
next:jsconfig-paths-plugin moduleName did not match any paths pattern styles/Pages/Auth.module.scss +1ms
warn - ./src/styles/Pages/Auth.module.scss
There are multiple modules with names that only differ in casing.

lyric mountain
#

we'll need tim

snow urchin
olive remnant
#

I'm having an issue with external emoji and slash commands. My bot has external emoji permissions and can use external emoji outside of a slash command. Inside a slash command, however, the emoji just show up as :emoji_name:s. Is this a known issue? Is there any workaround?

sudden geyser
#

can you show us your source code

coarse topaz
jovial vapor
#

can someone end my suffering and help me with a cmd handler that doesnt hurt replits feelings

split hazel
#

what do you mean hurt replits feelings

#

how can you hurt a machines feelings

jovial vapor
#

whatever i use gives it more errors then people on this planet

olive remnant
#

Whoops, wrong link for the embed

#

That's the correct one

sudden geyser
#

In __hungermoji, you're modifying the dictionary where you're storing the emoji IDs.

#

But you save the ID to a variable before altering it

#

Which is weird

#

So you end up with a situation where the value will be the ID if it's never been touched before or the string to render on Discord if it has

#

I don't think it was intentional

#

oh something I missed

#

you reassign emoji to the actual emoji and return that

olive remnant
#

I do need to change this function to just hardcode the values (I did it this way because of a mistaken assumption on my part originally). However, making that change doesn't actually fix it

#

If I change it to "no_hunger": "\:no_hunger:", I still get the bug

#

bleh, Discord messed up my formatting

#

If I change it to that, the bug still occurs

quartz kindle
#

for example message.guild or channel.guild

#

its not a free floating global variable

coarse topaz
#

got it, will try again KoGaMa_ThumbsUp

#

it works now, thanks!

jovial vapor
#

can someone end my suffering and help me with a cmd handler djs v12 compatible

lyric mountain
#

Yk v12 is deprecated right?

split hazel
#

i miss the time when they didnt instantly kill their older library

coarse topaz
#

if it's deprecated why can we still use it

split hazel
#

deprecated means you can use it but not recommended

#

and they wont support it anymore

lyric mountain
#

There are 3 phases

#

Deprecated is like the second

coarse topaz
lyric mountain
#

Which means "it MIGHT work, but expect sudden death at any moment"

coarse topaz
lyric mountain
#

Ye, better while you're still small

#

The later you start the more work you'll have

coarse topaz
lyric mountain
#

Nope

split hazel
#

you wish

coarse topaz
split hazel
#

discordjs wouldnt be that kind

lyric mountain
#

Btw, do you plan adding different languages on ur bot?

coarse topaz
lyric mountain
#

...languages as in english, spanish, german, etc

earnest phoenix
#

i18n

lyric mountain
#

Just say yes or no spongery

coarse topaz
#

ah lmao sorry
Nah, the current bots I program are made for very specific servers & purposes. Some years ago my dream was to create an actual cool bot and submit it to top.gg but I gave up

lyric mountain
#

Ok, you're fine then

split hazel
#

if anyone knows are javascript objects just hash maps under the hood

coarse topaz
#

So no, they'll keep English as main and only language

lyric mountain
#

I asked because for i18n stuff you need to start at the very beginning

earnest phoenix
#

i18n is annoying as fuck

lyric mountain
#

You can't simply change your mind later

#

It's not humanely possible to implement i18n in an old project

earnest phoenix
#

It is the kind of thing that you wanna make sure you're going to support multiple languages from the very beginning as it can be as KuuHaKu said quite challenging to implement later on

#

Not to mention implementing it properly can be rather annoying

coarse topaz
#

I see lol

sudden geyser
lyric mountain
#

But then it's too late 😩

earnest phoenix
#

Implementing i18n late is annoying as fuck

#

It is something i'd much rather do from the beginning

#

At least have some basic implementation that can be built upon later

lyric mountain
#

Me too, wish someone told me when I started

earnest phoenix
#

I have yet to successfully use i18n cause of how annoying I found it

sudden geyser
#

Implementing i18n is going to be annoying no matter what time you chose to adopt it

lyric mountain
#

Now all I have is a half-assed i18n implementation

#

Like, 10% collected

earnest phoenix
#

Klay you it is 10x more annoying doing it in a project that is already built up

sudden geyser
#

And adopting it early may just lead you to walk in the dark thinking "yeah this works!" only to realize it doesn't (or very poorly) when you add another language

lyric mountain
#

But I don't see myself collecting all the 3 thousand strings in near future

earnest phoenix
#

I don't have any major project going on right now that requires i18n

#

Nor do I have the patience to implement or work on a project that could use it

coarse topaz
#

Is i18n the only option for implementing translations to your bot though?

earnest phoenix
#

Probably not

#

but it is the most popular

sudden geyser
#

i18n stands for internationalization (often with localization added), so it is the way to translate a bot

earnest phoenix
#

Yea

coarse topaz
#

that sucks

boreal iron
#

It’s not like it would be complex to create language files in the ini or JSON format, load a default language file, parse the file into vars (or a language obj), then load an additional language and overwrite all existing language vars to prevent incomplete language files from missing anything

#

Just a few functions to load the files and parse the content, that’s it

#

But you really need to be consequent to not use any text to output in your code

quartz kindle
#

js Map is a hashmap, but objects can be a bunch of different things depending on how many items and what type of items it holds

#

yes its complicated

modest maple
#

man

#

that seems

#

highly un-optimised

coarse topaz
#

Btw, how can I check how many reactions have the collector collected?
I tried with console.log(<Collector>.collected.size) but it doesn't display anything in the console

quartz kindle
#

its optimized for performance, not for memory usage

modest maple
#

From the language that treats every number as a float

quartz kindle
#

also vastly depends on the js engine, thats how v8 does it

modest maple
#

it has maps that are massive complicated structures lol

#

and yeah

#

whats the general lookup time on a JS map?

quartz kindle
#

also fun fact, v8 stores 32 bit ints as actual 32 bit ints, even though js treats them as doubles

quartz kindle
modest maple
#

sorry i mean in actual timing

quartz kindle
#

like in nanoseconds?

modest maple
#

bloblul I would expect its generally O(1) otherwise it would be a yikes

#

yeah

quartz kindle
#

idk, a few hundred nanoseconds i guess? lmao

modest maple
#

Im just curious because if they do it for performance you'd expect it to be faster than things like Python for actual access time

#

otherwise it be needless complication

quartz kindle
#

in some cases it might be

#

but its hard to benchmark these things

quartz kindle
#

microbenchmarking in v8 is hell

#

"oh you're benchmarking this piece of code? here let me precalculate, predict and compile the outcome and give you the result instead of running your code :)"

modest maple
#

xD

#

Python sits at around 40 - 50ns per lookup

#

which amazes me

blissful coral
modest maple
#

Sip apparently your server no work

blissful coral
#

Well

#

It works

#

Then randomly

#

On no interval or a set way

#

It just sends a 520 back

#

Could it be I am calling too many times?

modest maple
#

shrug Ask the server

blissful coral
#

It's my VPS KEKW

modest maple
#

is this http status codes

blissful coral
#

looks like it yup

pallid jungle
#
module.exports = {
    name: 'error',
    async execute(client, error) {
        try {
            throw new Error('Whoops!')
          } catch (error) {
            const embed = new Discord.MessageEmbed()
            .setAuthor(client.user.username, client.user.displayAvatarURL({dynamic: true, size: 2048}))
            .setTitle(error.name)
            .setDescription(`\`\`\`${error.message}\`\`\``)
            .setFooter('Error!')
            .setTimestamp()
          }

How to make it send error from any code in the bot ?

modest maple
#

then in that cases webserver is committing http genocide

blissful coral
#

But the second I send another one it works Thonk

earnest phoenix
blissful coral
#

Snh

#

Smh*

earnest phoenix
#

also you just send the embed to the channel

pallid jungle
#

It's not sending

#

anything

blissful coral
#

It's only happening on this bot, maybe its just because its being hosted locally

blissful coral
#

My 2 bots on my vps are working perfectly fine with it KEKW

#

?

pallid jungle
#

nvm

blissful coral
#

My new bot is working besides the fact I can't edit my webhook on top.gg KEKW

azure lark
#

how would I make a cli have commands like npm init not npm --init

lyric mountain
#

just like you do commands for bots

#

technically bots are CLI applications

azure lark
#

they are??

lyric mountain
#

ye

#

MLI applications I'd say

#

message line interface KEKW

azure lark
#

also, is the only way to make custom cmds, to use bin?

lyric mountain
#

you can make cli apps with any language

#

tbf, they are the first kind you learn when starting

azure lark
#

I'm trying to make a cli for a npm package to help users manage, so they can do commands like "ch help" and it will log a help message

lyric mountain
#

you can do with node if you're used to it

earnest phoenix
#

@sinful belfry

#

bad dood here

sinful belfry
#

ty

earnest phoenix
#

np

olive remnant
#

Okay, I stripped out the bot.get_emoji() code and hard-coded the emoji strings into my code. Verified once again the bot has permission to post external emojis. Verified the @everyone role has external emoji permissions.

Bot still won't display external emojis using slash commands. It uses them just fine in non-slash-command interactions

olive remnant
#

Okay! Finally figured it out. Turns out the channel we have for bot testing didn't have the permission set, but every other channel did. 🤦‍♂️ But it works now

proven lantern
#

can i change the True False text for booleans?

lyric mountain
#

but they are

lyric mountain
proven lantern
#

Yes, delete my profile
No, don't delete my profile
i might need to use choices

lyric mountain
#

oh, yeah, u'll need a dropdown for that

#

slash don't allow customizing that far

azure lark
lyric mountain
#

you can make it however you want, the syntax is totally up to you

#

just like a normal bot

azure lark
#

oh alr,

lyric mountain
#

they use - or -- because grabbing params is somewhat easier if they all contain a common prefix

azure lark
#

ohhh okay,

lyric mountain
#

you can have as many args as you want

#

just split by space

azure lark
#

but like,

#

i want multiple cmds,

#

like

lyric mountain
#

then do it

azure lark
#

ch help

#

and , ch setup

#

but how?

lyric mountain
#

literally treat the cli app as a bot

#

use a command manager

#

good way to practice making command managers I'd say since you'll only have a single param

#

which is the message itself

azure lark
#

i have a simple cmd,

#

where user dose, ch -n <name>

lyric mountain
#

think as if you were making a bot, how would you process that message?

#

like, I sent ch -n blabla

#

how would you execute that command?

azure lark
#

as in with a cmd handler?

lyric mountain
#

ye

azure lark
#

well i would define prefix

#

which would be ch

lyric mountain
#

yes

azure lark
#

then i would get cmds folder

lyric mountain
#

in that case, you didn't define a command at all, only the params

azure lark
#

ohhhh

lyric mountain
#

so you'd need something like ch setname -n something

azure lark
#

the cmd is -n

lyric mountain
#

can be, sure

azure lark
#

lol i am confused

lyric mountain
#

normally params are the ones with - prefix

#

but it's exactly as you were saying

#

check if message has prefix ch

#

if yes, find command with name -n

#

if found, pass args to it and execute the code

azure lark
#

but how do i check when a cmd was sent

lyric mountain
#

you don't need to

#

actually, yes you do, but it's simpler than discord

#
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', text => {
  console.log(text);
  if (text.trim() === 'quit') {
    done();
  }
});

function done() {
  console.log('Now that process.stdin is paused, there is nothing more to do.');
  process.exit();
}
#

very similar to d.js

#

to keep process alive just put it on an infinite loop

#

although I guess stdin will already do it

azure lark
#

im so confused lol

lyric mountain
#
process.stdin.on('data', text => {
  console.log(text);
  if (text.trim() === 'quit') {
    done();
  }
});

imagine this is a d.js event

#

like client.on('message'

azure lark
#

yes

lyric mountain
#

but instead of an event object all you'll have is a string

#

text will be whatever the user typed

azure lark
#

ok

azure lark
lyric mountain
#

ye

azure lark
#

and i use a bin file to execute?

jovial vapor
#

can someone help me out with a command handler? v12?

sudden geyser
#

You know v12 is deprecated right.

#

And please don't ask to ask.

#

Just explain your problem.

thorny flume
#

help

      if (fields[key].$elemMatch) {
                      ^

TypeError: Cannot read property '$elemMatch' of undefined
    at model.Query._castFields (/home/runner/tbz/node_modules/mongoose/lib/query.js:5008:23)
    at model.Query.<anonymous> (/home/runner/tbz/node_modules/mongoose/lib/query.js:2341:23)
    at model.Query._wrappedThunk [as _findOne] (/home/runner/tbz/node_modules/mongoose/lib/helpers/query/wrapThunk.js:27:8)
    at /home/runner/tbz/node_modules/kareem/index.js:370:33
    at processTicksA
#

what... lol

sudden geyser
coarse topaz
#

Hi, I've a question
So I'd like to store a role's members.size value to use it later, the problem is that if I define it this way: js const role = message.guild.roles.cache.get("id").members.sizerole's value may vary, as people may get that role added/removed in the meantime

So how could I store it so that it's a non-editable value?

earnest phoenix
#

Uhm just dont change the value after storing it?

coarse topaz
#

But it's not possible - People might get that role added/removed from themselves while the code is running, and it may affect the final result

wheat mesa
#

Is that line of code being run multiple times?

lament rock
#

the value should only be assigned once the client reaches a ready state

wheat mesa
#

^^

coarse topaz
#

maybe I could put the value into a string and call it later?

wheat mesa
#

So you want it to run once, get the value, then never run again?

coarse topaz
lament rock
#

You should do what I suggested.

let amount = 0;
client.once("ready", () => {
   amount = getRoleCountHere();
});
#

maybe even store the value in a database so that it's persistent if you need it to be

coarse topaz
#

Alright, thanks! KoGaMa_ThumbsUp

coarse topaz
#

I've another idea, what if I update the message embed where role's value is each 1 hour?
Would this code be a good idea?

do {setTimeout(function(){m.edit(embedNameHere)}, 3600000)} while (gameVoteCollector.ended === false);```
Every time it edits the message, role's value will get updated
#

setInterval may be better lol

humble crane
#

Is there any link shortner for bot invite url

old cliff
carmine magnet
humble crane
#

K ty

errant flax
#

how do i make my own oauth2 handler?

earnest phoenix
#

🎉

near grotto
#

ohh ok

near stratus
# errant flax how do i make my own oauth2 handler?

Follow these steps
(I wrote this for someone else tho)

  • The user goes to Frontend React app (/login)
  • You redirect to Discord Oauth2 api (discord.com/oauth2/....)
  • The user clicks accept
  • The user gets forwarded to your Front-end React with a code (3000/login?code=THE_CODE)
  • You get the code inside react and send a request to the backend (The user stays on /login page and watches a loading screen)
    Meanwhile in Backend
  • The express app receives the request with code
  • It authorizes using the discord api
  • It generates a random token
  • It saves the data and token to database
  • It sends the user data and token to Frontend (React) as a response to the request.
    Now in Frontend (React)
  • The app receives the response containing user data and token
  • Stop the loading screen and show the data you received
  • Save token in cookies / localStorage for future use
errant flax
#

wait so u mean if a user authenticates through discord then discord does a request from the link ive provided?

#

if so that kinda makes sense isee

near stratus
#

huh ?

errant flax
#

shit

#

:misosface:

near stratus
#

When you set up oauth2 you get a code / token in your redirect uri/url

errant flax
#

ah

near stratus
#

You generate the token with the code in Backend

#

You use the token to get user data

errant flax
#

how do i get the code exactly

#

and how do i generate a token to get user data megathonk

near stratus
errant flax
#

ohh

#

so its in.. req.query correct?

near stratus
#

yes

near stratus
# errant flax how about this?
const oauthData = await fetch("https://discord.com/api/oauth2/token",
                {
                    method: "POST",
                    body: new URLSearchParams({
                        client_id: clientID,
                        client_secret: clientSecret,
                        code: code,
                        grant_type: "authorization_code",
                        redirect_uri: URL,
                        scope: "identify guilds",
                    }),
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded",
                    }
})
errant flax
#

ahhh

#

whats redirect_uri

#

is that the redirect url?

mild bone
#

woah

#

hi

near stratus
#

uri / url

errant flax
#

and whats URLSearchParams is that something i need to worry about or it's just a NodeJS/Js thing

near stratus
errant flax
near stratus
#

People (like me) literally spent hours just to find out the data type isn't json and URLSearchparams

#

Thus making it the most complicated process of the oauth2

errant flax
#

so how do i prevent that from happening/what do i do about it

slender thistle
#

Discord interactions are dumb, try and change my mind

cinder patio
#

URLSearchParams is literally ?param=value&param2=value

near stratus
errant flax
#

Is that a default thing?

#

or do i need something to "provoke" it

near stratus
#

It's probably built in

errant flax
#

ah

#

thx for the help!

near stratus
rich copper
#

Can anyone explain me how can I host bot 24/7 free

#

Thanks

quartz kindle
rich copper
#

are they safe?

quartz kindle
#

yes

rich copper
#

Kk tenks

rich copper
quartz kindle
#

idk, try it

rich copper
#

Kk

split hazel
errant flax
modest maple
#

Yeah

#

You have to verify the coe3

#

Nothing on the web from the client side can be taken as valid or correct

errant flax
#

so how do i check if its a real one?

cinder patio
#

you generate the code server-side, and after the user gets redirected you compared the generated server-side value with the search parameter value

errant flax
#

"generate the code server-side"
wdym megathonk

cinder patio
#

oop I'm confusing code with state

#

Just make the request for the user's access token and if you get an error then it's not valid

errant flax
#

ah

errant flax
cinder patio
#

yeah

earnest phoenix
#

Why my bot doesn't found commands folder at line 7 ?

#

he say me - no such filee or directory -

errant flax
#

lol what

#

"illegal request"

#

:iara_saywhat:

#

help

#

code

const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
  id: "884689851272810497",
  secret: process.env.client_secret,
  scopes: ["identify"],
  url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
  axios.request({
    url: `https://discord.com/api/v9/oauth2/token`,
    data: new URLSearchParams({
      clientID: client.id,
      client_secret: client.secret,
      code: code,
      grant_type: "authorization_code",
      redirect_uri: client.url,
      scope: client.scopes.join(" ")      
    }),
    headers: {
      "Content-Type": "application/x-www-form-url-encoded"
    }
  }).then(res=>{
    console.log(res)
  }).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())

app.get(`/`,(req,res)=>{
  res.redirect(`/login`)
})

app.get(`/login`,(req,res)=>{
  if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
  getToken(req.query.code)
})

app.listen(2000)
azure lark
#

is there any way to make a collection with plain js?

errant flax
#

wdym by "collection"

pale vessel
pale vessel
#

That's what a Collection is

errant flax
#

ohh

#

lel

errant flax
tulip marsh
#

hi can anyone help me out

#

this is coming when i made a new file for invite cmd

#

and this shows me when i run the cmd

#

@drowsy crag please see this

#

its a phising

#

link

errant flax
#
const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
  id: "884689851272810497",
  secret: process.env.client_secret,
  scopes: ["identify"],
  url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
  axios.request({
    url: `https://discord.com/api/v9/oauth2/token`,
    data: new URLSearchParams({
      clientID: client.id,
      client_secret: client.secret,
      code: code,
      grant_type: "authorization_code",
      redirect_uri: client.url,
      scope: client.scopes.join(" ")      
    }),
    headers: {
      "Content-Type": "application/x-www-form-url-encoded"
    }
  }).then(res=>{
    console.log(res)
  }).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())

app.get(`/`,(req,res)=>{
  res.redirect(`/login`)
})

app.get(`/login`,(req,res)=>{
  if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
  getToken(req.query.code)
})

app.listen(2000)
#

Its saying its a "Bad Request" and sending a status code 400

tulip marsh
errant flax
#

"Do not @mention people randomly"

tulip marsh
dense flame
tulip marsh
dense flame
#

Please provide the code and error so we can help easier

tulip marsh
#

idk when he cmd gets run then error comes

#

or else no error

errant flax
earnest phoenix
#

replit lol

dense flame
tulip marsh
earnest phoenix
tulip marsh
errant flax
#

send the code in a pastebin or something

tulip marsh
errant flax
#

cuz were not gonna zoom in ur code

tulip marsh
tulip marsh
earnest phoenix
dense flame
tulip marsh
earnest phoenix
#

basically is free

#

good price imo

tulip marsh
#

i see that

errant flax
#
const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
  id: "884689851272810497",
  secret: process.env.client_secret,
  scopes: ["identify"],
  url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
  axios.request({
    url: `https://discord.com/api/v9/oauth2/token`,
    data: new URLSearchParams({
      clientID: client.id,
      client_secret: client.secret,
      code: code,
      grant_type: "authorization_code",
      redirect_uri: client.url,
      scope: client.scopes.join(" ")      
    }),
    headers: {
      "Content-Type": "application/x-www-form-url-encoded"
    }
  }).then(res=>{
    console.log(res)
  }).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())

app.get(`/`,(req,res)=>{
  res.redirect(`/login`)
})

app.get(`/login`,(req,res)=>{
  if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
  getToken(req.query.code)
})

app.listen(2000)
dense flame
#

not sure about your issue

#

seems like an error form axios

dense flame
tulip marsh
#

and one more prb lol

#

need a hositng

#

free

dense flame
#

heroku or repl are the only free ones that I know at least

tulip marsh
cinder patio
#

you're making a get request rn

tulip marsh
#

as for me the imp this is members privacy and data

tulip marsh
#

😮‍💨 e

dense flame
#

but vps are not free

tulip marsh
dense flame
#

you can search for it

tulip marsh
#

:((

snow hedge
#

Does someone know the discord sys req?

tulip marsh
errant flax
#

@cinder patio

const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
  id: "884689851272810497",
  secret: process.env.client_secret,
  scopes: ["identify"],
  url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
  axios.request({
    url: `https://discord.com/api/v9/oauth2/token`,
    method: "POST",
    data: new URLSearchParams({
      clientID: client.id,
      client_secret: client.secret,
      code: code,
      grant_type: "authorization_code",
      redirect_uri: client.url,
      scope: client.scopes.join(" ")      
    }),
    headers: {
      "Content-Type": "application/x-www-form-url-encoded"
    }
  }).then(res=>{
    console.log(res)
  }).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())

app.get(`/`,(req,res)=>{
  res.redirect(`/login`)
})

app.get(`/login`,(req,res)=>{
  if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
  getToken(req.query.code)
})

app.listen(2000)
cinder patio
#

That means bad request

errant flax
#

yes ik but i can't find the error that causing this

cinder patio
#

There's nothing wrong with the code itself, the data you're sending to discord is not correct

errant flax
#

how do i correctly send data then

#

:megathonk:

cinder patio
#

It's client_id, not clientID

errant flax
#

oh

jaunty ore
#

Hello

errant flax
#

still saying Bad Request

#
const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
  id: "884689851272810497",
  secret: process.env.client_secret,
  scopes: ["identify"],
  url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
  axios.request({
    url: `https://discord.com/api/v9/oauth2/token`,
    method: "POST",
    data: new URLSearchParams({
      client_id: client.id,
      client_secret: client.secret,
      code: code,
      grant_type: "authorization_code",
      redirect_uri: client.url,
      scope: client.scopes.join(" ")      
    }),
    headers: {
      "Content-Type": "application/x-www-form-url-encoded"
    }
  }).then(res=>{
    console.log(res)
  }).catch(res=>console.log(res.toJSON()))
  
}
app.use(express.json())

app.get(`/`,(req,res)=>{
  res.redirect(`/login`)
})

app.get(`/login`,(req,res)=>{
  if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
  getToken(req.query.code)
})

app.listen(2000)
jaunty ore
#

I not it English hehe

errant flax
jaunty ore
#

:( what your from?

cinder patio
#

I dunno, check if process.env.client_secret is correct

errant flax
#

k

errant flax
cinder patio
#

you mean a secret?

#

it can be whatever you want

#

or do you mean to regenerate an access token?

jaunty ore
#

sorry, how do you change the language?

errant flax
#

like converting the code into a token

jaunty ore
#

are you hackers?

noble coyote
#

haxta

errant flax
#

anyways thx for ur help

sacred aurora
#

@errant flax try removing the scope

errant flax
#

why?

sacred aurora
#

umm you already do that from the authorization?

#

seems useless sending it again

jaunty ore
sacred aurora
jaunty ore
#

I can't speak English :(

errant flax
#

still the same lmao

sacred aurora
#

ah wait a sec

#

you need to make it a string

#

new URLSearchParams({...}).toString()

#

try it

jaunty ore
sacred aurora
#

nvm its the same

#

or maybe you have a typo

#

@errant flax isn't it application/x-www-form-urlencoded

#

you write it application/x-www-form-url-encoded

jaunty ore
#

I can't speak English. Help me :(

errant flax
sacred aurora
jaunty ore
errant flax
#

sill an error

sacred aurora
#

hmm

#

dunno then

errant flax
#

pOg it WoRkS

#

ive fixed it by:
fixing the typo on Content-Type
and making data a URLSearchParams class

opaque seal
#

Is there a max amount of slash commands a bot can have?

pale vessel
near stratus
azure lark
#

why dosent this work?
I have defined cmd and the file exists but it keeps telling me it cant find module .src/command/commandname.js

fs.access(`./src/commands/${cmd}.js`, (err) => {
    if (err) {
        console.log("The file does not exist.");
    } else {
        const command = require(`./src/commands/${cmd}.js`)
        command()
    }
});```
opaque seal
earnest phoenix
opaque seal
earnest phoenix
#

Nah

opaque seal
#

ah ok I'm good then

earnest phoenix
#

It's still just one command

opaque seal
#

thx

crystal wigeon
#

hey umm

#

anyone use nestjs?

#

i just ran the basic nest new app and when i try to start the application it keeps throwing some "unexpected token in dist/app.controller.js" error

#

like bruh i haven't made any changes yet

#

just the basic boilerplate

earnest phoenix
#

Skill issue

crystal wigeon
#

..

#

literally basic file generated by nest

quiet topaz
#

why does it say that when its on raspberry pi but not in cmd on windows?

earnest phoenix
#

It says that because typescript is java 2.0

quiet topaz
#

okay i solved it myself

errant flax
#
refreshToken(token){
    return new Promise((resolve,reject)=>{
      axios.request({
        url: `https://discord.com/api/v9/oauth2/token/revoke`,
        method: "POST",
        data: new URLSearchParams({
          client_id: this.client.id,
          client_secret: this.client.token,
          grant_type: "refresh_token",
          refresh_token: token
        }),
        headers: {
          "Content-Type": `application/x-www-form-urlencoded`
        }
      }).then(res=>{
        resolve(res)
      }).catch(res=>{
        reject(res)
      })
    })
 }
#

??

signal estuary
#

How can I make the collector listen just to the right interaction reply. So If I send 2 command where to bot replies with a message with components the collector listens to both.
I cant do like

let message = await interaction.reply()
message.createMessageComponentCollector({})
//message is always undefined

any help?

pale vessel
#

await it and make sure to add fetchReply

pale vessel
#

await interaction.reply({ fetchReply: true }) if I recall correctly

jaunty ore
#

is there anyone who is still studying in the IT field?

jaunty ore
#

some are still in school majoring in tkj

quartz kindle
#

i never finished school

jaunty ore
quartz kindle
#

idk, 7th grade?

jaunty ore
jaunty ore
quartz kindle
rose warren
#

School is overrated for some people / jobs. I wasted 2 years at college studying something I didn't really enjoy and dropped out.

quartz kindle
#

agreed

rose warren
#

Have you ever had any formal programming classes Tim?

#

Or all self-taught?

jaunty ore
quartz kindle
#

self taught from there on

rose warren
#

Same lol

jaunty ore
rose warren
#

Now I sell websites to small businesses dog_Joy

quartz kindle
#

we traveled for a few years in brazil, then i never joined school again

rose warren
#

I dropped out of college because it wasn't what I wanted to do (studying Chinese and Spanish). And since I was already self-taught in development and graphic design and I already had that side hustle, I just didn't see the need for school at all.

quartz kindle
#

nihao

rose warren
#

Yeah that's the limit of my Chinese too dog_Joy

quartz kindle
#

lmao

rose warren
#

It was interesting, but I just don't do well in a school environment

quartz kindle
#

ye

#

for me, it still took me almost 10 years before i actually started working with programming

jaunty ore
#

How do you add bot music to our discord?

quartz kindle
#

i was more interested in tech and repair back then

#

my js skill was attrocious when i started working on discord bots in 2017 lmao

rose warren
#

Same. I was more used to PHP from web dev. Making Discord bots has definitely helped my JS skills lol

#

Obviously there's a bit of JS in web dev but not a lot.

quartz kindle
#

the only php i knew was from working with wordpress and i hated it lmao

near stratus
quartz kindle
#

i also didnt know how to use wordpress properly, so i did some horrendous things with it xD

#

meaning that i couldnt update wordpress because it would break my shit

#

and eventually i got hacked

#

because wordpress security is good™️

rose warren
#

Lol

errant flax
#

so what were talking

quartz kindle
#

got a website filled with malware and ads for pharmacy bullshit like viagra

#

lmfao

rose warren
#

Lmao yeah I always bulk up the wp security a bit for clients

quartz kindle
#

i was great at writing unmaintainable websites :^)

#

but i got tired of web dev, i dont do it professionally anymore

quartz kindle
# errant flax how...

wordpress is famous for its bad security, so you have to always update it, otherwise you're vulnerable to exploits and shit

rose warren
#

Yeah I don't know if I really like client work anymore. Making a Discord bot with a premium model has made me realise maybe SAAS is the way to go.

errant flax
#

SAAS?

rose warren
#

WordPress is like the #1 CMS so if people find an exploit you can bet they're gonna make money out of it.

rose warren
quartz kindle
#

isnt it software as a service?

#

same thing anyway lel

errant flax
#

is the refresh_token for the OAuth2 app valid forever?

jaunty ore
rose warren
frigid solar
#

hello

#

Do you have a code that makes my bot change the nickname of the new member automatically when he enters my server

jaunty ore
wheat mesa
#

By that do you mean you have an existing piece of code that you want help with, or you just want the code given to you @frigid solar

wheat mesa
#

Welp, can’t do that for ya 😛

#

We don’t spoonfeed code in this channel

frigid solar
#

Why

frigid solar
wheat mesa
frigid solar
#

here

wheat mesa
#

Having someone else write your code for you doesn’t teach you anything

near stratus
frigid solar
#

We are in this rum

near stratus
wheat mesa
#

This server doesn’t spoonfeed code

frigid solar
#

Do you have a code that makes my bot change the nickname of the new member automatically when he enters my server
@near stratus

wheat mesa
#

Either use Google like suggested, or we can offer help on how you can get started with that functionality

frigid solar
near stratus
frigid solar
#

thx

jaunty ore
#

how to add music bot

near stratus
frigid solar
#

@near stratus

#

where is the code

#

??

wheat mesa
#

🤦‍♂️

#

It’s documentation for what you’re trying to do

near stratus
#

someone kill me

earnest phoenix
#

🔪

near stratus
#

thank you

earnest phoenix
#

np*

frigid solar
#

Why are you laughing at me

wheat mesa
#

To update the nickname like you want, you should set the user’s nickname on the guildMemberAdd event

frigid solar
#

I'm learning

wheat mesa
#

You’re not learning if you’re expecting people to just give you code for you to copy paste

slender wagon
#

uh how do i check if my bot has permissions to ban, like i want to check all the guilds that my bot is in and make my bot leave all the servers that it doesn't have ban perms in

jaunty ore
earnest phoenix
#

Why i have this error ? (the folder exists, see on the left) thx

[Error: ENOENT: no such file or directory, scandir '../commands/'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'scandir',
  path: '../commands/'
}
/moontest/events/ready.js:12
        if(content.length < 1) return;
                   ^

TypeError: Cannot read property 'length' of undefined
    at /moontest/events/ready.js:12:20
    at FSReqCallback.oncomplete (node:fs:185:23)```
frigid solar
#

Can I ask for another help

wheat mesa
#

Yes

frigid solar
#

How can my bot be verified

#

??

wheat mesa
#

On top.gg, or on Discord itself?

#

Huh

#

I didn’t answer your question

earnest phoenix
# slender wagon using d.js 13
const { Permissions } = require("discord.js");
if((bot).guild.me.permissions.has(Permissions.FLAGS.BANS_MEMBERS) console.log("Great, i have the perm !")```

try this
wheat mesa
#

To get verified on discord, you’ll have to look at their requirements for bots, but you can start the verification process once your bot reaches 75 servers

jaunty ore
earnest phoenix
frigid solar
earnest phoenix
# frigid solar

For you, when the guildMemberAdd is emit, do a action for the bot change her nickname.

frigid solar
frigid solar
#

??

earnest phoenix
#

ye, logic

frigid solar
#

ok

#

thx

earnest phoenix
#

example: i don't have perm to change my nickname in this server because i don't have required perms. Is same for you

#

otherwise the perm change nickname will not exist

jaunty ore
errant flax
#

hey is refresh_token valid forever???

jaunty ore
#

F1?, F2?

frigid solar
earnest phoenix
errant flax
#

?

jaunty ore
earnest phoenix
#

i don't understand ur question @errant flax

wheat mesa
#

A quick google search can teach you how to take a screenshot

errant flax
#

is refresh_token valid?
from the OAuth2 thing

wheat mesa
jaunty ore
slender wagon
#
    const guildIds = client.guilds.cache.map(g => {
      return g.id
    })

i am trying to make this select all the guilds that the bot has ban perms

#

is there a way i could do that

frigid solar
quartz kindle
wheat mesa
#

Or snipping tool 😎

quartz kindle
slender wagon
#

aye thx

jaunty ore
jaunty ore
quartz kindle
#

you have prtsc right?

#

click prtsc, then ctrl+V on discord

jaunty ore
#

where do you come from?
can you teach me how to install music bot?

slender wagon
#
const guildIds = client.guilds.cache.map(g => {
      return g.me.permissions.has("BAN_MEMBERS").id
    })

ayo tim is this supposed to only get the guild ids that the bot has ban perms in?

sudden geyser
#

has returns a boolean

#

You should use filter on the guild cache

#

And return the Boolean rather than trying to get out the id

#

Then you'll have a collection of guilds where your bot has permission to ban members

earnest phoenix
#

you can filter the collection after mapping

sudden geyser
#

That's just logically more inefficient

quartz kindle
jaunty ore
#

I still don't understand can you teach me again, sorry I still don't understand 😦

quartz kindle
#

that will give you entire guild objects

#

not ids

#

if you want ids you can map it afterwards

#

.filter(...).map(g => g.id)

slender wagon
#

ohh alrightys

quiet topaz
#

So I have two typescript files, and i want to get variables from file1 in file2, how can i do that?

wheat mesa
#

export them

quiet topaz
#

but i think it wont work, as file2 has an event listener, which is in a functionn. which is exported. but the variables will change over the time, so i want to get the variables when the event happens

quartz kindle
#

show code

quiet topaz
#

well its lot of code

quartz kindle
#

then show a simple version of what you want to do

#

which variables etc

quiet topaz
#

ok wait

#
//file1.ts
import {func1} from "file2.ts";
let val1 = "something";

func1(val1);

val1 = "something else";
//event happens now
//file2.ts
export function func1(someVal){
event.addListener("event1",()=>{
//do Something with someVal
});
};
#

something like that

signal estuary
#

I have here an array with .mp3 files.
So how can I play the next song after the last song ends:
Sth like this (doesnt work of course)

        let pathM = path.resolve('./music')
        const playlist = fs.readdirSync(pathM).filter(file => file.endsWith('.mp3'));
        console.log(playlist.length)
        for (let i; i < playlist.length; i++) {
            const resource = createAudioResource(path.resolve(`./music/${playlist[i]}`));
            player.play(resource);
        }
quartz kindle
#

one option is to have a separate function to update the value

#

another option is to put the listener in file1

quiet topaz
quartz kindle
#

file1 sorry

earnest phoenix
#

Ask the gods who created React.useState

quartz kindle
#

you can also export an object and modify its properties

earnest phoenix
#

How do they track the value of a variable

quiet topaz
#

i will have multiple event varaibles (where i add the listener)

#

wait i have an idea

quartz kindle
#

i mean, the proper way would be to have functions to update it

#

but an object should also work

#

for example

quartz kindle
#
// file2
export {
  prop: 10,
  start: function() { event.addListener(/* do something with this.prop */) }
}

// file1
import * as obj from "file1"
obj.start()
obj.prop = 20
#

idk how typescript parses this, the object has to be imported as a reference and not destructured

#

but a more correct way would be to use functions

quiet topaz
#

how could i do that with the functions ?

quartz kindle
#
let prop = 10;
export function start() { ... }
export function update(val) { prop = val; }

// file1
import { start, update } from "file2"
start()
update(20)
tulip ledge
#

don't you have to export default tho?

#

Or am I being stupid

quartz kindle
#

probably yes

#

either export default object, or export = {}

tulip ledge
#

yeah

pale vessel
#

Not on the last one though

quartz kindle
#

ye, not needed in the functions method

tulip ledge
#

yeah but I was talking about the first one

stray seal
#

Me and my friend made a bot together. He gave me the file to add it for me and i downloaded it and added to my code sorce and this is what i got:

5Pm�B�l�G���}_�O�'�=�^6�i͘w%F��N�G�,�#�fH�Fq�Ɨ�"�b3?�Bz/%�.�,��!nc`Eʃh�%Mx�'ƭthI�2R�JG�� �?�7��rJhɹl3f�8��~�8�>�o�o֥9۴��A+ܮ^�G�6x|�H�D�@K~.�M:%.���Ϡ�gŅX�i�$2�*,� ��E�~�7��

quartz kindle
#

nice

split hazel
#

nice

jaunty ore
#

Sorry, I'm still confused about what to do here

tulip ledge
#

That looks like a compressed file

stray seal
#

Did you not read the message?

#

I can give the file is you need

tulip ledge
#

like I said either it's a compressed file or your editor doesn't support that file extension

quartz kindle
#

or is a binary file

tulip ledge
#

true but I have no experience with that

wheat mesa
#

botum compressed help @ mods

static trench
rose warren
#

Read his gist

static trench
#

ok

#

that sucks

#

his gist is showing the unicorn of death error

static trench
#

thanks

#

its loading but not loading

#

it worked

#

thanks

quartz kindle
#

#toomanycomments

prime glacier
#

hosting my bot on aws but when i do node . the bot comes online but its status dosen't load and bot dosen't reply
also it stuck at ready.js

jovial nexus
#

How can i skip to a specific second of a video with the new @discordjs/voice

static trench
near stratus
pallid jungle
#
            data = await schema.findOne({
                   ^^^^^

SyntaxError: await is only valid in async functions and the top level bodies of modules
const schema = require('../schema/GuildSchema')

module.exports = {
    name: 'guildMemberAdd',
    execute(client, member) {

        let data;
        try{
            data = await schema.findOne({
                GuildID: member.guild.id
            })
            if(!data) return;
        } catch(err) {
            console.log(err)
        }
        let Channel = client.channels.cache.get(data.LogsChannel)
        if(!Channel) return;
        if(Channel.type !== 'GUILD_TEXT') return;
        
        const Add = new Discord.MessageEmbed()
        .setAuthor(member.user.username, member.user.displayAvatarURL({dynamic: true, size: 2048}))
        .setTitle('![Up](https://cdn.discordapp.com/emojis/853495519455215627.webp?size=128 "Up") Member Join!')
        .setDescription(`![iNFO](https://cdn.discordapp.com/emojis/853495450111967253.webp?size=128 "iNFO") MemberTag: ${member.user.tag}\n![pp198](https://cdn.discordapp.com/emojis/853494893439352842.webp?size=128 "pp198") MemberID: \`${member.user.id}\`\n![Right](https://cdn.discordapp.com/emojis/877975111846731847.webp?size=128 "Right") Created At: ${moment.utc(member.user.createdAt).format('LT')} ${moment.utc(member.user.createdAt).format('LL')} (\`${moment.utc(member.user.createdAt).fromNow()}\`)\n![Right](https://cdn.discordapp.com/emojis/877975111846731847.webp?size=128 "Right") Joined At: ${moment(member.joinedAt).format("LT")} ${moment(member.joinedAt).format('LL')} (\`${moment(member.joinedTimestamp).fromNow()}\`)`)
        .setColor('GREEN')
        .setFooter(member.guild.name, member.guild.iconURL({dynamic: true}))
        .setTimestamp() 
        const botname = client.user.username;
        Channel?.createWebhook(botname, {
            avatar: client.user.displayAvatarURL({ format: 'png', dynamic: true, size: 128 })
          })
          .then(webhook => Promise.all([webhook.send({ embeds: [Add] }), webhook]))
          .then(([_, webhook]) => webhook.delete())
          .catch(() => {});
        
          // add more functions on ready  event callback function...
        
          return;
    }
}

Line

data = await schema.findOne({
static trench
boreal iron
#

(as the error states)

solemn latch
gritty stag
#

Hi 🙂 I'm report bot @tall vessel bot using to scam

gritty stag
#

bot using on discord scam nitro

static trench
#

oh

#

i cant help

boreal iron
gritty stag
#

thx

earnest phoenix
#

code

guild.members.fetch().then m
let bots = m.filter(x => x.bot)
console.log(bots.size)

Result

0

Problem
There are 3 bots in server

lyric mountain
#

Do you have guild_members intent?

earnest phoenix
#

Yes

#

It cache all users

lyric mountain
#

And is enabled during client start?

earnest phoenix
#

I enabled it on dev portal

lyric mountain
#

Did you add the intent to the client?

earnest phoenix
#

And
Defined
Const client = Discord.Client intents = GUILD_MEMBERS

#

Yes

lyric mountain
earnest phoenix
#

No

lyric mountain
#

Idk if fetch allows no-param retrieval

#

Did you try using the cache?

#

Or fetchAllMembers (something like that)

earnest phoenix
#
message.guild.members.fetch().then(m => {   
        
        let b = m.filter(x => x.bot)
        
        message.channel.send(`
Total Users: ${m.size}
Bots: ${b.size}
`)
      });
earnest phoenix
lyric mountain
#

Still, I'm not sure you can fetch like that, without any param

#

Doesn't the docs talk about doing that?

earnest phoenix
#
ClientOptions#fetchAllMembers
The ClientOptions#fetchAllMembers option has been removed.
#

Docs only talking fetching members and filter them if they online

#

I need to fetch bots

#

Probably fetching thing fetch all bots and users as same thing

#

What if i use users instead members

#

fetch undefined...

quartz kindle
#

x is a member, not a user

azure lark
#

hello, i am trying to make a npm that has a cli and i am using a bin file and using package.json to exectue functions when messages are sent, but, when the user installs the package they can not use the commands, do i have to update their package.json to include the bin or do i have to do something els?e

quartz kindle
#

if you want to use cli commands without node/npm the user has to install it as global

#

with the -g switch

azure lark
#

so like npm i -g <package name>

quartz kindle
#

yes

azure lark
#

ok

coarse topaz
#

I just restarted my bot (after literally changing a string's content) and now I'm only getting this error. My bot doesn't go online.
Is this a problem from my vps or Discord?

#

I mean I don't think it's my fault, I just changed a string's content before and restarted it so that it would show the string's updated content

lyric mountain
#

Catch ur promises

#

Not only makes it a hell easier to debug but also allows error handling

proven lantern
#

Remember to throw early and catch late

coarse topaz
#

just tried to start the project again right now (without changing anything in the code) and it worked out of nowhere lmao - I guess the fault was on Discord's end?
anyway thanks for the heads up

pale vessel
#

Probably connectivity issue

lyric mountain
#

Still, put .catch() on ur stuff

#

Else you'll regret later

pallid jungle
#
module.exports = {
    name: 'channelDelete',
    async execute(client, GuildChannel) {
        if (!GuildChannel) {
            return;
          }
      
          const { type, id, name } = GuildChannel;

How to know the user who deleted the channel ?

sand shale
#

Can i know what is shard for and how to get it?

azure lark
# quartz kindle yes

can i still have other packages if the user installs it global, and if so do they also have to install the used packages global aswell?

quartz kindle
#

if the other packages have cli commands, yes

quartz kindle
#

discord only allows 2500 guilds on a single connection, so if you bot is in more than 2500 guilds, you have to use multiple bot connections, aka shards/sharding

sand shale
#

Ouh

tender terrace
#

how can i disble maintenece mode

cinder patio
#

ummmmmmmmmmmm

tender terrace
#

pls help me

earnest phoenix
#

not here

#

Main

const something = require(./something)

Something File

module.exports = client => {
 console.log("Something is Ready")
}

Problem

something is ready not writing in console(restarted bot)
misty sigil
#

quotes around the ./something

tender terrace
misty sigil
#

and you've gotta call it

#

e.g. something(client)

earnest phoenix
#

But console log is working when i type console.log on the first line

misty sigil
#

yea because it's not exported as a function

earnest phoenix
#

Hmm how do i it

misty sigil
#

wdym

earnest phoenix
misty sigil
#

its a function

#

something is a function

earnest phoenix
#

export as a funciton

misty sigil
#

it is

#

it already is

earnest phoenix
#

Then why itsnt working

pallid jungle
#
    async execute(client, channel) {
        if (!channel) {
            return;
          }
          const fetchedLogs = await channel.guild.fetchAuditLogs({
            limit: 1,
            type: 'CHANNEL_DELETE',
        });
        // Since there's only 1 audit log entry in this collection, grab the first one
        const channelLog = fetchedLogs.entries.first();
      
        const { executor, type, id, name } = channelLog;

 const ChannelDeleted = new Discord.MessageEmbed()
            .setDescription(` Channel Name: \`${name}\`\nChannel ID: \`${id}\``)
#

Channel Name: undefined

#

What is the problem ?

earnest phoenix
#

Hi! How can i fix this error pls ?
Source code : https://hastebin.com/ociwazinuk.coffeescript
Error : js DiscordAPIError[50035]: Invalid Form Body 10[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names are unique at SequentialHandler.runRequest (/moontest/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:198:23) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async SequentialHandler.queueRequest (/moontest/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:99:20) at async /moontest/deployCommand.js:80:3 { rawError: { code: 50035, errors: { '10': [Object] }, message: 'Invalid Form Body' }, code: 50035, status: 400, method: 'put', url: 'https://discord.com/api/v9/applications/883621594877009921/guilds/834472071559512104/commands' }

PS: He say me exist duplicates command but i don't see :/

boreal iron
#

Fetch your commands then and you will see it

misty sigil
#

you've got to run the function

quartz kindle
#

ah yes, switch to an abandoned lib because of an error in another lang

near stratus
wanton axle
#

any help ? i get this probleme only when i invite the bot to my own server but it works in other servers

fair axle
#

Which intent is required to emit guildMemberRemove on discord.js?

modest maple
#

you need the members intent

#

as the name suggests

earnest phoenix
quartz kindle
#

emit = receive

earnest phoenix
#

Hello.

Today I'm trying to send a attachment with interaction.reply function but he send me one error and i ask if someone can help me for fix this ?

Thanks you!

Error:

/moontest/node_modules/discord.js/src/util/DataResolver.js:125
    throw new TypeError('REQ_RESOURCE_TYPE');
          ^

TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.
    at Function.resolveFile (/moontest/node_modules/discord.js/src/util/DataResolver.js:125:11)
    at Function.resolveFile (/moontest/node_modules/discord.js/src/structures/MessagePayload.js:240:41)
    at /moontest/node_modules/discord.js/src/structures/MessagePayload.js:205:85
    at Array.map (<anonymous>)
    at MessagePayload.resolveFiles (/moontest/node_modules/discord.js/src/structures/MessagePayload.js:205:56)
    at CommandInteraction.reply (/moontest/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:97:64)
    at Object.exports.run (/moontest/commands/Images/avatar.js:24:22)
    at Query.onResult (/moontest/events/interactionCreate.js:28:41)
    at /node_modules/mysql2/lib/commands/query.js:72:16
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  [Symbol(code)]: 'REQ_RESOURCE_TYPE'```
pallid jungle
#
    data: new SlashCommandBuilder()
        .setName('filter')
        .setDescription('Adds filters to your avatar!')
        .addBooleanOption(option => option.setName('blurpify').setDescription('Select the blurpify filter option'))
        .addBooleanOption(option => option.setName('magik').setDescription('Select the magik filter option'))
        .addBooleanOption(option => option.setName('deepfry').setDescription('Select the deepfry filter option')),

How to make that the required option is 1 option

#

If i set .setRequired(true) for all it will require all in same message

lyric mountain
azure lark
#

how do i make a line of code run terminal commands for me with node?

lyric mountain
#

exec

wanton axle
lyric mountain
#

the returned object is undefined

#

prob not cached

wanton axle
#

so how i can fix it

#

btw

#

its just happened when i invite the bot to my own server

#

but it works when i kick em

lyric mountain
#

is the code yours?

wanton axle
#

yes but i use some other codes

quartz kindle
modest maple
#

so no

quartz kindle
#

yes

boreal iron
#

You got'em

wanton axle
quartz kindle
#

be aware that updating discord.js requires updating a lot of your bot's code, because new versions are not compatible with code for old versions

#

you are using discord.js v11 from what i can guess, the latest version is v13

lyric mountain
#

v11? that's beyond outdated

#

if it was a cheese it'd cost around $1m

quartz kindle
#

Lol

wanton axle
#

lmao

#

let me see

boreal iron
#

Never change a running system u know

azure lark
#

how would i make a command that would run:

git commit -m "commit"
git push```