#development

1 messages ยท Page 1944 of 1

spark flint
wicked pivot
#

Hello, is it possible to do example / mod tempmute and the custom suite will be different from / mod kick for example?

earnest phoenix
#

Can a collector be made in a DM Channel?
Like this:

when a user joins a server, the bot DM's them a embed asking to send a SS of the invite they used.
then they send a attachment
*sends attachment*
attachment gets sent to a channel?

#

Mainly can a collector be used in DM's? ๐Ÿคฃ

quartz kindle
#

you cannot sent stuff directly like that with v13

#

.send() expects an object of options, something like { content: "abc", etc }

#

a MessageAttachment is an object

#

so its trying to find attachment.content, attachment.embed, attachment.files, etc

#

which of course do not exist

#

you have to specify that you're sending an attachment object

#

.send({ attachments: [reply] })

earnest phoenix
#

ah

#

that helped me too ๐Ÿคฃ

quartz kindle
#

put it in files instead

#

{ files: [reply] }

#

but actually, if you have the url, why not just send the url directly?

#

if its an image, discord should automatically embed it

spark flint
#

You can get the invite they used on join

#

Instead of making them verify

earnest phoenix
#

How do you do that o-o

west stag
#

If I just run my tiny express script it works flawlessly, but if I use pm2 to start it, it starts and logs 1 thing but doesnt respond to requests anyone know why?

#

tf is wrong with pm2 lol

earnest phoenix
#

Now this doesn't work :why:

client.on('GuildMemberAdd', async member => {

  const verify = new MessageEmbed()
  .setAuthor(`Staff Verification`, client.user.displayAvatarURL({ dynamic:true }))
  .setDescription(`Please send a **image**/\`attachment\` of who invited you. You will need to do this to get access to the rest of the Staff Server. `)

  member.send({ embeds: [verify] })
          })```
#

Discord.js v13 is so much different for these index.js events lol

#

Not sure if that would work but sure? I alr have MessageEmbed defined.

#

Nope ๐Ÿคฃ

#

whaaat

#

why would I even do that?

#

confusion

#

That didn't work.

#

Fixed, I just had "guild" Capitalized.

#

guildMemberAdd works.

earnest phoenix
#

Well, ik now

solemn latch
#

how long have you been getting it? just pushed an update?

500 errors are server side errors, might just be discord problems?

#

if you are doing these tests on a test bot then I would wait a few hours and see if they go away.
If you are testing on your main bot I would revert the changes.

#

ah, then I would just wait tbh.

wicked pivot
#

Hello, is it possible to do example / mod tempmute and the custom suite will be different from / mod kick for example?

earnest phoenix
#

Can I make it so it only sends the welcome embed if they join a specific server using guildMemberAdd?

earnest phoenix
#

huh

#

How in a event?

#

like if(member.guild.id === '') {...}?

#

wait no cause I have it set as message, so it would need to be in a server huh?

vast ore
#

Heya! I was wondering is it possible to use Spotify Web Playback sdk with discord.js to play songs directly from spotify in a voice channel?

solemn latch
quartz kindle
#

wut?

vast ore
#

I see
Thanks for the reply!
As I see it, that api is currently available only for Spotify premium users

solemn latch
#

is it spotify that only gives metadata

#

I cant keep track

quartz kindle
solemn latch
#

ah

quartz kindle
#

i miss european internet T_T

#

100/100 fiber

#

here im stuck with 10/0.5 adsl

solemn latch
#

very thankful with my 200/20
even if the 20 up sucks

vast ore
#

Mine is 150/220 LOL

earnest phoenix
#

Why does .sendTyping() stop typing after like 10 seconds?

#

Because that's whats supposed to happen?

solemn latch
#

yeah, it stops exactly after 10 seconds or a message is sent

#

if you want to do so for longer best to use a slash command and defer update.

#

but you technically can(best not to do it more than a few times)

#

send a message is the only way I know of

earnest phoenix
#

files.map is not a function

#

bruh

#

files is defined but it's not an array ig

#

try console.log(this.options.files)

quartz kindle
#

show search.js line 17

vague swallow
#

Whats the best way to make a transcript of a particular channel?

quartz kindle
#

catch the error from .send()

modest maple
#
        SELECT 
            rooms._id as _id,
            rooms.title as room_title,   
            rooms.votes as room_votes, 
            rooms.topic as room_topic,
            rooms.banner as room_banner,

            p.nsfw as playlist_is_nsfw,

            pe._id as playing_entry_id, 
            pe.title as playing_entry_title, 
            pe.description as playing_entry_description, 
            pe.nsfw as playing_entry_is_nsfw, 

            owner._id as owner_id,
            owner.name as owner_name, 
            owner.picture as owner_name, 
            owner.premium as owner_premium, 
            owner.created_on as owner_created_on,

            guild._id as guild_id,
            guild.name as guild_name, 
            guild.picture as guild_name, 
            guild.premium as guild_premium,
            guild.created_on as guild_created_on
        FROM rooms
        INNER JOIN playlists p on rooms.active_playlist = p._id
        INNER JOIN playlists_entries pe on rooms.playing_now = pe._id
        INNER JOIN entities owner on owner._id = rooms.owner_id
        INNER JOIN entities guild on guild._id = rooms.guild_id
        WHERE 
            rooms.owner_id = $1 AND rooms.active = true
        LIMIT 1;
#

so somewhere in this something is wrong

#

I suspect the last 2 joins but sad

neat ingot
#

-->>

#

Finally fixed the bugs in the little module i wrote earlier that convers md files into embeds for discord.js ๐Ÿ˜„

quartz kindle
#

looks a bit different from md tho

#

you could name it something like embed-down

#

xD

neat ingot
#

yea, its not really markdown syntax supported i guess, not for the most part

#

but if you use the format shown in the template, and save it as an md file, you get syntax highlighting etc, so...

quartz kindle
#

yeah

neat ingot
#

and can use markdown style links in descriptions and stuff, so highlighting on that is nice

quartz kindle
#

there are actually many markdown "flavors" out there, although they all share the same basic markdown syntax, some have different features

#

so you could just make it another flavor

#

embed-flavored markdown

neat ingot
#

mark-the-bed-with-discord---js

quartz kindle
#

hahaha

neat ingot
#

^ i use it for an /info command

quartz kindle
#

nice

neat ingot
#

so at boot i scan the dir for all md files, and use that as the choices for the command

#

so all i need to do now is write up whatever info files i need following that template

#

and i can pass whatever variables in to the template as shown

#

handy af imo

quartz kindle
#

tbh this is the most useful/creative/good-idea lib i've seen around here in a long time

neat ingot
#

๐Ÿ˜ฎ

quartz kindle
#

im usually like "but... why..."

neat ingot
#

thanks lol ๐Ÿ˜„

quartz kindle
#

but this one i actually felt like its useful

#

ahaha

neat ingot
#

yea most things are pointless or just derivatives of other projects that arent as good ๐Ÿ˜„

quartz kindle
#

ye

neat ingot
#

i've been debating releasing my discord.js minigame module for years now

#

recently updated it to support buttons instead of reactions

#

but idk, i like to hogg the good code ๐Ÿ˜„

quartz kindle
#

i have one critique tho

#

besides the different syntax

#

i'd use raw embeds instead of MessageEmbed internally

neat ingot
#

consider yourself quoted ๐Ÿ˜„

quartz kindle
#

that way you get rid of the discord.js dependency, and it works on all libraries, not only discord.js

neat ingot
#

yea i did consider using the message embed object for more flexibility

#

for that very reason

#

like, object structure {}

quartz kindle
#

ye

#

if you really want, you could slap in a formatter

#

for example embedMD.parse(file, { format: "discord.js" })

#

and it returns a MessageEmbed instead of a raw embed

lament rock
#

optional peer compat is wonky imo

quartz kindle
#

you dont need a dependency for that either, just check if the lib is already installed in the user's project

neat ingot
#

im confuzed on how this formatter would work different from the one i have?

quartz kindle
#

honestly i much prefer having peer libs manually controlled than just included as a dep

neat ingot
quartz kindle
#

if lib exists in the project, use it, if not, throw an error/warning and tell the user to install it

neat ingot
#

oh, flagged user, but you get the point ๐Ÿ˜„

quartz kindle
# neat ingot

could initialize the lib with a set of options for the user to define

neat ingot
#

like, global replacers

quartz kindle
#

parser = new Parser({ avatar: "url here" })

#

for example

neat ingot
#

mmk

quartz kindle
#

then ```js

THUMBNAIL

this.avatar

cinder patio
#

tbh I dunno when this would be useful, you can just export the embed object in a different js file and import it when u need it

quartz kindle
#

but well, it does get increasingly more complex if you try to support multiple libs or make it lib agnostic

neat ingot
#

so i'd basically use this as a refernce to gain the globally defined variables rather than the embed specific one?

neat ingot
willow mirage
#

Is there anyway to pass data from a event to a React Component?

#
import {Client, Intents} from 'discord.js'

const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_PRESENCES,
  ]
})

client.on('ready', async () => {
  console.log('Bot is ready');
  const user = client.guilds.cache.get('id')?.members.cache.get('id');
  if(user){
    const data = user.presence?.activities;
    // Pass it to a component
  }
})

client.login('token')
winter pasture
#

@willow mirage What are you trying to accomplish?
Are you trying to run a discord bot in the browser, do oauth2 with Discord or have your bot running on a server send a websocket event down to a frontend react client?

willow mirage
#

yeah

#

it is dumb

#

fuck this shit

quartz kindle
#

if you want to send websocket events to the browser, you need another websocket in the browser

#

otherwise you'd need to queue events and run an update query in a interval in the browser

winter pasture
#

Keep on trying mate
Backend <-> frontend communications can be hard.

Kinda all depends on what you need. If you just need to have all the users presence listed on lets say a Web UI, there is a few ways you can do it

You could spin up a http server on the same instance as your bot, and on frontend page load you ask the http server on an endpoint for the presence data

earnest phoenix
#
db.set(`warnid_${message.guild.id}_${number}`, `${uuidv4()}`)
``` Why does that return "null"?
winter pasture
subtle kiln
#

Discord.js is fetching every channels at startup. The ChannelManager cache is filled with more than 200 000 channels! It takes time and fill the RAM with data I don't need. It seems that I can't disable this cache in the client option. What can I do?

cinder patio
#

I've encountered an interesting problem... I want to generate a random number from 0 to x, but I want a few numbers to not be possible to be generated. I really care about performance here, so for example generating a random number until it's not one of the forbidden numbers won't fly.

I've thought about doing something like this:

const fobiddenNumbers = [...]; // It's sorted
const rng = Math.floor(Math.random() * max);
// Binary search if the random number is in the forbiddenNumbers array
// If it is, return rng + 1

But what if rng + 1 is also inside the forbiddenNumbers array BlobThonk

winter pasture
# subtle kiln Discord.js is fetching every channels at startup. The ChannelManager cache is fi...

Maybe try this from their docs https://discordjs.guide/additional-info/changes-in-v13.html#customizable-manager-caches

const client = new Client({
    makeCache: Options.cacheWithLimits({
        MessageManager: 200, // This is default
        PresenceManager: 0,
        // Add more class names here
    }),
});

I have never used it before tho. So not sure how/if it works as you expect.
I think this is all the stuff:

 makeCache: Options.cacheWithLimits({
          ApplicationCommandManager: 0, // guild.commands
          BaseGuildEmojiManager: 0, // guild.emojis
          GuildBanManager: 0, // guild.bans
          GuildInviteManager: 0, // guild.invites
          GuildManager: Infinity, // client.guilds
          GuildMemberManager: {
            maxSize: Infinity, 
            keepOverLimit: (value, key, collection) => value.id === this.user.id,
            sweepFilter: collection => (value, key, collection) => value.id !== this.user.id,
            sweepInterval: 600
          }, // guild.members
          GuildStickerManager: 0, // guild.stickers
          MessageManager: {
            maxSize: 100, 
            sweepInterval: 60
          }, // channel.messages
          PermissionOverwriteManager: 0, // channel.permissionOverwrites
          PresenceManager: 0, // guild.presences
          ReactionManager: 0, // message.reactions
          ReactionUserManager: 0, // reaction.users

          RoleManager: Infinity, // cache all roles
          PermissionOverwrites: Infinity, // cache all PermissionOverwrites. It only costs memory if the channel it belongs to is cached
          ChannelManager: {
              maxSize: 0, // prevent automatic caching
              sweepFilter: () => channelFilter, // remove manually cached channels according to the filter
              sweepInterval: 3600
          },
          GuildChannelManager: {
              maxSize: 0, // prevent automatic caching
              sweepFilter: () => channelFilter, // remove manually cached channels according to the filter
              sweepInterval: 3600
          },

          StageInstanceManager: 0, // guild.stageInstances
          ThreadManager: 0, // channel.threads
          ThreadMemberManager: 0, // threadchannel.members
          UserManager: {
            maxSize: Infinity, 
            keepOverLimit: (value, key, collection) => value.id === this.user.id,
            sweepFilter: collection => (value, key, collection) => value.id !== this.user.id,
            sweepInterval: 600
          }, // client.users
          VoiceStateManager: 0 // guild.voiceStates
      }),
sudden geyser
#

But what if rng + 1 is also inside the forbiddenNumbers array
@cinder patio then how about incrementing the number until it exceeds the max or is not forbidden? Or how about just biting the bullet and retrying the random number? What's the actual performance cost of using Math.random()and Math.floor, anyway?

cinder patio
#

The forbiddenNumbers array could contain all numbers except one

#

So repeating would make the performance depend on randomness, same with the other solutiom but to a lesser extene

winter pasture
#
const forbiddenNumbers = [4, 40, 100]

const randomNumber = (max: number) => {
  const random = Math.floor(Math.random() * max)
  if (forbiddenNumbers.includes(random)) {
    return randomNumber(max)
  }
  return random
}

maybe?
Just sudo code, not sure it it would even run ๐Ÿ˜›

winter pasture
#

I really care about performance here
I for some reason read it as "I do not care about performance" facepalm

subtle kiln
lament rock
subtle kiln
lament rock
#

I'm working on making ThunderStorm more like v13

spark flint
#

openvz or kvm

sudden geyser
subtle kiln
lament rock
#

If you're getting to the point of needing to micro manage your client's memory state, then you should be using modular libs instead of Discord.js because it caches anything and everything it can

#

The closer you get to raw socket writing, the more performance you will get, but induce a headache. The libs I mentioned are a nice middle ground

quartz kindle
quartz kindle
lament rock
#

net.Socket is what I meant

quartz kindle
#

i wrote my own websocket for my custom lib instead of using ws and the difference is pretty stupid

lament rock
#

can you send a link? I'll probably implement it into cloudstorm

lament rock
#

Ah hm. Cloudstorm does allow for proxying the gateway connection which could be over http, so this might be fun to implement

quartz kindle
#

i'll publish some benchmarks in the next couple months, but one of the tests i ran was measuring the time it takes from a packet to be received by net until its emitted by client, and over ~1800 GUILD_CREATES my code spent around 500ms combined, while ws took 6000+

lament rock
#

God damn

quartz kindle
#

i also got performance improvements for etf

#

my pure js etf unpacker is about 30% faster than the official native discord/erlpack

lament rock
#

do you have a link for that as well

quartz kindle
#

its in there as well

#

in the same file

lament rock
#

Okay. If you ever make those into standalones, do lmk since I don't exactly want to dupe code or copy/paste

quartz kindle
#

i dont think i'll make the etf standalone, at least not for now

#

because its a limited subset of the etf spec, i only coded the parts that discord actually uses

#

if i make it standalone, i'll need to code the entire spec

lament rock
#

I'd say that's good enough since they don't pack the entire erlang spec either in erlpack

quartz kindle
#

they cover the parts that js supports

#

i only cover what discord uses, which is even smaller lel

lament rock
#

yeah

quartz kindle
#

same thing with my websocket code

#

i only coded a subset of the websocket spec

#

and cut a lot of corners to make it faster

lament rock
#

perhaps you don't have to label it as full spec and instead advertise as Discord specific

quartz kindle
#

perhaps

#

but discord specific is already what the lib is

lament rock
#

so long as Discord doesn't dramatically change their communication layer

quartz kindle
#

its pretty modular already

lament rock
#

A little bit of a conflict of interest since I maintain all of the WeatherStack modules

quartz kindle
#

i guess

split hazel
#

any nextjs nerds here

#

i want to clear all of my query string on the client side with useEffect but the query string is briefly reverted after being removed
window.history.replaceState({}, document.title, "/");

#

@woeful pike sorry for ping but im sure you'd be excited to answer this

#

maybe something to do with dev mode?

wheat mesa
#

You canโ€™t put an object in a parameter expecting a string

quartz kindle
#

image url requires the actual url

#

not an attachment

#

meaning setImage requires the actual text value

#

setImage("https://c.tenor.com/G6DW8l99nKsAAAAC/sakuya-fumo.gif")

west stag
#

Right click the picture and select "Open in new Tab" then copy that url

#

Or do you mean dynamic

quartz kindle
#

use whatever the search gives you

#

like

#

use the url directly

#

dont create an attachemt

#

setImage(googleresulthere.url)

west stag
#

Yeah

#

Put the url directly into it

earnest phoenix
#

@earnest phoenix all you'd have to do is ```js
.setImage(${reply});

#

lmk if that works

#

try using message.reply, it's a cool new feature with inline replies

#

you can also add this to disable the mention ```js
allowedMentions: { repliedUser: false }

#

so it'd be ```js
message.reply({embeds: [embed], allowedMentions: { repliedUser: false }})

surreal sage
#

I'm trying to get the body of my HTTP server post request but it's nothing while there is something..

#

I'm logging with json stringify body

#

and req.on data

#
var body = ''
        req.on("data", function(data) {
            body += data
        })

        console.log(JSON.stringify(body))```
#

Also tried logging 'body' itself

#

Also nothing

#

I have this as body 'WHtest'

pale vessel
#

Body is a string

surreal sage
#

Yeah

#

But to be sure

pale vessel
#

Why are you stringifying a string?

surreal sage
#

double string

pale vessel
#

Also, log it after it's done, in the end event

surreal sage
#

bruh moment

#

fixed

#

ty lul

earnest phoenix
#

what is reply

#

can you console log it and send me exactly what it is

#

console.log(reply)

#

yeah no of course

#

just ping me whenever

real phoenix
#
@client.command()
async def howlong(ctx):
  today = datetime.date.today()
  d = datetime.date(2021,12,25)
  diff = d - today
  embed = discord.Embed(title="How long until Christmas?", description=f"{diff.days} days!", colour= 0x003DFF)
  print(str=(embed.colour))
  print("triggered.")
  await ctx.send(embed=embed)

I have a embed here and it works but its not changing the colors nor is it printing the color.

proven lantern
#

thumbnail is 1:1 i think

boreal iron
#

Nobody actually uses fucking British English

#

But idk the py library, just assuming

pale vessel
#

Both work

dry imp
#

both color and colour works

real phoenix
boreal iron
#

Haha lmao

real phoenix
#

also colour works on another embed I have

boreal iron
#

Is it because of the whitespace between colour and the hex code?

real phoenix
#

i'm not sure

boreal iron
#

Idk py, too so try it at least

real phoenix
#

I'll try and run it without it but I doubt thats the issue

#

Wow that actually fixed it tysm

#

i also had to pass the print as a string

wooden ember
#

what causes this?

#

this is my bot that pings mc servers and changed channel names to weather they are up or not

#

it pinged on server said it was down and tryed to edit the channel and got this error

#

is there a way to fix this or is it just my internet being crap?
and if so would just catching the error on the channel.edit be enough to stop it from crashing

outer zenith
#

wats the correct call ๐Ÿ’€

wooden ember
#

ah cool

outer zenith
#

or

quartz kindle
#

console.log it

#

or show where you define it

outer zenith
quartz kindle
#

thats the problem

#

Discord is not an exported variable

#

Constants is

outer zenith
#

:0

#

wat

quartz kindle
#

{ abc } = require("something")
is the same as
require("something").abc

#

you are doing { Discord } = require("discord.js")

#

which is the same as doing this

#
const Discord = require("discord.js")
Discord.Discord
#

there is no Discord.Discord

outer zenith
#

a ok thank u

quartz kindle
#

there is no Discord inside the exported variables

wooden ember
quartz kindle
#

you can .catch anything that returns a promise

wooden ember
#

ah fair enough

quartz kindle
#

likewise anything that returns a promise does so for a reason, and usually the reason always involves a risk of failure

#

so unless you have full control over what the promise is doing, you should probably be catching ALL promises

wooden ember
#

i have been lazy at that tbh but im trying to make the bot so everything it cought and delt with so it wont crash

#

i just wish there was a "if there is an error anywhere just log it and move on" function i can make so i dont have to type out a catch for everything

#

that would be espesually useful when dealing with ytdl- core cuz that spews errors out everywhere since google is mega annoying

#

still never got my music player to work but there seems to not be any real documentation on how to get crap to work so i just gave up in the end

wheat mesa
#

Personally I havenโ€™t had many issues with ytdl-core

wooden ember
#

it not ytdl thats the issue is google breaking the api every month

#

and that causes ytdl to error and crash the whole program

#

also to clarify the reason i cant get music to play isnt due to ytdl either i just cant fined any mention of how to get audio to work with d.js v13 other than "heres how you joijn a channel you can figure the rest out"

#

anyway must sleep

neat ingot
#

streaming audio seems to cause so many people so much issues, is it really that complicated?

quartz kindle
#

djs v13 did complicate stuff a little bit by separating audio from the core

#

since now people have to manually control it instead of most of it being automatic

#

and on the lower level audio is indeed quite complicated, discord is very demanding in regards to audio formatting, encoding and encryption

neat ingot
#

yea, audio can get really complicated

#

I've written a few audio visualizers in js

#

like, it can be easy once you understand how it flows

#

but when getting into it, it is quite the pain lol

quartz kindle
#

im still pondering whether or not i'll make an audio module for discord

#

since i dont use audio myself

neat ingot
#

oh? for what purpose? just ease of use?

quartz kindle
#

for my discord lib

neat ingot
#

fair lol

#

I've been enjoying my shiny new module that i wrote ~ even if others dont see much point in it, its super helpful for me ๐Ÿ˜„

#

was thinking of cleaning up some of my other things and publishing that

quartz kindle
#

nice :)

neat ingot
#

i'd kind of like to have a standard project that i can clone for bot related projects that lives in a docker container, along with other containers for a bot website, system metrics, routing, etc

boreal iron
quartz kindle
#

those are all things i already started long ago

#

and never finished

wheat mesa
#

...it shouldn't

#

probably not

#

perhaps you should provide some more code

#

because that 1 line is not the problem

#

well that's why

#

you're getting 3 results

errant flax
#

is it ok for my bot to be ran in repl.it not being hosted in repl.it just like yk a testing place weirdsip

pale vessel
#

Why not

boreal iron
#

Shouldnโ€™t the message option be attachments instead of files?

lament rock
#

attachments is for embeds

#

files is for images outside of embeds

boreal iron
#

Ahh alright

lament rock
#

You should post an embed with the url to the image file set as the image url

#

Don't download anything you don't have to

#

No. files array is for when you have Buffers of files

#

message.reply({files:

#

That's using files

#

No I didn't sorry. The one you linked should be correct

#

I thought you linked to the files one

lyric mountain
#

That's not a valid image url sir

#

Note how it didn't even appear the gif embed

#

https://c.tenor.com/6VVh7C5NzUcAAAAC/horse-hi.gif

#

This is the url

#

Idk, it's the gif from that url u sent

wheat mesa
#

interesting naming conventions

lyric mountain
#

Idk, what's the payload you get?

#

(payload = the returned json/xml/whatever from the api)

#

Only the link?

#

Like, nothing more?

errant flax
#

dumb question but how do u transfer a discord bot into a discord team

lament rock
#

Transfer ownership

errant flax
#

where is that topggVeld

#

oh wait i cant transfer my bot if its already in a team?

lament rock
#

I think so

old cliff
#

hey is there a way using node so that if someone clicks specific text in the console it gets copied to clipboard?

lament rock
#

I think that would require a special terminal interface instead of just the basic terminals shipped with the os since there are no events when a user highlights text or when the curser goes to a row and column in the terminal afaik. Although might be worth looking up if you can get the cursor position

earnest phoenix
#

I just tried

#

Only reason it didn't appear is cause I think he bolded it (just checked bolding an image url makes it not embed)

#

You can try just sending the image url itself

#

without bolding

#

Noice

zenith knoll
#

im getting TypeError: Right-hand side of 'instanceof' is not an object

when trying to add a command to a collection (im using eris)

my code is

require('dotenv').config();

const Eris = require('eris');
const client = new Eris(process.env.BOT_TOKEN, { intents: ['all'] });

client.commands = new Eris.Collection();

const fs = require('fs');
[...]
const commandFiles = fs
    .readdirSync('./commands')
    .filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    client.commands.add(command);
    console.log(`Registered command : ${file.replace('.js', '')}`);
}
[...]
lament rock
#

the Collection.add probably is what checks if the passed reference is an object. You might want to log the value of command before it's added and make sure it's an object

wheat mesa
#

you might be passing undefined on accident

zenith knoll
#

and it goes on for the other cmds etc

wheat mesa
#

do you have any undefined entries, or something similar?

zenith knoll
#

no, i just retried and commented other commands leaving just ping

wheat mesa
#

this is all the code for Eris's Collection class, at some point you're passing something that isn't an object into it

#

Are you logging the commands before or after you try to add them?

#

If you're logging after, log before instead

zenith knoll
#

im logging before

[...]
console.log(command);
client.commands.add(command);
wheat mesa
#

paste what it logs in here

earnest phoenix
zenith knoll
# wheat mesa paste what it logs in here
Registered event : messageCreate
Registered event : ready
{ id: 'ping', execute: [Function: execute] }
/Users/.../node_modules/eris/lib/util/Collection.js:60
        if(!(obj instanceof this.baseObject || obj.constructor.name === this.baseObject.name)) {
                 ^

TypeError: Right-hand side of 'instanceof' is not an object
    at Map.add (/Users/.../node_modules/eris/lib/util/Collection.js:60:18)
    at Object.<anonymous> (/Users/.../index.js:29:18)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Node.js v17.3.0```
wheat mesa
#

interesting

earnest phoenix
wheat mesa
#

seems like you have to pass in the base object when creating a collection in eris

#

(Perhaps?)

earnest phoenix
#

just use a djs collection

zenith knoll
#

what would my base object be?

#

my commands dont extend or implement anything

earnest phoenix
#

then when inserting do new Command(command)

zenith knoll
#
module.exports = {
    id: 'ping',
    execute() {
        return;
    },
};
earnest phoenix
#

make a class called Command that defines what properties the command can have

zenith knoll
#

ooh

#

yeah i understand

#

plug in the values

#

from the cmd files

earnest phoenix
#

yup

zenith knoll
#

into objects

earnest phoenix
#

your nickname is a lie

zenith knoll
#

it is

#

welcome to humaity

#

humanity

#

did i mention i cant spell

earnest phoenix
#

*can't

zenith knoll
#

.-.

lament rock
short pilot
#

I've been stuck on this for hours and am gonna... How do you remove a rich embed from a message when you edit it with python?

lament rock
#

baseObject is supposed to be an typeof Class and add expects an instanceof Class

zenith knoll
#

i see

#

so what n0 said

lament rock
lament rock
#

or use a Map

short pilot
#

But i want to clear the rich embed completely

lament rock
#

Then pass an empty array of embeds

earnest phoenix
#

he tried that once

short pilot
#

I've tried embed=None, embed=[], embeds=None, embeds=[]

lament rock
#

then you need to make a raw request patching that message supplying an empty array

earnest phoenix
#

or stop using python

short pilot
#

I have no idea how to make a raw request but at least i've got something to go on now pepe_hmm

lament rock
#

Idk either since I use JS, but gl

short pilot
#

alright figured it out, should know in a min if it works

zenith knoll
#

and the "sigma truth 69"

short pilot
#

what is my webhook id and token pepe_thinking

woeful pike
#

what the hell

#

how do you expect to be able to fix anything with code like this

#

use variables my man

#

have you checked what the size of message.guild.channels.cache.size is

fiery creek
#

Am in starting Trouble

In Database am adding a userid with so an so time like reminder.

So for particular Interval it should send message to user DM. Unfortunately am stuck over there. Can somebody assists me with reminder on ready event if possible

neat ingot
#

@quartz kindle Took your advice and added global replacers to my module/lib/thing, and then also uploaded some spiffy documentation for it all (https://dekita.github.io/md-embed/). hopefully dont need to touch it for a while now ๐Ÿ˜„

earnest phoenix
woeful pike
#

bruh don't scare me with pings like that

earnest phoenix
#

lmfao

surreal sage
#

I'm doing a post request via php but it just returns bool(false), what did I do wrong?

#
            $url = "noneofyabusiness:69420";

            $opts = array('http' =>
                array(
                    'method' => 'POST',
                    'header' => 'Content-type: text/html',
                    'content' => "EN".$lastArg
                )
            );

            $context = stream_context_create($opts);
            $result = file_get_contents($url, false, $context);

            print(var_dump($result));```
#

To my knowledge, it isn't even sending the request

#

I want to send a text/html body to the server

gentle condor
#

So discord has introduced timeout/server mute,i was wondering how can i timeout someone using discord py anyone has any idea?

surreal sage
#

You'll have to wait for a new release

#

Or else check their docs

gentle condor
#

hm

#

ty

royal pawn
#
@bot.command()
async def reactionrole(ctx):
   msg = await ctx.send("reactionrole")
   await msg.add_reaction('๐ŸŽ…') #and stuff...
slender thistle
#

on raw reaction add, check message ID and emote

jovial nexus
#

How can i get the date of when a user was banned in djs?

earnest phoenix
#

v13 or v12?

errant flax
#

cant wait til' u see my messy code

#

why would i

#

if it works

#

it works

#

but it works

#

give me a sec

#

good luck cleaning that code ;)

flat copper
#

my code:

<div class="form">
                        <form method="POST"><label for="tag">Your discord tag.</label><br>
                                <input type="text" id="fname" name="fname" placeholder="@dream#6262" required><br>
                                
                                <label for="fage">Your Age [optional]</label><br>
                                <input type="number" id="fage" name="fage" min="13" max="20" placeholder="13"><br>
                                
                                <label for="fwhymod">Why do you want to become a mod?</label><br>
                                <input type="text" id="fwhymod" name="fwhymod" placeholder="I want to help the server!" required><br>
                                
                                <label>If there was someone who was breaking the rules and ignoring warnings what would you do?</label><br>
                                <input type="text" name="test" placeholder="i will kick him." required><br>
                                
                                <button type="submit">Submit</button>
                        </form>
                </div>

whenever i press submit button req.body gives undefined

#
router.get("/chmod", (req, res) => {
  res.sendFile(path.join(__dirname, "../pages/chmodform.html"))
})

router.post("/chmod", (req, res) => {
    console.log(req.body)
})```
spark flint
#

2 secs i'll get the code i use

#
const bodyParser = require('body-parser');


app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(bodyParser.raw());```
#

that works and then you can do req.body.fieldname

earnest phoenix
#

<Express>.json() works too

spark flint
#

ah

#

i always get undefined if i don't require body-parser

#

so thats why i suggested

zenith knoll
#

my BaseCommand is

module.exports = class BaseCommand extends Object {
    constructor(id, execute) {
        super(id, execute);
        this.id = id;
        this.execute = execute;
    }
};
#
require('dotenv').config();

const BaseCommand = require('./schema/BaseCommand');
const Eris = require('eris');
const client = new Eris(process.env.BOT_TOKEN, { intents: ['all'] });

client.commands = new Eris.Collection();

const fs = require('fs');

const commandFiles = fs
    .readdirSync('./commands')
    .filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    console.log(command);
    client.commands.add(new BaseCommand(command.id, command.execute));
    console.log(`Registered command : ${file.replace('.js', '')}`);
}

client.connect();
#

TypeError: Right-hand side of 'instanceof' is not an object

spark flint
#

that might help

zenith knoll
quartz kindle
#

nevermind, i scrolled up, what is index.js line 29?

earnest phoenix
#

Hi

zenith knoll
#

idk whats with the weird line wrap on discord

#

maybe its just me

quartz kindle
#

separate those lines and log it

#
console.log(command)
const basecommand = new BaseCommand(...)
console.log(basecommand);
client.commands.add(basecommand);
#

then show the logs for both console.log(basecommand) and console.log(command) that come up right before the error

zenith knoll
quartz kindle
#

show full logs

#

including the error

zenith knoll
#

kk

#
Registered event : messageCreate
Registered event : ready
{ id: 'ping', execute: [Function: execute] }
BaseCommand { id: 'ping', execute: [Function: execute] }
/Users/kyrok/Programming/NodeJS/verbose bot/node_modules/eris/lib/util/Collection.js:60
        if(!(obj instanceof this.baseObject || obj.constructor.name === this.baseObject.name)) {
                 ^

TypeError: Right-hand side of 'instanceof' is not an object
    at Map.add (/Users/.../node_modules/eris/lib/util/Collection.js:60:18)
    at Object.<anonymous> (/Users/.../index.js:32:18)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Node.js v17.3.0```
quartz kindle
#

index.js line 32 is client.commands.add right?

zenith knoll
#

yep

arctic solar
#

hey

zenith knoll
#

hi

arctic solar
#

so

#

my pip command ain't working

zenith knoll
#

wdym not working

arctic solar
#

wait

zenith knoll
#

either you didnt add to path

#

or restart ur pc after

arctic solar
#

long back

#

never run python in my pc

#

i use jupyter or repl or google collab or vs code

spark flint
#

install python then

zenith knoll
#

install, add to path, restart

spark flint
arctic solar
#

bruh

spark flint
#

clearly not then

#

try pip3

quartz kindle
# zenith knoll ``` Registered event : messageCreate Registered event : ready { id: 'ping', exec...

according to the eris collection code, the collection expects a base object to be given when the constructor is called, so for example you have to tell Eris.Collection what kind of data the Collection is supposed to have: new Eris.Collection(baseObject). in your case you have to give it the class that you use to create the commands, meaning client.commands = new Eris.Collection(BaseCommand) so that it knows that this is a Collection of BaseCommands

zenith knoll
#

OOHH

#

Bruhhhhhhhhh

#

I need to read docs better

arctic solar
#

wait

#

i got this

zenith knoll
#

Some require it

arctic solar
#

the path is not right

zenith knoll
#

Yeah

#

Install it

#

You cant eat a cookie when you dont have a cookie

arctic solar
#

i'll play a game

zenith knoll
#

You cant play a game when you dont have a game

arctic solar
#

bruh

#

why is

#

this not going on

#

???

zenith knoll
#

???

arctic solar
zenith knoll
#

Patience is of virtue

arctic solar
#

how long

#

????

zenith knoll
#

Depends on ur wifi and pc speeds

arctic solar
zenith knoll
#

Good for you

arctic solar
#

i die

#

bie

zenith knoll
#

After installing

#

If it doesnt work

arctic solar
#

python in desktop is so hard

zenith knoll
#

Try restarting pc

#

And then try again

#

Well

#

I dont exactly agree with that mindset

arctic solar
#

till i do some crime

spark flint
arctic solar
zenith knoll
#

Larr

arctic solar
#

yea my game

zenith knoll
#

Using pygame?

arctic solar
#

node

zenith knoll
#

I see

arctic solar
#

jk

#

c++

#

and unity

zenith knoll
#

Unity uses c#

#

But kk

arctic solar
#

no

#

c++

#

you got to use a few packages

#

to code it in c++

zenith knoll
#

Then use unreal or something

#

Its c++

arctic solar
#

and i made the game in c++

#

but

#

i uses unity

#

wait a minute

zenith knoll
#

Confusion

arctic solar
#

wuts the dif between c# and c++

zenith knoll
#

.-.

arctic solar
#

man

zenith knoll
#

They are 2 different programming languages

arctic solar
#

i just saw a ytb video

zenith knoll
#

You're joking right

arctic solar
#

i did?

zenith knoll
#

Step by step tutorials are a thing

arctic solar
#

brurrrrrruh

#

why so serious

zenith knoll
#

Hey he might just be new to development

arctic solar
#

you don't know my jokes?????

#

tf

zenith knoll
#

I cant tell if youre joking or not

arctic solar
#

i speak in python

zenith knoll
zenith knoll
arctic solar
zenith knoll
#

Damn

arctic solar
zenith knoll
#

Read what i said

#

Restart pc

arctic solar
#

i was trolling

#

bruh

zenith knoll
#

Lmao

arctic solar
zenith knoll
#

Im confused

#

So did you actually have a problem with pip

#

Or were you just messing with us

arctic solar
#

hows this suit

zenith knoll
#

What a way to make friends

raw nest
zenith knoll
#

tailwindcss makes templates right

#

maybe its a twcss templae

raw nest
#

hm, but which one? ๐Ÿง they have a ton I think

zenith knoll
#

look around idk

raw nest
#

I'm looking on GitHub, they have the docs code there...

cinder patio
short pilot
#

Still trying to find a way to edit a message to remove a rich embed from it...

wheat mesa
#

Have you tried asking in your libraryโ€™s official discord

#

They would probably know

cinder patio
#

embeds: []

wheat mesa
#

Heโ€™s on a python lib

short pilot
#

Asked four different places, keep getting redirected to different servers and channels

past crypt
#

lf a jojo fan who has knowledge of javascript

quartz kindle
quartz kindle
#

do you use discord_components?

short pilot
#

solved

#

i swear i tried this before 100 times but it was embeds=[]

quartz kindle
#

๐Ÿ‘

earnest phoenix
faint prism
#

I'm trying to figure out how to manage clustered sharding. Not sure if anyone else has any better approaches as far as solving this system architecture problem, but so far I've setup a lightweight API (ShardManager) that knows how many total shards I'm going to scale to, and give an ID out to each sharded client that asks for an available shard ID. If none are available, the sharded client exits cleanly. It works... okay
https://i.imgur.com/gH3viZX.png

quartz kindle
#

nothing wrong with it

#

as long as each of your shard clients is a process that contains multiple shards

faint prism
#

It's a docker swarm, with replicated containers

quartz kindle
#

then its not really "clustering", is it?

#

what does each container contain?

faint prism
#

A single discord client that reaches out on startup to the ShardManager for an available ID (and total shard count) to pass on to the Discord gateway

quartz kindle
#

so each of those shards is a full docker?

faint prism
#

mhm

quartz kindle
#

sounds very inefficient

faint prism
#

Well it's the only running process in that container

#

I had a few other architecture ideas as well

quartz kindle
#

my "ideal" architecture would be very similar to yours but with each process containing multiple internal shards

faint prism
#

An alternative is Load balancing, by offloading the busy logic to nodes (maybe web apis?)

#

Or another would maybe be a messaging queue (AMQ?)

#

But those would likely have to be internal sharding

faint prism
quartz kindle
#

if you wanna go for a "funnel" that forwards events to workers, you can use worker threads with internal sharding

#

if you wanna make each worker a self-contained shard+logic, processes are better, but still internal sharding on each process

#

a full process for only one shard is very wasteful

#

and does not scale well

#

thats essentially what discord.js does

faint prism
#

There is no internal sharding with the library I'm using

quartz kindle
#

you can always make your own internal sharder

#

just create and manage multiple client instances

faint prism
#

But, I can probably wrap my existing usage into either separate background threads or full processes

#

Yeah

faint prism
quartz kindle
#

its better to ask for individual shards

#

because the manager also has to control the login queue

#

otherwise you'll run into gateway ratelimits

faint prism
#

You're misunderstanding what my ShardManager API does

#

It's simply an API that maintains a concurrent stack of available shard ids, and either supplies a new shard id, or returns an unsuccessful response stating "out of available shards". It also exposes a simple interface for me to modify the amount of available shards

#

Each client, currently, reaches out for an ID and amount of total shards, to pass along to the discord gateway themselves

#

The ShardManager doesn't communicate with Discord directly

quartz kindle
#

yes i understand that

#

but you cannot have multiple shards connect concurrently

quartz kindle
#

yes

#

no matter how stateless you try to be, you still need a centralized login queue

faint prism
#

Seems to be working with the current layout

quartz kindle
#

just handing off shard ids to other processes is not enough, they wont know whether other processes are trying to connect at the same time

#

so they will run into gateway ratelimit errors

#

the gateway limits are 1 login per 5 seconds for small bots, and 16 logins per 5 seconds for big bots (100k+)

faint prism
#

It's sending the Shard Id and Shard Count along with the Identify gateway interaction for each replicated client. I'm not seeing any failures...

#

Wouldn't I see that error response from the gatway, since this is a small bot?

quartz kindle
#

try having 2 clients connect at the same time

faint prism
#

I'll try scaling from 0 to 2 clients

#

1 sec

quartz kindle
#

your logs above are spaced by ~30 seconds, so there wont be an issue there

faint prism
#

mhmm

#

I noticed that

quartz kindle
#

but if you try to connect twice within 5 seconds, one of them will fail and retry

#

and disconnections and reconnections must also be accounted for

#

resumes dont count, but reconnects do

faint prism
# quartz kindle resumes dont count, but reconnects do
[19:17:01 INF] Retrieving gateway endpoint...
[19:17:02 INF] Starting a new session (949 session starts remaining of 1000; limits reset in 02:32:06.4590000)
[19:17:02 INF] Connecting to the gateway...
[19:17:02 INF] Creating a new session...
[19:17:07 ERR] Local unrecoverable gateway error: The payload after identification was not a Ready payload.
[19:17:07 ERR] Gateway error: The payload after identification was not a Ready payload.

Maybe this is it

earnest phoenix
#

Does anybody know how to have mutiple different colors in a console.log function using css
This is my code and it returns as this

#

use chalk

#
const chalk  = require( 'chalk' );

console.log(chalk.blue('Hello world!'));
#

@earnest phoenix this

#

i dont want to use chalk

#

smh

#

i figured it out, its not css for console colors its ansi colors

wheat mesa
#

This is a stupid question, but does anyone know how to convert a discord attachment into a buffer?

wheat mesa
#

Nevermind, got it

split hazel
#

anyone know where I can find low-level implementation details for nvidia graphics cards?

#

down to the metal information such as what each register does and what data it holds

solemn latch
#

Oh fun

fickle magnet
#

Im trying to use the Command design pattern

sage prairie
#

how add timeout

earnest phoenix
#

Is there a way that quick.db can work on a VPS?

solemn latch
#

Quick db works anywhere realistically

earnest phoenix
misty sigil
#

can you set both options and choices on a djs slash command

#

๐Ÿค”

earnest phoenix
#

Whenever I use a bot that has quick.db on it, it says "Malformed database schema(?)"

wooden ember
#

cuz atm i just use chalk

wooden ember
#

ooooo

#

thats cool

main oak
#

could someone help me? I dont understand why but im getting a error "Cannot access 'message' before initialization"

#
const {
    SlashCommandBuilder
  } = require('@discordjs/builders');

  module.exports = {
    data: new SlashCommandBuilder()
      .setName('embed')
      .setDescription('embed a message'),

      async execute(interaction, client) {
  const args = message.content.split(' ')
  let message = args[0]
      const embed = new client.discord.MessageEmbed()
        .setColor('6d6ee8')
        .setDescription(` ${message} `)
        .setFooter(client.config.footerText, client.user.avatarURL())
        .setTimestamp();
      await interaction.reply({
        embeds: [embed]
      });
    }, 
  };
real rose
#

You'll need to elaborate a bit more, and show code snippets. However, you're most likely defining message after trying to use it.

#

You can't use message.content and then define message on the next line! You should try re-working your code to define message before using it. (Or rename variable from message to something else such as "msg")

#

that was a lot of "message" in a short space of time

solemn latch
#

just a note, your message definition isnt a message. probably best to name variables of what they are, not random other things

main oak
#

Im trying to follow a guide but its not helping, Sorry

solemn latch
#

probably best to follow the offical djs guide

#

its quite easy to follow

main oak
#

i couldnt find one for message arguments (In a slashcommandbuilder) , Ill look again

solemn latch
#

I dont think slashcommandbuilder has a method for that ๐Ÿ‘€ does it?

#

slash command builder uses options

real rose
#

Yeah it would be options afaik.

main oak
#

Ill try again, My bad

short pilot
#
user_id = discord.utils.get(client.get_all_members(), name="olie", discriminator="6728").id```
#

why does this suddenly not work anymore pepe_hmm

#

returning None

sudden geyser
#

do you have intents enabled

solemn latch
short pilot
#

hmm no

real rose
#

I am still lowkey scared of slash iwl

#

Don't use them too often

solemn latch
main oak
#

is how i get the input correct?

short pilot
#

yeah, it must have been on when i tested it before, hmm how do i fetch a single persons user id from their username pepe_hmm

real rose
short pilot
real rose
#

Wait sorry are you trying to avoid using intents?

solemn latch
real rose
#

I'm not 100% sure what's excluded in the new members intent. I haven't had a chance to dig into it yet.

short pilot
#

ugh. i should have saved the ids and the usernames

real rose
#

That was quick wow, thank you lmao. I need to do lots of background before I overhaul my bot smudge

solemn latch
#

I was already on the page double checking ^_^

real rose
#

private bots are so much easier to handle

real rose
solemn latch
#

yeah kek

real rose
#

I must use some dpy to practice my py for college

#

mega brain

main oak
solemn latch
main oak
#

lemme get it again

#
MessageEmbed description must be a string.
solemn latch
#
data: new SlashCommandBuilder()
      .setName('embed')
      .setDescription('embed a message')
      .addStringOption(option =>
      //optiondatahere
      ),

to add it to the registering

#

add the option*

main oak
solemn latch
main oak
#

Would you like the full code?

solemn latch
#

yeah please

main oak
#
const {
    SlashCommandBuilder
  } = require('@discordjs/builders');

  module.exports = {
    data: new SlashCommandBuilder()
      .setName('embed')
      .setDescription('embed a message')
      .addStringOption(option =>
        option.setName('message')
            .setDescription('The input to message back in a embed')
            .setRequired(true)),

      async execute(interaction, client) {
      const embed = new client.discord.MessageEmbed()
        .setColor('6d6ee8')
        .setDescription(interaction.options.getString('message'))
        .setFooter(client.config.footerText, client.user.avatarURL())
        .setTimestamp();
      await interaction.reply({
        embeds: [embed]
      });
    }, 
  };

solemn latch
#

strange

#

did you fill in the message option when you ran the command?

earnest phoenix
real rose
#

setRequired is true so it should require it regardless mmmm

main oak
#

yea///

solemn latch
#

๐Ÿ‘€

main oak
#

Should i try kicking the bot to add it back?

solemn latch
real rose
#

Oh I forgot that's a thing !

solemn latch
#

or are you just typing a message after it

main oak
#

yes im getting that

#

I kicked the bot and re-added it and deleted the command and re-added it and re-deployed it then it worked

solemn latch
#

ah

#

probably just didnt update right

main oak
#

Must not of, Thanks!

faint prism
quartz kindle
#

the ideal setup is as many processes as cpu cores until you start getting issues

#

for example if you have 100 shards and 4 cores, it would be 4 processes of 25 shards each

#

then you need to monitor the processes to see if they are managing

#

if you start seeing delays and lag in the event loop, then its time to add more processes

gritty bolt
#

anyone know why vercel is pushing commits just fine to it's default domain but not to my custom domain?

faint prism
quartz kindle
#

well im not sure what would be the best approach in a language that supports true threading

#

the advantages of async vs threads is that its easier to setup and consumes less resources (less memory management and no cpu context switching)

#

the advantage of threads is that they offer true concurrency

#

however network operations such as websockets dont really benefit that much from true concurrency

faint prism
#

Yeah, typically when you want parallel operations, or any sort of background work, we offloaded onto It's own background task (tasks are wrappers around threads, doesn't guarantee every task has its own thread)

#

At least in C sharp. I don't think I've ever seen The need for multiple instances of an application. It handles it pretty well from a single process from what I've seen

quartz kindle
#

idk how c# does it either, but from the docs im assuming System.Threading.Tasks uses async behind the scenes

arctic solar
#

hey

#

i'm having trouble

#

downloading psutil

slender thistle
#

That's unfortunate

#

What have you tried so far?

arctic solar
#

eveerything

#

let me see

#

by using visual studio

arctic solar
#

it is not happening

earnest phoenix
#

Install the wheel package by running pip install wheel and then try installing psutil again

earnest phoenix
#

Show the whole error

arctic solar
#

k

#

there's more

earnest phoenix
#

Show the last part of the error

arctic solar
#

k

earnest phoenix
#

You need to have the Python headers installed, run apt install python-dev -y to install it and then try installing psutil again

#

Are you on Windows?

arctic solar
#

yea

earnest phoenix
arctic solar
sly sierra
#

what

vocal elk
#

Hello, I'm a beginner learning pycord and I did a simple command

#

It gives me an error but I couldn't find the cause

#
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='.', intents=discord.Intents.all())

@bot.listen()
async def on_ready():
  print("Bot has logged in")

@bot.command()
async def serverinfo(ctx: commands.Context):
    embed = discord.Embed(title="Server info", description=f"Hello, this server is owned by kratoz",                              color=discord.Colour.random())
await ctx.send(embed=embed)

bot.run('token')โ€Š
#

It says

#

Syntax error: invalid character in indentifie with an upper arrow marking my token

#

How do I fix this

#

Ohhh

#

Alright

#

But have you found any fix for the error

slender thistle
#

Why is await ctx.send outside of the function

slender thistle
#

Is it indented?

vocal elk
#

No

#

I guess that is what the problem is

slender thistle
#

Then it's not inside of the function

#

Give it a try

vocal elk
#

So I have to leave a space before ctx. Send?

slender thistle
#

As many as you use for indents in other parts of your code

vocal elk
#

If possible could you please correct the code, I'm in mobile so I don't know whether the indentation is right

slender thistle
#

Can you send the full stacktrace

vocal elk
#

This

#

Please ping me when you reply

slender thistle
#

^

vocal elk
#

Oh, thank you so much for the reply.

royal pawn
#

How to make giveaway time in <t:{}:R> format using discord.py?

#
@bot.command()
@commands.has_permissions(administrator=True)
async def gcreate(ctx):
    giveaway_questions = ['Which channel will I host the giveaway in?', 'What is the prize?', 'How long should the giveaway run for (in seconds)?\n**Note:** 1hr = 3600s | 1day = 86,400s | 1week = 604,800s',]
    giveaway_answers = []

    def check(m):
        return m.author == ctx.author and m.channel == ctx.channel

    for question in giveaway_questions:
        await ctx.send(question)
        try:
            message = await bot.wait_for('message', timeout= 30.0, check= check)
        except asyncio.TimeoutError:
            await ctx.send('You didn\'t answer in time.  Please try again and be sure to send your answer within 30 seconds of the question.')
            return
        else:
            giveaway_answers.append(message.content)

    try:
        c_id = int(giveaway_answers[0][2:-1])
    except:
        await ctx.send(f'You failed to mention the channel correctly.  Please do it like this: {ctx.channel.mention}')
        return

    channel = bot.get_channel(c_id)
    prize = str(giveaway_answers[1])
    time = int(giveaway_answers[2])

    await ctx.send(f'The giveaway for {prize} will begin shortly.\nPlease direct your attention to {channel.mention}, this giveaway will end in {time} seconds.')

    give = discord.Embed(title=f'{prize}', description=f'React with ๐ŸŽ‰ to enter!\n Ends: {round(time/60/60/24)} Days!\nHosted by: {ctx.author.mention}', color = 0x37b2cb, timestamp=datetime.datetime.utcnow())
    give.set_footer(text = f'Winners: 1 | Hosted at')
    my_message = await channel.send(f":tada: **GIVEAWAY** :tada:", embed = give)```
#

Please help

#

Library: Python

slender thistle
#

The {} stands for epoch timestamp in UTC

#

I'm not sure I understand the full question here though

earnest phoenix
#

Use time.time(), cast it to int, finally add up the time input from the user

slender thistle
#

datetime > 3HC_sunglasses

earnest phoenix
#

Kinda overkill to me kekw

slender thistle
#

I call it balanced effort of productivity and uselessness

earnest phoenix
timber fractal
#

how do i fix this error? DiscordAPIError: Invalid Form Body embeds[0].image.url: Scheme "welcome-image.png" is not supported. Scheme must be one of ('http', 'https'). code ```js
const attachment = new MessageAttachment(canvas.toBuffer(), 'welcome-image.png');

const embed = new Discord.MessageEmbed()
.setAuthor(`Welcome to the server, ${member.tag}`, member.displayAvatarURL())
.setThumbnail(`https://cdn.discordapp.com/icons/809479699663290380/030d1709205bb369c8162bdcddfaeba8.png?size=4096`)
.setFooter(`${member.guild.name} | store.runecraft.eu | play.runecraft.eu`, member.guild.iconURL())
.setTimestamp()
.setDescription(`Please read the [#809479700497694741](/guild/264445053596991498/channel/809479700497694741/) and <#> yourself! Have a great time in our server!`)
.setImage(attachment.name)```
#

what?

#

why would that make sense

cobalt junco
gentle condor
#

how do i disable all buttons when a button is clicked in nextcord?

#

any idea

#

like

#
  
@nextcord.ui.button(label = "Yo",style = nextcord.ButtonStyle.gray)
  async def YoYo(self,button:nextcord.ui.Button,interaction:nextcord.Interaction):

      em = nextcord.Embed(title = "Heya",color = nextcord.Colour.random())

      await interaction.response.edit_message(embed = em)
      self.value = True
  
  @nextcord.ui.button(label = "End",style = nextcord.ButtonStyle.red)
  async def End(self,button:nextcord.ui.Button,interaction:nextcord.Interaction):

#

this is my code

wooden ember
tardy hornet
#

in one server that my bot is in it shows it with out the emojis

#

any idea?

#

it got admin perms in both

#

?

earnest phoenix
tardy hornet
earnest phoenix
#

Thats weird

zenith knoll
earnest phoenix
#

nvm it works now

simple stump
#

I'm trying to add options to slash commands, but when doing so I receive an error. The slash command appears normally, but the sub commands don't work for some reason.
Code:

    if (interaction.commandName === 'strike') {
      if (interaction.options.getSubcommand() === 'user') {
              const user = interaction.options.getUser('target');

              if (user) {
                  await interaction.reply(`Username: ${user.username}\nID: ${user.id}`);
              } else {
                  await interaction.reply(`Your username: ${interaction.user.username}\nYour ID: ${interaction.user.id}`);
              }
      }
    }

(line 306 is if (interaction.options.getSubcommand()...)
Registering the Slash Command:

... new SlashCommandBuilder().setName('strike').setDescription('Strikes an user.').addUserOption(option => option.setName('target').setDescription('Select an user')),

Error: https://sourceb.in/lEwPB2WEOY

wheat mesa
#

You didnโ€™t specify a subcommand

#

The error tells you exactly whatโ€™s wrong lol

#

Youโ€™re trying to access options, not subcommands

simple stump
#

mb i just fixed that

#

i forgot to add a subcommand

plain knot
#

I can't add a bot to the server

spark flint
plain knot
#

My

spark flint
#

what issues do you face

plain knot
#

I am writing that I cannot attach the bot to the server and I should contact this server

spark flint
#

Hmm

#

Which bot

plain knot
#

Ship It

spark flint
#

Could you send a link to it?

plain knot
#

I can not

opaque acorn
#

first of all, merry christmas

#

and second

royal herald
opaque acorn
#

i have a problem

rare hazel
#

yes yes you too

sudden geyser
#

9 hours left for us edt peeps

opaque acorn
#
Cannot read properties of undefined (reading 'send')
at DisTube.<anonymous> (/app/index.ts:66:65)
    at DisTube.emit (node:events:390:28)
    at DisTube.playVoiceChannel (/rbd/pnpm-volume/b454ff45-fa92-45a8-97d4-4cad670ab5b6/node_modules/distube/dist/DisTube.js:203:34)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async DisTube.play (/rbd/pnpm-volume/b454ff45-fa92-45a8-97d4-4cad670ab5b6/node_modules/distube/dist/DisTube.js:119:9)```
rare hazel
#

idk

#

im not a coder

rare hazel
#

i use my friends code

royal herald
rare hazel
#

for bots

#

api

#

whatever

rare hazel
#

idk

opaque acorn
spark flint
opaque acorn
#

wait

spark flint
#
royal herald
opaque acorn
#
.on("playSong", (queue, song) => queue.textChannel.send(
        `${client.emotes.play} | Reproduciendo \`${song.name}\` - \`${song.formattedDuration}\`\nPedido por: ${song.user}\n${status(queue)}`
    ).then(setTimeout((message) => message.delete(1), 15000)))
#

this is the code

opaque acorn
royal herald
#

can bot see that channel*

opaque acorn
#

It should be like that

royal herald
#

weird

opaque acorn
#

can it be because of the .then?

sudden geyser
#

The .then is weird.

#

You're passing the value of calling setTimeout

#

But you'd usually pass a function that calls setTimeout

opaque acorn
#

wait

sudden geyser
#

I think Discord.js can handle the timeout for you as well

#

oh it doesn't seem like it

#

maybe it was deleted

opaque acorn
sudden geyser
#

yeah

opaque acorn
#

i have discord v12.5.3

earnest phoenix
#

can i do something like this?

Object.values(object.family === "Obojectto")

object: ```js
const object = {
"heelo": { name: "Heelo", family: "Obojectto", lvl: "11" },
"hello": { name: "Hello", family: "Target", lvl: "none" },
"heello": { name: "Heello", family: "Obojectto", lvl: "21" }

sudden geyser
#

Then you could use:

.then((m) => m.delete({ timeout: 15000 }));

And Discord.js will handle the timeout for you.

opaque acorn
#

wait ill try

sudden geyser
opaque acorn
#

nothing

#

maybe isnt the .then

sudden geyser
#

Well the error is complaining about .send, and that precedes queue.textChannel, so you may want to check the value of queue for what .textChannel should be.

#

Right now, queue.textChannel is returning undefined

opaque acorn
opaque acorn
#

and if i change it to queue.channel.send?

sudden geyser
#

You won't get anything out of that

#

Since there's no property for channel

#

Though in the docs textChannel is marked as optional, so that may be why it's undefined

opaque acorn
sudden geyser
#

That's interesting.

#

I don't use DisTube so I'm not able to answer well

opaque acorn
#

it works fine again wtf

#

xd

#

well anyway thanks for the help|| @sudden geyser ||

old dune
#

intents_use_case_supplemental_material_description Trying to verify my bot and I've got this error. I assumed all I needed to do was increase my reasoning for wanting the members intent was increasing the word count to at least 100 words and so I did. I increased it by 120 total but I still get this error.

rustic nova
#

thats speaking about length, aka characters

#

check your text with a word/character counter

old dune
#

yeah I did

#

I typed it out in a word counter and it's 120 words in total and 610 characters

rustic nova
old dune
#

Ok it worked, for whatever reason it also wanted an essay on the part where it only asked for a screenshot.

slender wagon
#

i store discord users avatar on a database for my website, the issue is when they change their pfp the db doesn't update it obviously

#

what would be the best way to update their pfp

#

put a check on userlogin?

#

i wouldn't want it to slowdown authentication

earnest phoenix
#

can I remake this in a few lines? ```js
if(chss.rarity === "Common"){
chr = [
"nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","chr","nada","nada"
];
} else if(chss.rarity === "Rare"){
chr = [
"nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","chr","nada","nada","nada","nada","nada"
];
} else if(chss.rarity === "Epic"){
chr = [
"nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","chr","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada"
];
} else if(chss.rarity === "Legendary" || chss.rarity === "Champion"){
chr = ["nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","chr","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada","nada"];
}

#

What the f*ck is it

#

the droprate of new character appearing in chests

#

I choose "chr" randomly

#

and somehow that makes it harder to appear

spark flint
#

or uh

#

just do random choice

#

random number out of X, if number = X then give it