#development

1 messages · Page 1394 of 1

balmy knoll
#

I really think this is an API problem, how can I solve the problem that the bot status reset sometimes?

restive furnace
#

by setting a interval that resets it in every X seconds

balmy knoll
#

So it is normal to reset? It's not a code problem, right?

restive furnace
#

like in js you could do setInterval(() => ClientUser#setPresence(...), 6000 * 30);

#

yeah

#

like in js you could do setInterval(() => ClientUser#setPresence(...), 6000 * 30);
this is every 30 mins

balmy knoll
#

Ok, I had thought, instead of creating an interval, to set the status of the bot every time the presenceUpdate event is triggered (by entering a check on the user ID)? Can this be done?

hollow sedge
#

I don't think it's supposed to reset, but then again I'm using discord py

restive furnace
#

it does

#

but its way easier with setInterval

hollow sedge
#

LOL i was just looking around on the website in your status, this is hilarious

earnest phoenix
#

capitalism ™️

ancient nova
#

channel.send(shardReconnectings).catch((err) => {
^

TypeError: Cannot read property 'send' of undefined

#

guys I've done catch just becausse it kept giving me that error

#

and it still does give me the same error

balmy knoll
#

LOL i was just looking around on the website in your status, this is hilarious
@hollow sedge This was for a friend of mine who wanted at all costs to use my bot to make fun of me and I decided so 😄

earnest phoenix
#

@ancient nova because the error isn't coming from the promise lol

#

the promise isn't even getting executed

#

channel is undefined

hollow sedge
#

extort your friends for money using this one simple method

balmy knoll
#

Exactly, but this was mainly for him cz_smile

ancient nova
#

@earnest phoenix well let me send you the entire command, I'm pretty sure it's because I'm trying to use discord.js before it even starts

hollow sedge
#

i get it, im just making a joke

ancient nova
#

but see for yourself

earnest phoenix
#

it probably is

#

like i said, channel is undefined

#

interact with discord in/after the ready event

ancient nova
#
<client>.on("shardReady", id => {
console.log(`[SHARD] Shard ${id} booted up...`);
  const shardReadys = new MessageEmbed()
  .setTitle(`Shards`)
  .setColor(COMMANDCOLOR)
  .setDescription(`Shard **${id}** booted up...`)
  .setTimestamp();
   const channel = bot.channels.cache.get('770505348339466250');
   channel.send(shardReadys);
});
#

the thing is

#

it sometimes works

#

sometimes doesn't

#

that what makes me mad about it

sudden geyser
#

is the channel always in the cache

earnest phoenix
#

the guild that the channel is in probably isn't in that shard

ancient nova
#

oh I see

earnest phoenix
#

give me a sec

ancient nova
#

alright

drifting wedge
#

I have ertor

#

Help

#

Js

earnest phoenix
#
shard_id = (guild_id >> 22) % num_shards

use this formula to get the id of the shard the channel is accessible in

#

oh i see you want to send a message for every shard that is ready

ancient nova
#

yeah

earnest phoenix
#

you can use fetch instead of get

#

that'll return it directly from discord if not in cache

#

it's a promise though, don't forget to await it

dense drift
#

I'm so confused, so I'm uploading an attachment with my bot, and every time it goes to upload, it's a totally different size. I can't figure out why, but I would assume that the bot is just sending it before it's even finished the upload....

earnest phoenix
#

impossible

#

when you attach files you send a multipart request

#

it won't finish until the multipart is done

dense drift
#

Take a look

#

Same file, it goes to reupload it to a different channel, and it's different every time

fleet dove
#

wow

earnest phoenix
#

what's your code

dense drift
#

All it does it grab the file, save it, create a new channel, upload it, delete it

#
await ticketchannel.send({
                    embed: embed,
                    files: [{
                        attachment: `${process.cwd()}/downloadedzips/${name}`,
                        name: `${name}`
                    }]
                });```
earnest phoenix
#

also have you tried downloading the file, unzipping it, seeing the contents are intact?

dense drift
#

Yeah, it's a broken zip

#

Won't uncompress

earnest phoenix
#

can you provide the code for downloading

dense drift
#

Sure, I know it downloads right because I can check my file server, and it's there in tack

#
request.get(url)
        .on('error', console.error)
        .pipe(fs.createWriteStream(`downloadedzips/${name}`));```
#

url is the attachment url

agile lance
#

How can I fetch a different guild then the one i’m talking in?

dense drift
#
client.guilds.cache.get('ID')```
agile lance
#

Ty

earnest phoenix
#

i have no clue if request's pipe is blocking

#

try using node-fetch

dense drift
#

I can confirm the download is working, it's on the upload side, as I can just go to my server and manually download it

earnest phoenix
#

if you go to your server and manually download it and it's working fine

#

then it's the downloading code

dense drift
#

..? I guess I'm confused

ancient nova
#

@earnest phoenix hey but what about if it boots up before discord .js and I get that unknown message error

earnest phoenix
#

@ancient nova ...unknown message, what?

#

@dense drift what are you confused about

#

if you download it manually and it works

#

it means that your code to download the file is incorrect because when you try to download it, it doesn't download properly

#

try using node-fetch and the sample they have

dense drift
#

What I mean is, when I run the

fs.createWriteStream(`downloadedzips/${name}`)```` 
line of code, and navigate to my server with visual studio to manually download it, it's the correct file on the server

Only the file that is attached by the bot on Discord is incorrect
rustic nova
#

Same file, it goes to reupload it to a different channel, and it's different every time
@dense drift not development related, but that's a smart idea ngl

earnest phoenix
#

is there any reason for you to keep the zip files on the server?

dense drift
#

I dump it after

#

But as a test, I didn't dump it to check

earnest phoenix
#

then you don't need to download it to your drive in the first place

dense drift
#

oh

#

well

earnest phoenix
#

djs allows buffers to be passed

dense drift
#

That would make it easier hahaha

#

I was just saving > uploading > deleting

#
                await ticketchannel.send({
                    embed: embed,
                    files: [{
                        attachment: `${process.cwd()}/downloadedzips/${name}`,
                        name: `${name}`
                    }]
                });```
#

So with this code, I can just change what attachment has?

agile lance
#

How can I make a role with the manage messages permission and create it using js?

dense drift
#

Instead of pulling locally?

#
guild.createRole({ name: 'ROLENAME', permissions: ['MANAGE_MESSAGES'] });```
ancient nova
#

so if I have this , and while playing it randomly edits the embed

        this.gameEmbed.edit(editEmbed).catch((err, msg) => { 
            //console.log(err)
        });

but someone deletes the embed before it could edit it, it gives me unknown message error, I used catch on it, but it still sends me the damn error

dense drift
#

One google search, and it was the first answer

ancient nova
#

it's basically flooding my entire console with these errors

earnest phoenix
#

you can directly just pass the url of the file and djs will take care of it

#
files: ["url"]

should work just fine

#

if you want to rename the file on upload

#
files: [{
  attachment: "url",
  name: "whatever.zip"
}]
dense drift
#

Well.. that worked, thanks man

#

I should've just uploaded straight from discord to discord

#

I made more work for myself hahaha

royal crescent
#

So yesterday someone told me to use node-fetch to fetch a webpage and pass that to cheerio
i am not well-versed in node-fetch or js so this is what is looks like rn
``` fetch(https://brawldb.com/player/stats/${args});

        const $ = cheerio.load(fetch.text());```

this is obviously very wrong lol, anyone know how to fix?

earnest phoenix
#

pretty much almost any method in node-fetch is a promise

#

first await the fetch method and store the result of it in a variable

safe creek
#

i need to set this straight

earnest phoenix
#

then await the text() method on the said variable

safe creek
#

is print() what makes the bot speak or no?

earnest phoenix
#

no

safe creek
#

ok

#

ty

royal crescent
#

@earnest phoenix github has a ton of different uses of node-fetch so i just dk which to use lol
are you talking about this one?

params.append('a', 1);

(async () => {
    const response = await fetch('https://httpbin.org/post', {method: 'POST', body: params});
    const json = await response.json();

    console.log(json);
})();```
earnest phoenix
#

the pattern there is the correct one

#

but don't just copypaste it

royal crescent
#

yeah ofc lol

earnest phoenix
#

so basically, await the fetch, store in a variable

#

in that snippet the variable is response

#

in your case, instead of using json() you'd use text()

#

and that's it

royal crescent
#

shit man thanks a ton

agile lance
#

I tried creating a role using a command.

guild.createRole is not a function

Anyone help?

earnest phoenix
#

because it isn't

#

don't make up your own methods and consult with the docs

agile lance
#

I was told to do that by somebody.

young elk
#

@royal crescent👀

tired panther
#

How to get shard count?

earnest phoenix
#

in which library?

#

#

congrats you know how to use unicode chars

#

ancient nova
#

guys how to see how many voice channels my bot is in?

earnest phoenix
#

keep track of it yourself

#

​​

tired panther
#

in which library?
@earnest phoenix discord.js ^12

agile lance
#

How do I assign a role to user? Keeps saying “Cannot read property of ‘roles’ of undefined.

Code:
message.guild.members.cache.find(‘737918277866487928’).roles.add(‘778101197009190933’)

earnest phoenix
#

the user isn't defined

#

!us how to fly

#

@split hazel annoying spammer

tired panther
#

How do I assign a role to user? Keeps saying “Cannot read property of ‘roles’ of undefined.

Code:
message.guild.members.cache.find(‘737918277866487928’).roles.add(‘778101197009190933’)
@agile lance first fetch , then assain

earnest phoenix
#

Result for how fly:

When a person knows how to control their vehicle well in the air in the video game Rocket League. Especially when you personally can’t do the same.

tired panther
#

and idea @earnest phoenix about shard count?

agile lance
#

@agile lance first fetch , then assain
@tired panther Do I replace find with fetch?

earnest phoenix
#

sec

pale vessel
#

You can't assign a role to a user we_smart

split hazel
#

is there even a point giving them warnings

ancient nova
#

guys how to see how many voice channels my bot is in?

earnest phoenix
#

@tired panther do you use the sharding manager?

tired panther
#

yap , the auto

pale vessel
#

I'd use guilds.reduce()

quartz kindle
#

@ancient nova client.voice.connections

ancient nova
#

I did but it always returns 0

#

<client>.voice.connections.size

#

also tried to do .map

#

with it

#

it doesn't return anything

quartz kindle
#

and you're sure your bot is connected to a at least one voice channel?

ancient nova
#

yup I'm listening to music right now

#

with it

#

it will still return 0

quartz kindle
#

are you using intents?

ancient nova
#

yeah

#

I have both of them whilelisted

quartz kindle
#

do you have the GUILD_VOICE_STATES intent?

ancient nova
#

I'm.. not sure

#

how do I check if I have it?

quartz kindle
#

do you pass a list of intents to your client?

#

when you create the client

ancient nova
#

I don't think so

agile lance
#

let ro = guild.roles.cache.find(h => h.name == “TEST”)

let me = message.guild.members.cache.get(‘737918277866487928’)

me.member.roles.add(ro.id)

This code doesnt work. Error: Cannot read property ‘member’ of undefined

ancient nova
#

I have two clients running at the same time always, one for music streaming and one for the rest of the commands

quartz kindle
#

@ancient nova what if you check message.guild.voiceStates.cache

ancient nova
#

let me see

tired panther
#

%eval message.channel.send(client.shard.totalShards); does not work

ancient nova
#

it returns the guilds normally

quartz kindle
#

@tired panther where did you get totalShards from?

#

@ancient nova so voice states are working, but client.voice.connections.size is still 0?

ancient nova
#

yeah

earnest phoenix
#

it's a map

#

isn't size always supposed to return 0

ancient nova
#

let me send you

earnest phoenix
#

or is it for length

#

jesus christ my internet is so slow

quartz kindle
#

length is for arrays, size is for maps

ancient nova
#

even if I map it

#

nothing is in it

quartz kindle
#

@ancient nova try message.guild.voiceStates.cache.map(x => x.member.user)

ancient nova
#

alright

quartz kindle
#

dafuq

ancient nova
#

I dunno

#

lol it's broken

quartz kindle
#

ah i know why

#

you're accessing your bot from another client right?

ancient nova
#

nope

#

this one is the main one

blissful coral
#

Huhhh

ancient nova
#

bot

blissful coral
#

Weird

quartz kindle
#

the same where the music is being run from?

ancient nova
#

yeah

quartz kindle
#

ok then idk

blissful coral
#

Is it sharers

#

Sharded*

ancient nova
#

well for now I have every server on the same shard due to a memory leak

quartz kindle
#

but using the sharding manager?

blissful coral
#

^?

ancient nova
#

for now I don't use it

quartz kindle
#

but you have 2 clients running right?

#

do they have 2 different prefixes?

ancient nova
#

nope

quartz kindle
#

so how do you know which is which? only one of them has an eval command?

ancient nova
#

nope only the main one has an eval

#

it has connection to the both clients though

tardy hornet
#
ot.on('ready', () =>{
    console.log("this bot is online!");
    setInterval(() => {
      bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"});
  }, 60000);
  setInterval(() => {
    dbl.postStats(bot.guilds.size);
}, 1800000);  
  })

its not refreshing it in the page

quartz kindle
#

and u sure the main one is the one thats playing the music?

#

@tardy hornet bot.guilds.size is not a thing anymore

tardy hornet
#

then what is it?

quartz kindle
#

also you dont need to use postStats

river wing
#

i want to ask if i want to make a incremental function to update everyone's money in the database every second whats the most efficient way? the way im planning to do it is every second pull out all the players data from the database and increment it and save it to the database before repeating it within a second and my bot will start to lag when theres multiple players

tardy hornet
#

@tardy hornet bot.guilds.size is not a thing anymore
@quartz kindle then what is it?

solemn latch
#

look in your setActivity to see it

quartz kindle
#

@tardy hornet you already have the answer in your setActivity

tardy hornet
#

O lol

#

didnt see ty

quartz kindle
#

@river wing updating the entire db every second is indeed a bad idea

river wing
#

but is there other ways to workaround that

quartz kindle
#

caching and eventual consistency

#

keep a copy of all user's money in memory, update that every second

#

only push it to the database once every 10 seconds or so

#

if your bot crashes, all users will be roled back about 10 seconds, but that shouldnt be much of an issue

sudden geyser
#

or just calculate how much money based on the time

quartz kindle
#

other than that ^

solemn latch
#

what i was typing

#

makes the most sense to me

sudden geyser
#

basically subtraction with no cost to it

river wing
#

hmm okay

ancient nova
#

so um

#

I guess it's brokken

#

somehow

quartz kindle
#

it definitely doesnt make sense

ancient nova
#

I know I'm as confused as you

river wing
#

is there any tutorials for that like keeping the users money and updating it every second

quartz kindle
#

is the updating a constant thing?

#

like add +1 per second

#

the same to everyone?

river wing
#

as in the people have different increment values

quartz kindle
#

ok, you can still do what lite said

#

when a user is created, give it a creation timestamp, a base money and an increment value

#

when you pull the user to check its money, compare its timestamp to the current time, and calculate how much money they have

#

if the incremented value changes, save a new timestamp and a new base money

river wing
#

hmm ok i can try doing that

#

but is it possible to always update it into the database

fervent goblet
#

does the ms npm module not support months?

solemn latch
#

from a functionality standpoint you are updating it into the database

quartz kindle
#

^

#

just not directly

ancient nova
#

@quartz kindle I wrote a code to directly access the client directly and it still says 0

quartz kindle
#

which is a billion times better for performance

river wing
#

ok ill try that

fervent goblet
#

is there a better module that converts args to ms?

ancient nova
#

I am really confused

quartz kindle
#

@ancient nova wait... you're using a third party library to play music?

ancient nova
#

yeah but it all saves

quartz kindle
#

then thats probably why

#

they are not doing it through discord.js

ancient nova
#

so how else can I get it?

quartz kindle
#

the library you're using should have a list of channels its connected to

ancient nova
#

let me see

#

it gives me a random error

#

I don't even know where it comes from

#

@quartz kindle

#

btw the manager there is the library

#

I'm just accessing cuz it's in another file in my bot

quartz kindle
#

what library are you using

ancient nova
#

lavalink

quartz kindle
#

which one

peak venture
#

Does anyone know about these intents?

#

My bot is verified, but the guildMemberAdd seems to not work?

solemn latch
#

Its the GUILD_MEMBERS intent right? for guildMemberAdd

peak venture
#

It's kind of interesting to me though

#

cause my bot is over 100 servers, and verified

#

That would mean my bot has these things enabled by default isnt it?

solemn latch
#

no

#

you have to enable them in your code intents, and on the dev portal

peak venture
solemn latch
#

you must request those intents in order to use them

peak venture
#

as for my code; i'll have to look on the web on how to do that (javascript)

#

request them by the scopes?

sand condor
#

contact discord support

oak timber
#

oh

safe creek
#

so i was doing py -3 -m pip install -U discord.py everything was going well untill i got a shit ton of errors...

earnest phoenix
#

|Hello|

#

<hi>

safe creek
#

...

earnest phoenix
#

XD

safe creek
#

What are you trying to do?

earnest phoenix
#

Idk

#

Nothing

safe creek
earnest phoenix
#

Xd

thin cedar
#

Good evening I have a problem for 1 hour the photos are no longer displayed in the embed.

tardy hornet
#
case 'kill':
  const array5 = [
    'https://media1.tenor.com/images/a0d13ec25f9774f155b6cd5ebf12a6c8/tenor.gif?itemid=18258403',
    'https://media1.tenor.com/images/361a7354f193af1b1ace5843dcaeeb02/tenor.gif?itemid=18599860',
    'https://media1.tenor.com/images/3cedee4f8118855c83ea05463498f326/tenor.gif?itemid=16400090',

]
const Random = Math.floor(Math.random() * array5.length)
  if(!args[1]) return message.channel.send('who do you want to kill?')
  const opponent2 = message.mentions.users.first();
  if ( !opponent2 ) {
    return message.reply( 'who do you want to kill?' );
  }

  if(message.author.id === opponent2.id) return message.channel.send("please mention a user that is isnt you.")
  const killf = new Discord.MessageEmbed()
  .setDescription(`${message.author} killed ${opponent2}:dorange:`, '\u200b')
  .setImage(array5[Random])
  .setColor("RED")
  message.channel.send(killf)

  break;

its just sending the embed with out the gif

thin cedar
#

I do not understand why

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sudden geyser
#

did an error occur sending the message

opaque seal
#

Is Discord having issues deleting Voice Channles?

obtuse jolt
#

no i just randomly keep getting it in console

sudden geyser
#

It's having some issues doing stuff.

obtuse jolt
#

and i cant find the issue

sudden geyser
#

Like timing out bulk deleting messages I just got

#

Well, it comes from line 44 in commands/config.js, so I think it's safe to assume it has something to do with sending the message, because if an error occurs, you're ignoring it and setting the value equal to undefined instead (.catch(() => {return;}) => () => undefined).

thin cedar
#

Would someone be how to use the randomcolor package?

pure lion
#

so how would i write an event handler where i set the events to a collection and then when an event occurs it triggers said event?

obtuse jolt
#

the message sending has a catch

safe creek
sudden geyser
safe creek
#

Oh

lethal grail
#

how do you get a database in discord.js lmao

safe creek
#

Node.js I think

pure lion
#

no

sudden geyser
#

Working with databases is not really limited to Discord.js. You set up the database like you're supposed to.

pure lion
#

^

#

you can use sql or nosql

tardy hornet
#
case 'kill':
  const array5 = [
    'https://media.giphy.com/media/OHbDlU9nH13cbJPCWq/giphy.gif',
    'https://media.giphy.com/media/Diy0XGkNkA14nPGfBE/giphy.gif',
    'https://media.giphy.com/media/3bUxL3UQGTnbyF1tVe/giphy.gif',

]
const Random = Math.floor(Math.random() * array5.length)
  if(!args[1]) return message.channel.send('who do you want to kill?')
  const opponent2 = message.mentions.users.first();
  if ( !opponent2 ) {
    return message.reply( 'who do you want to kill?' );
  }

  if(message.author.id === opponent2.id) return message.channel.send("please mention a user that is isnt you.")
  const killf = new Discord.MessageEmbed()
  .setDescription(`${message.author} killed ${opponent2}:dorange:`, '\u200b')
  .setImage((array5[Random]))
  .setColor("RED")
  message.channel.send(killf)

  break;

its not sending the gif in there!

pure lion
#

i personally use nosql but its up to you

lethal grail
#

yeah, how do i set it up

sudden geyser
#

What database would you like to use?

solemn latch
#

depends on the database

lethal grail
#

sql

sudden geyser
#

That's a language. A database using SQL would be SQLite, Postgres, etc.

pure lion
#
case 'kill':
  const array5 = [
    'https://media.giphy.com/media/OHbDlU9nH13cbJPCWq/giphy.gif',
    'https://media.giphy.com/media/Diy0XGkNkA14nPGfBE/giphy.gif',
    'https://media.giphy.com/media/3bUxL3UQGTnbyF1tVe/giphy.gif',

]
const Random = Math.floor(Math.random() * array5.length)
  if(!args[1]) return message.channel.send('who do you want to kill?')
  const opponent2 = message.mentions.users.first();
  if ( !opponent2 ) {
    return message.reply( 'who do you want to kill?' );
  }

  if(message.author.id === opponent2.id) return message.channel.send("please mention a user that is isnt you.")
  const killf = new Discord.MessageEmbed()
  .setDescription(`${message.author} killed ${opponent2}:dorange:`, '\u200b')
  .setImage((array5[Random]))
  .setColor("RED")
  message.channel.send(killf)

  break;

its not sending the gif in there!
@tardy hornet doesnt look like you ever call the array

sudden geyser
#

If you're new I'd recommend SQLite. It's very common/easy to setup.

lethal grail
#

sure

tardy hornet
#

@tardy hornet doesnt look like you ever call the array
@pure lion .setImage((array5[Random]))

pure lion
#

ah nvm

#

remove one set of ()s

#

from that

sudden geyser
pure lion
#

also are there any errors

sudden geyser
#

The database is essentially a local file.

tardy hornet
#

remove one set of ()s
@pure lion i did

#

didnt work

waxen rapids
#

How I Get The Top.gg Vote Counter Code

sudden geyser
#

the message sending has a catch
@obtuse jolt which, if called, evaluates to undefined, which is why it may throw the TypeError? Am I missing something?

lethal grail
#

hmm is mongodb easier?

sudden geyser
#

What do you mean the counter code.

#

MongoDB is a NoSQL database.

#

You should search it's setup guide on the website if you want to use it.

waxen rapids
#

There Is A code That Count The Votes

sudden geyser
#

Do you want to use Top.gg's API to get the number of votes your bot has, or to know when a user has voted?

tardy hornet
#

so? what should i do?

waxen rapids
#

To get the number of votes

gentle lynx
#

(node:4568) UnhandledPromiseRejectionWarning: FetchError: request to https://discord.com/api/v7/gateway/bot failed, reason: unable to verify the first certificate

#

what's this error

safe creek
#

@sudden geyser after install the visual build tools from that link inside tbe error it should work when i input the command again right?

sudden geyser
#

glassy I think Discord is having issues right now

gentle lynx
#

thought so

lethal grail
#

holy cow, setting up a database looks hard as hell

sudden geyser
#

@safe creek it should, just try it out and see.

#

It may seem hard at first, but it gets easier as you learn more.

#

Practice makes perfection.

safe creek
#

Haha yeah my head really hurts

tardy hornet
#

am guys, i found the problem

#

.setImage dose not work

#

anyone else got it?

#

i saw 5 people that dose

pure lion
#

how old are you?

#

also

safe creek
#

^^

pure lion
#

can anyone help me with a discord.js event handler?

safe creek
#

Lmao

pure lion
#

ive set event files to a discord collection

tardy hornet
#

how old are you?
@pure lion me?

pure lion
#

you

#

ive set event files to a discord collection
And im not sure how to access the files when an event happens

lethal grail
#

im dead confused where i should put the database code

#

and what should be the file extension?

tardy hornet
#

you
@pure lion why are you asking?

pure lion
#

why are you defensiveing

thin cedar
#

Could someone help me use the "RandomColor" package

pure lion
#

just pass in RANDOM

#

if you're doing an embed

sudden geyser
#

so how would i write an event handler where i set the events to a collection and then when an event occurs it triggers said event?
@pure lion similar to how you set up command handlers, but I think it's easier to just store the functions to call when the event has been emitted in the files, then, in the loader, do <EventEmitter>.on(theEventNameFromTheFile, theFunctionToCall).

Do you really need to store the commands in a collection? That would be like having a key of file names and the value being the function call (hence your map).

river thistle
#

anyone got a good "whats the sauce of this image"-like api ?

sudden geyser
#

when you say sauce, is your interest in finding anime by a scene

river thistle
#

yup

pure lion
#

@pure lion similar to how you set up command handlers, but I think it's easier to just store the functions to call when the event has been emitted in the files, then, in the loader, do <EventEmitter>.on(theEventNameFromTheFile, theFunctionToCall).

Do you really need to store the commands in a collection? That would be like having a key of file names and the value being the function call (hence your map).
@sudden geyser so then how would i d o

sudden geyser
pure lion
#

is there a way to listen for everything?

river thistle
#

ok thanks Ill look into it ^^

pure lion
#

same

#

whats your story

sudden geyser
#

I don't know about one event on the EventEmitter that gets triggered for all listeners.

#

There are certain ways to get that behavior.

pure lion
#

ah?

heavy marsh
#

Small question ...
How to create embed using eris
as in discord.js v12 its ```js
const Discord = require('discord.js');

const exampleEmbed = new Discord.MessageEmbed()

sudden geyser
#

Well, take for example.

Let's say I have two events: guildMemberAdd and guildMemberRemove in two separate files (./events/*.js). I'd like to go the extra mile by using a switch for control.

If I were to put that into code, I could write: ```js

function loader() {
let files = readdir("./events/");

for (const file in files) {
let eventName = file.replace(".js", "");
let eventFunc = require(./events/${file});

bot.on(eventName, (...args) => whichListener(eventName, eventFunc, ...args))

}
}

function whichListener(name, func, ...args) {
switch (name) {
case "guildMemberAdd": ...
case "guildMemberRemove": ...
}
}```
Unless I'm misunderstanding something. I still don't understand why you'd want to store all the functions for later because I don't see much use out of it. The message from the loader function should make enough sense though. @pure lion

#

@heavy marsh you need to send it as an object.

#
message.channel.createMessage({
  embed: {
    // ...
  }
});```
eternal osprey
#

https://hatebin.com/nceboezkay TypeError: Cannot read property 'toLowerCase' of undefined. It is coming from line 52. I have logged it and it displays raid is undefined

sudden geyser
eternal osprey
#

please could anybody help me?

heavy marsh
#

@sudden geyser so it is the same tags like creating a title , desc and etc

sudden geyser
#

not exactly

#

It should be structured like Discord expects the library to send it as (JSON).

#

For example, title: "this is the title"

heavy marsh
#

ooh I see

sudden geyser
#

For a color, Discord wants an integer. Maybe 0xABCDEF

heavy marsh
#

I will give it a go

#

thankyou

eternal osprey
#

hey guys could anybody look at my question above? Thanks already 🙂

pure lion
#

@sudden geyser ah

#

a;kghadogih]

lethal grail
olive roost
#

so i have the following code:

if message.content == 'c!meme':
   memes = ('https://cdn.discordapp.com/attachments/753695631167586499/778709549397442600/unknown.png', 'https://cdn.discordapp.com/attachments/735991790284439563/778317227144904755/animal-memes-9-11.png', 'https://cdn.discordapp.com/attachments/735991790284439563/774738067629146163/ecd39aa9ea89c2884de38a822f8480aa--so-funny-funny-stuff.png')
   choice = random.choice(memes)
   await message.channel.send('{}'.format(choice))

i would like it to convert the link directly into an image like normal, but for some reason it only shows the random link. can someone help?

crystal yew
#

Is this a good chat/channel to ask about markdown on the bots log desc?

solemn latch
#

sure

iron tinsel
#

So basically rn, I’m trying to setup my bot using Slappey and after I install nodemon I attempt npm run dev but I get a whole bunch of errors

sudden geyser
#

You're missing your package.json file for some reason.

olive roost
#

so i have the following code:

if message.content == 'c!meme':
   memes = ('https://cdn.discordapp.com/attachments/753695631167586499/778709549397442600/unknown.png', 'https://cdn.discordapp.com/attachments/735991790284439563/778317227144904755/animal-memes-9-11.png', 'https://cdn.discordapp.com/attachments/735991790284439563/774738067629146163/ecd39aa9ea89c2884de38a822f8480aa--so-funny-funny-stuff.png%27)
   choice = random.choice(memes)
   await message.channel.send('{}'.format(choice))

i would like it to convert the link directly into an image like normal, but for some reason it only shows the random link. can someone help?

sudden geyser
#

Could try npm init

#

Christmas try sending it as an attachment rather than a link

olive roost
#

hmm

#

@sudden geyser so do i download the image

ancient nova
#

@olive roost message.channel.send({embed:{image:{url: ${choice}}} })

olive roost
#

k i'll try that

sudden geyser
#

Not Discord.js

olive roost
#

k thx

ancient nova
#

oh I see, sorry about that

olive roost
#

@sudden geyser so its class discord.File(fp, filename=None, *, spoiler=False)
?

ancient nova
#

I'd help you but I'm not good with py

eternal osprey
#

could somebody help me please?

#

https://hatebin.com/nceboezkay TypeError: Cannot read property 'toLowerCase' of undefined. It is coming from line 52. I have logged it and it displays raid is undefined
@eternal osprey

hollow sedge
sudden geyser
#

What you showed me is the signature of the function. Not what you're supposed to pass. Each parameter is a positional argument.

So, discord.File(fp, filename, spoiler) where fp, filename and spoiler are their expected types. If the file is a spoiler I'll replace spoiler for true.

It's hard to explain, but it's a matter of reading documentation and understanding the signature of something.

olive roost
#

ok thx

#

im bad at coding sorry

hollow sedge
#

@eternal osprey

console.log(raid.pokemon_id + options.name)
      let raid = raids.shift();
      let raids = data.raids.filter(raid => getName(raid.pokemon_id).toLowerCase() === options.name.toLowerCase() && raid.level >= (options.level ? options.level : 5))

Do you still need help

eternal osprey
#

oowh it is defined outsside

hollow sedge
#

well not outside but after

young flame
#

what errors

eternal osprey
#

i still need help tho:

hollow sedge
#

you mean it still doesnt work?

eternal osprey
#

TypeError: Cannot read property 'toLowerCase' of undefined line 52

molten yarrow
#

@earnest phoenix make ur function async

young flame
#

why do you have the error message before you get the member

#

?

#

args[0] would be an id

hollow sedge
#

@eternal osprey because you didnt define raid before calling toLowerCase on it

young flame
#

you just type async

eternal osprey
#

okay look

#
let res = await afetch("https://nycpokemap.com/raids.php?time=" + new Date().valueOf())
      let data = await res.json();
      const getName = id => nameList.filter(el => el.i === id)[0].n;
      let raid = raids.shift();
      let raids = data.raids.filter(raid => getName(raid.pokemon_id).toLowerCase() === options.name.toLowerCase() && raid.level >= (options.level ? options.level : 5))
      console.log(raid.pokemon_id + options.name)```
#

Cannot access 'raids' before initialization

young flame
#
const Discord = require('discord.js')

module.exports ={
    name: 'kick',
    description: 'kick a user',
    execute(client, message, args){
        if (!message.member.hasPermission('KICK_MEMBERS')) {
            return message.channel.send(`You are unable to kick members`)
        }

        const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if(!member) return message.reply('you didnt mention anyone');

        try {
            await member.kick();
            await message.channel.send(`${member} has been kicked!`)
        } catch (e) {
            return message.channel.send(`User isn't in this server!`)
        }

    }
}
#

hH

#

why is everything greeN

#

very poggers

heavy marsh
#

@sudden geyser another help how to do some thing like
Hello
and an embed below in eris

young flame
#

execute async ect

hollow sedge
#

Yes, you are calling raids.shift before even defining raids@eternal osprey

eternal osprey
#

yeah but how would i do it otherwise?

young flame
#

i'm not doing eeverything for you G)

sudden geyser
#

wdym

eternal osprey
#

i cannot first define the raids

hollow sedge
#

You have to define raids before defining raid

eternal osprey
#

and then the raid

hollow sedge
#

Yes you can?

eternal osprey
#

as i am getting the raid.pokemon_id

hollow sedge
#

Oh

eternal osprey
#

(raid.pokemon_id) then this would be undefined

sudden geyser
#

@heavy marsh are you referring to the footer?

heavy marsh
#

nope

hollow sedge
#

You are going about it the wrong way then

sudden geyser
#

async before execute

hollow sedge
#

I'm not sure how the pokemon API works so I can't help you

heavy marsh
#
const exampleEmbed = new Discord.MessageEmbed()
    .setTitle('Some title')
    .attachFiles(['../assets/discordjs.png'])
    .setImage('attachment://discordjs.png');

channel.send(`Hello`, exampleEmbed);
``` - but in eris
eternal osprey
#

@hollow sedge i am not using any form of api's

#

i am grabbing the info from a webite

sudden geyser
#

The first argument should be the content. The second argument will be what the first argument is right now.

eternal osprey
#

@earnest phoenix fucking put async execute

hollow sedge
#

Yes you are?

sudden geyser
#

Aka js createMessage("Hello", { embed: { // ... } })

hollow sedge
#

what do you think nycpokemap is

heavy marsh
#

hmm it told be wrong format

eternal osprey
#

yeah but i am not using their api

#

but their website format

heavy marsh
#

let me try it again

sudden geyser
#

oh wait I'm stupid

heavy marsh
#

👀

hollow sedge
#

Oj

#

Oh*

sudden geyser
#

It should look like this: js createMessage({ content: "Hello", embed: { // ... } })

hollow sedge
#

Same idea though @eternal osprey

#

Still don't know what it's doing

heavy marsh
#

ahh I see

#

Thanky ou

earnest phoenix
#

hi, recently (like less then a hour) i had an issue with my clear command. When i use the clear command i receive the mesage that the bot clear messages but the messages don't been deleted

eternal osprey
#

anyone knows how i can define this shit i wrote

#
let res = await afetch("https://nycpokemap.com/raids.php?time=" + new Date().valueOf())
      let data = await res.json();
      const getName = id => nameList.filter(el => el.i === id)[0].n;
      let raid = raids.shift();
      let raids = data.raids.filter(raid => getName(raid.pokemon_id).toLowerCase() === options.name.toLowerCase() && raid.level >= (options.level ? options.level : 5))
      console.log(raid.pokemon_id + options.name)```
molten yarrow
#

why are u using new Date().valueOf()

young flame
#

what is undefined?

molten yarrow
#

its the same as Date.now()

eternal osprey
#

@young flame the raids

young flame
#

hmmm

molten yarrow
#

and should it not be await fetch and not await afetch?

eternal osprey
#

as i am defining raid = raids.shift before the raids defining

#

but i canot define raids before the raid as i am calling the raid variable in it.

young flame
#

yes

eternal osprey
#

look at the lil snippet. Appreciate it!

young flame
#

because the raids need raid

#

so just put raids under raid?

eternal osprey
#

yeah i know

#

but i cannot

#

look at raid

young flame
#

why can't you

eternal osprey
#

raid = raids.shift

young flame
#

why would you

eternal osprey
#

the raids.shift will be undefined as i clearly have not named the raids yet

young flame
#

it wont work at all

eternal osprey
#

yeah i see

molten yarrow
#

can u console.log(data)

young flame
#

if raids is undefined nothing will happpen if raids is defined before raid nothing will happen

eternal osprey
#

yeah i know

young flame
#

can u console.log(data)
@molten yarrow it's not his data

#

the way he's coding it

#

is retarted

eternal osprey
#

so how can i ever fix it and define both

molten yarrow
#

does he even get anything?

young flame
#

you can't defined both

#

try changing the code in raid so it doesn't define raids yet

#

like ```js
let raid = []

#

then after raids is defined you can like call something to put in that [] what you have in raids now

#

so raid will work because it wont say undefined because what your defining after will be defined

eternal osprey
#

okay i understand the first part

#

but the second part is kinda complicated

#

could you give an example?

molten yarrow
#

raid = raids[0] is the same as raid = raids.shift()

young flame
#

i didn't say raids[0]

eternal osprey
#

@molten yarrow still would give the raids error

young flame
#

i just said raid = []

molten yarrow
#

you dont need to define raid atall??

young flame
#

he needs raid for raids

inland eagle
#

My friend is a weirdo

eternal osprey
#

i do alina

molten yarrow
#

just use raids[0] ....

eternal osprey
#

ata.raids.filter(raid => getName(raid.pokemon_id).toLowerCase() === options.name.toLowerCase() && raid.level >= (options.level ? options.level : 5))

#

i am calling raid.pokemon id

young flame
#

he needs raid lmao

molten yarrow
#

omg

#

its even worse...

eternal osprey
#

thanks

young flame
#

whats up with the pfp alina

molten yarrow
#

raid is defined in here

young flame
#

kinda pog

eternal osprey
#

wait what really

#

ooowh fuck i did not see that

earnest phoenix
#

someone developing with mongoose?
@earnest phoenix ask your question

young flame
#

i think i fucked discord.js over

#

my images wont show in embeds

eternal osprey
#

@earnest phoenix that was his question lmao

earnest phoenix
#

yeah but he expects someone to say yes and then ask another question

#

so might as well get to the point

eternal osprey
#

btw boys

young flame
#

LOL

earnest phoenix
#

i don't help in dms

eternal osprey
#

it still did not work. Cannot read property 'toLowerCase' of undefined

young flame
#

@molten yarrow MY IMAGES IN EMBED TAKE LIKE 5 MINUTES TO WORK

eternal osprey
#

i am losing my faith in my code.

young flame
#

eh

earnest phoenix
#

bruh this channel is cursed

young flame
#

send the code

molten yarrow
#

@eternal osprey do you even get any data from api?

eternal osprey
#

yeah i do

young flame
#

i'll eval it in my bot and see what happens @eternal osprey

molten yarrow
#

Moon show me ur snipped

eternal osprey
#

i would really appreciate it man!

young flame
#

np lol

molten yarrow
#

you sure? console.log() it

eternal osprey
molten yarrow
#

you fetch is still wrong...

#

i posted it like 10mins ago

young flame
#

god dayum

molten yarrow
young flame
#

1000 character limit

molten yarrow
eternal osprey
#

what's wrong?

molten yarrow
#

you defined it as fetch and call it as afetch...

young flame
#

yeah

#

kinda poggers G)

#

Devs help meh
@earnest phoenix dev senpai is here

#

whats da problem

#

lets see

eternal osprey
#

ah but it still did nothing?

molten yarrow
#

yeah you need add intents to your client :3

young flame
#

always end it in ;

molten yarrow
#

you dont rly need to end with ;

eternal osprey
#

anyways, if you could eval it i would appreciate it! Take your time and jut ping me when you are done with evalling it!

young flame
#

like ```js
const Discord = require('discord.js');

#

you always wanna end it in ; lol

#

stops it from tweaking

prime stump
#

Is there a bot that you can open pokemon cards?

young flame
#

uH

#

i'm not gonna speak lol

#

i tis looking

#

hmmm

#

your screen wont load for mee

safe creek
#

@Lite#6155 IT FUCKING WORKEDDDDDDDD

#

@sudden geyser

sudden geyser
#

good

safe creek
#

YYYYEEEEE BOOOIII

#

Ty btw

tardy hornet
#
case 'giveaway':
  if (!args[0]) return message.reply(`You didn't specify you time`);

        if (
            !args[1].endsWith("d") &&
            !args[1].endsWith("h") &&
            !args[1].endsWith("m") &&
            !args[1].endsWith("s")
        ) return message.reply(`Please format you amount of time correct!`);

        if (isNaN(!args[1][1])) return message.reply(`That is not a number!`);
        let channel2 = message.guild.channels.cache.find(ch => ch.name === "giveaways");
        if (!channel2) return message.reply(`Please create a channel named \`"giveaways"\``)

        let prize = args.slice(2).join(" ");
        if (!prize) return message.reply(`You need to specify a prize`);

        message.reply(`You giveaway has been created on \`${channel2.name}\``)
        let Embed = new Discord.MessageEmbed()
            .setTitle(`🎉 **New Giveaway!** 🎉`)
            .addFields(
                { name: "Host", value: `\`${message.author.tag}\``, inline: true },
                { name: "Prize", value: `\`${prize}\``, inline: true },
                { name: "Date (M/D/Y)", value: `\`${new Intl.DateTimeFormat("israel").format(Date.now())}\``, inline: true }
            )
            .setColor("EA0D0D")
        let m = await channel2.send(Embed).then (m => m.react("🎉"))
        setTimeout(() => {
            if (m.reactions.cache.get("🎉").count <= 1) {
                message.channel2.send(`Reactions: ${m.reactions.cache.get("🎉").count}`);
                return channel2.send(`The giveaway has been ended and failed because not enough people reacted`)

            }

            let winner = m.reactions.cache.get("🎉").users.cache.filter((u) => !u.bot).random();
            channel2.send(`The giveaway has been ended and the winner for \`${prize}\` is ${winner}`)
        }, ms(args[1]))
    break;
#

TypeError: Expected a number

outer perch
#

is that the only thing it says?

tardy hornet
#
   ---->     }, ms(args[1]))
    break;

this line

proper bolt
#

args[1] isnt a number

#

what is ms()

#

show that func

earnest phoenix
#

it's a lib

#

iirc

atomic parcel
#

Does anyone know a good Wolfram Alpha library/API?

proper bolt
#

why would you use a lib for making a string a number

molten yarrow
#

for converting time into ms

earnest phoenix
#

ms is for time conversion

proper bolt
#

@tardy hornet can you show what args[1] is

earnest phoenix
#

but regardless node devs are dumb and need a library for something that's two lines if code lol

proper bolt
#

yep

tardy hornet
#

i fixed that

proper bolt
#

have you seen is-even

tardy hornet
#

ty all

proper bolt
earnest phoenix
#

lol

proper bolt
solemn latch
#

best lib

quartz kindle
#

have you seen undefined.js?

outer perch
#

wat

regal saddle
#

bruh

solemn latch
#

2 issues

#

lmao

earnest phoenix
#

people also keep on installing the install package

#

by people i mean clueless newbies who dont understand how npm works

eternal osprey
#

@young flame have you evalled it yet?

quartz kindle
eternal osprey
#

boys can someone help me out please

solemn latch
#

ports hahaha

quartz kindle
#

ikr

#

everyone should be using this lib

#

it does everything

grizzled raven
#

undefined = require("undefined")

sudden geyser
#

but regardless node devs are dumb and need a library for something that's two lines if code lol
@earnest phoenix I wouldn't say, the ms library is quite useful as a utility for converting some time to milliseconds. It's not like a one-liner library like is-odd. It's useful for preserving DRY as well.

young flame
#

@young flame have you evalled it yet?
@eternal osprey it's over the 1000 character limit

quartz kindle
#

lmfao

sudden geyser
#

THE SOURCE CODE LMAO

quartz kindle
solemn latch
#

these are some remarkable devs

quartz kindle
#

semicolon.js is “a more secure and reliable vapor.js.” Rather than containing zero lines of code, semicolon.js contains a semicolon.

#

vanilla.js is a JavaScript compiler that compiles JavaScript into JavaScript.

stark abyss
#

do you guys like my coding profile picture

past needle
#

if you coded it yes

stark abyss
#

yes def

past needle
#

epic 👍

proper bolt
#

@earnest phoenix run ls in that dir

#

you dont have a package.json

#

not in that directory

#

are you sure you are in the right place?

#

where is the bot src

#

like where is the code stored

#

on your computer

#

k then on your phone

earnest phoenix
#

there is ur problem

midnight blaze
#

this is fucking funny 😄

proper bolt
#

go to the place where your bot code is

#

go to that directory

#

ok run pwd

#

terminal command

green kestrel
#

Shows current directory

proper bolt
#

is the output of that command the correct place?

#

is the bot code in the downloads folder?

#

also have you ever ran it successfully

#

have you ran it before

#

if the code isnt in the downloads folder then you arent in the right place

shy turret
hollow sedge
#

How do I donate to that

#

Thirteen is an unlucky number, I just cannot allow my users to input that anywhere

shy turret
hollow sedge
#

Lol

#

I like how they also have image recognition

#

It's insane

ember lodge
earnest phoenix
#

Try deleting the node_modules folder

Also, use the npm cache clean command

Maybe that will help you

ember lodge
#

ok thanks

somber wigeon
#

Does anyone know where a Discord bot can be hosted other than repl.it?

proper bolt
#

@ember lodge you dont have the command line tool make installed on your computer

ember lodge
#

It's a VPS

#

not a computer

proper bolt
#

ok

#

sudo apt install make should do it i think

slender merlin
#

Hello

thick gull
#

Does anyone know where a Discord bot can be hosted other than repl.it?
a VPS

#

or computer

stark abyss
#

is it me or database are hard asf

thick gull
#

its a learning curve imo

#

but once you get it, it wont be as hard

stark abyss
#

no matter what I try or how much time I spend learning I can't grasp it

#

😔

somber wigeon
#

Thanks for the moment I will stay a repl.it since it is good, in which I have a vps

lyric mountain
#

no matter what I try or how much time I spend learning I can't grasp it
@stark abyss what kind of database?

earnest phoenix
#

Or pay for premium

stark abyss
#

i tried quick.db [easiest yet I failed], nedb, mongodb

lyric mountain
#

Or just save coffee money and buy a vps

stark abyss
#

I get stuck somewhere and then I can't move on

lyric mountain
#

Have you tried sql databases?

stark abyss
#

i would have to learn sql then WeirdChamp

#

postgress is next up

normal sage
#

Does anyone know where a Discord bot can be hosted other than repl.it?
@Mr.Abyssus#0001 heroku, something.host, etc

lyric mountain
#

Either way you'll need to learn something

#

Be it non relational or sql

stark abyss
#

you have a point

#

is it hard?

lyric mountain
#

Also, don't think sql as a programming lang

#

It's really just a "I want this data" query

#

Or "gimme that data, from that table and also sort it by date"

stark abyss
#

oh okay I will try postgress next it's probably gonna take time but worth it

lyric mountain
#

I'd recommend a plug-n-play database to train before you hop into complex ones

#

Like sqlite

stark abyss
lyric mountain
#

How to create a database?
Right click -> New file -> rename -> database.sqlite

#

Also it has very basic data types

#

So it's a really good database to start doing sql

#

Also it doubles as caching database

#

Because it's so lightweight that you'll barely notice it

primal garden
#

Hey all!

#

so I want to add a music command to my discord.js bot

#

Can someone help?

#

Just @ me 🙂

sudden geyser
primal garden
#

@sudden geyser Does this link talk about on how to make a YouTube Music Bot?

#

Sorry if i'm being dumb...

#

I don't mean to

#

I just really don't know how to do music side of things

sudden geyser
#

It teaches you how to work with voice channels in Discord, not how to work with YouTube. As for how to get the YouTube data, I've never worked with music, but I've heard of ytdl-core: https://www.npmjs.com/package/ytdl-core

stark abyss
#

oh okay thhx

hasty mulch
#

Is there a way to capture an airport’s METAR information and post it into Discord with Python? It’s a little project I want to work on

rich ether
#

so im trying to send a embed through pages but it sends the embed written out in text instead of sending the actual embed any ideas?

lyric mountain
rich ether
#

Java: Are you building the embed object?
JS: Are you sending the correct object?
@lyric mountain im using python and yes

lyric mountain
#

Is it sending the string representation of the embed or is it sending the content as text?

#

Nonetheless, double check if you're passing the right object

hasty mulch
#

Someone tag me when they respond to me

dreamy yoke
#

is it against ToS for bot to auto leave server if bot hasn't been used after lets say 1 week?

solemn latch
solemn latch
dreamy yoke
#

just double confirming here.

solemn latch
#

yeah, it may be ideal to mention it somewhere on your bots page that itll leave for no one using it.

dreamy yoke
#

alright thanks

#

that will save me loads of resources

lyric mountain
#

Not as much as you think tho

solemn latch
#

if it helps, it helps 🤷‍♂️

dreamy yoke
#

well it kinda does since i have an online db with a read/write limit

solemn latch
#

never used one

lyric mountain
#

Why not use an embedded db?

#

Or are you heroku'ing?

dreamy yoke
lyric mountain
#

I see

solemn latch
#

heroku pandasad

dreamy yoke
#

well, its only a hobby for making bots but people do use it

lyric mountain
#

It always start like that

#

My bot was never meant to be global too

#

Shiro now kinda became my younger sis

solemn latch
#

my bot also accidentally became public

#

been thinking about taking it down pandasad

lyric mountain
#

Maybe you're missing some smallish details somewhere

rich ether
#

ive tried that

lyric mountain
#

Try debugging the code

rich ether
#

ive started from screatch no embeds just pages

#

any ideas where i should go from there

lyric mountain
#

I mean, ig python has debuggers

rich ether
#

yes i tried nothing came up

lyric mountain
#

Run the code in debug mode

#

And put breakpoints near the place you send the embed

#

Then go step by step seeing object states

rich ether
#

i tried that

#

littlary nothing

lyric mountain
#

Maybe it's a discord issue then, they had some hard issues with embeds today

#

There's an announcement for that

rich ether
#

@lyric mountain

lyric mountain
#

I'd like the screenshot version of it

rich ether
#

okay

lyric mountain
#

On mobile it's hard to read codeblocks

rich ether
#

there tried to make it as easy to read as possible

lyric mountain
#

Btw, why do you use an infinite loop?

#

You could simply listen to OnReactionAdd events

rich ether
#

its easier to use a infinite i find makes there less a chance to getr a rate limit

#

in my mentality at least

lyric mountain
#

Ratelimit for events?

rich ether
#

no

#

for general command spam

drifting wedge
#

how can i send a message and get the message's id?

#

like link?

#

dpy

lyric mountain
#

Anyway, I see nothing wrong there

rich ether
#

yes

#

no nothing is

#

my question is how would i switch out the pages foir embeds

#

cause before when i tried i got this

lyric mountain
#

That's a bad object probably

#

Check if you're enclosing it correctly

orchid vortex
#

in a node.js bot, whats the best option for error handling?
making every command file async then a .catch() in [the file that handles command execution]
using try .. catch within the command file
or something else?

orchid vortex
#

ok guess thats good

#

but uh

lyric mountain
#

This because promises may fail without triggering try-catch sometimes

orchid vortex
#

does .catch work without as-

#

yeah thats true

rich ether
orchid vortex
#

would .catch work on a non async [thing]

#

probably not

drifting wedge
#

how can i get a message's link?
dpy docs didnt help

rich ether
#

because its there

drifting wedge
#

its not

#

how about you point me to it then?

rich ether
#

wait a link?

drifting wedge
#

yes

rich ether
#

u can get a message id but not a link

#

that has to be manual unless its a image

lyric mountain
drifting wedge
lyric mountain
#

For sync stuff try-catch works fine

rich ether
orchid vortex
#

oh well

drifting wedge
#

oh

lyric mountain
#

@rich ether found the issue

drifting wedge
#

i was looking for link not jump

#

@earnest phoenix thanks!

lyric mountain
#

Like, it's a very very "it can't be" error

lyric mountain
#

Or "how tf didn't I notice that" error

rich ether
#

where

#

dont tell me....

lyric mountain
drifting wedge
#

@earnest phoenix if i pass: message.jump_url into a function

#

can i pull message.jump_url?

lyric mountain
#

You're passing the embed object inside the content

rich ether
#

oh fuck me

drifting wedge
#

and just make it a link?

lyric mountain
#

So it's getting converted to string

rich ether
#

fuck this man i need sleep

earnest phoenix
#

wdym?

lyric mountain
#

Lul

rich ether
#

ughhh

earnest phoenix
#

it returns the string

drifting wedge
#

i do message.jump_url

rich ether
#

it send the embed in text form instead of embed form

drifting wedge
#

and i pass that in a function

lyric mountain
#

Yeah

earnest phoenix
#

what function

drifting wedge
#

its passing the url?

earnest phoenix
#

yeah

drifting wedge
#

so i can just do {message.jump_url}?

#

and its the jump url?

#

@earnest phoenix

lyric mountain
#

Did that solve it lope?

rich ether
#

nope

earnest phoenix
#

yes, it's property of Message object

rich ether
drifting wedge
#

lemme try, thanks btw

lyric mountain
#

Aw

#

Ah, btw

#

Isn't there a dedicate method for setting embeds for messages?

rich ether
#

fucking annoying ass code

lyric mountain
#

Like, did u try embed=stuff?

rich ether
#

yes but it dosent work anymore outdated

drifting wedge
#

@earnest phoenix passing: message.jump_url to a function

#

gave error

earnest phoenix
#

what error

drifting wedge
#

syntax

rich ether
drifting wedge
#

i think bc of the .

lyric mountain
#

Try replacing content with embed

earnest phoenix
#

then you must be doing something wrong somewhere

rich ether
#

auto error

drifting wedge
rich ether
#

ugh ill deal with it tmrw

drifting wedge
#

@earnest phoenix

lyric mountain
#

To provide an alternative answer to the one already given, you should be able to edit an embed of a given message like this :

from discord import Embed ... first_embed = Embed(title='embed 1') new_embed = Embed(title='embed 2') # send a first message with an embed msg = await ctx.send(embed=first_embed) # edit the embed of the message await msg.edit(embed=new_embed)
earnest phoenix
drifting wedge
lyric mountain
earnest phoenix
#

see what i sent

#

that's not how you specify a parameter when you're defining a function

drifting wedge
#

ill try to remove message

rich ether
stark abyss
lyric mountain
#

No, not like that

earnest phoenix
#

@rich ether send method returns the Message object it sent

rich ether
earnest phoenix
#

that's why it's sending Message object

lyric mountain
#

Instead of content

rich ether
#

ahhh fuck this

#

imma pay someone to fix this fucker for me

#

who wants to

#

fuck

lyric mountain
#

Don't give up

rich ether
#

i got a whole ai to finish too

#

and deadlines in 6 days

lyric mountain
#

Why an AI?

rich ether
#

the bot has its own "siri" but with text

#

i need to debug it

lyric mountain
#

Ah

rich ether
#

yup

upper agate
#

Hi

lyric mountain
#

Wish I could understand how AIs work so I could make a bot player for my TCG

rich ether
#

hullo

#

wrd wrd

lyric mountain
#

I'll never underestimate games ai now

rich ether
#

its pretty simple once u grasp the basics

#

ill brb goin fo a smoke

lyric mountain
#

But like, the npc would need to understand current arena state, which cards it has and which cards are best to play in that turn

rich ether
#

im back and yes your completey right it would take the cards personal api for the ai to understand it

lyric mountain
#

Still too abstract for me (btw, there's no api, I wrote the game from scratch)

#

It's an in-discord tcg

rich ether
#

ohh wrd

#

and btw the changing it from context to embed dosent work

lyric mountain
#

I'm clueless then

#

Maybe there's a specific way to edit embeds in newest discord.py

#

Ah, hm

#

What if you use both content and embed parameters?

#

Like, put page number in content param and the embed in embed param

#

Maybe it's getting appended because of that page counter

rich ether
#

mabey

#

hmmm

lyric mountain
#

Also, you got a different response this time

rich ether
#

yes

#

lemme try something

#

didnt work

lyric mountain
#

Meh

#

Idk much about dpy, sorry

rich ether
#

u gud g

earnest phoenix
#

you're passing Embed object into content kwarg MegaThonk

rich ether
#

whats ur bot?

#

yes -.- why you have a bette rway of doing it

earnest phoenix
#

i got something like this, after getting the kwargs, you can do, edit(**kwargs)

rich ether
#

would u like to look at the whole code ?

#

and see why that wouldnt work

earnest phoenix
#

sure

rich ether
earnest phoenix
#

try edit(content=f"Page {cur_page}/{pages}:", embed=contents[cur_page-1])

rich ether
#

that actually worked after i tweaked it a bit

lyric mountain
#

Wait, did it?

rich ether
#

yes

#

cause before i had this

#

message = await ctx.send(f"Page {cur_page}/{pages}:\n", embed=contents[cur_page-1]

#

i changed the message