#development

1 messages · Page 1916 of 1

boreal iron
#

But that’s pretty much more complicated than using SQLite

#

It’s actually a good idea to play around with a database and collect some experience if you already got the time for testing things anyways

lethal trout
lethal trout
lyric mountain
#

Actually, it's probably even less precise than unix nvm, it's definitely unix

#

Check the input time unit

#

Ye, totally unix

woeful pike
#

camelCase

earnest phoenix
#

camelCase

#

camelCase

hybrid cargo
#

🐪

eternal furnace
#

🐫

slender thistle
#

Thanks for not using English as your package description

#

cc @dense flame ads

dense flame
#

@earnest phoenix no ads please, thx.

earnest phoenix
surreal sage
#
client.on("guildMemberAdd", member => {
    console.log('member detected')
    member.guild.channels.cache.get("906309395439304715").send(new MessageEmbed(
        {
            title: `Welcome <@!${member.id}> to the server!`,
            description: "Make sure to check [#906308769368125543](/guild/264445053596991498/channel/906308769368125543/) and verify at [#906308242630639636](/guild/264445053596991498/channel/906308242630639636/)",
            footer: {
                iconURL: "https://cdn.discordapp.com/attachments/906456481589768192/906456916723638282/Cloud_Zone_Blurple.png",
                text: "CLOUD ZONE"
            },
            color: "#43B581"
        }
    ))
})```

There is a empty message error....
#

ah

#

I'm used to 12.5.3

#

¯_(ツ)_/¯

#

Hmm no

#

Still the error

#

thanks

#

Works

thorny flume
surreal sage
#

How do you mention a user in a title....

#

uh

spark flint
#

Poor @ user

surreal sage
#

base string

#

lemme try without

spark flint
#

Try member.mention

#

Without all of the <@ stuff

surreal sage
#

does that even exist

spark flint
#

Yep

surreal sage
#

cap

#

yea

spark flint
#

Then user doesn’t exist ig

surreal sage
#

?

#

is author 1?

#

nvm

#

ill just bold

#

resolved 👍

earnest phoenix
#

@surreal sage @carmine topaz

spark flint
surreal sage
#

bruh

#

@earnest phoenix

boreal iron
#

As well as the footer

#

The description can contain a mention as well as fields

surreal sage
#

:/

eternal osprey
#

for fuck sakes

#

what is this mockery

boreal iron
#

As long as it’s not a virus.exe you shouldn’t worry

eternal osprey
#

i reinsalled it and it still ha all my plugins etc

#

i supposedly closed it while it was updating

surreal sage
#

a category counts as a channel right

#

I want to cache.get a category

#

does a category fall under guild.channels?

#

extends guildchannel

#

ight it does

eternal osprey
#
 const embed = new Discord.MessageEmbed()
  embed.setColor("RANDOM")
  embed.setTimestamp()
  embed.setFooter("Your KPOP dealer!")
  const keys1 = Object.keys(carddatabase)
  const prop1 = keys1[Math.floor(Math.random() * keys1.length)]
  const keys2 = Object.keys(carddatabase)
  const prop2 = keys2[Math.floor(Math.random() * keys2.length)]
  const keys3 = Object.keys(carddatabase)
  const prop3 = keys3[Math.floor(Math.random() * keys3.length)]
embed.setDescription(`${message.author} is dropping cards! Lets bake it for 20 minutes!\n\nAfter 20 minutes you can claim ONE card by clicking the corresponding emoji:\n`)
let emoji1 = await message.channel.send(embed, {files: ["./cards/"+prop1, "./cards/"+prop2, "./cards/"+prop3]}```why is this sending me [object, object] and then the 3 images?
#

I am trying to send the embed with the 3 images inside the settdescripttion

#

nope doesn't work

#

I am on v12

surreal sage
#

how to get the id of a channel that just was created

#

channelCreateFunction.then()?

#

The vsc thing that shows the properties ect doesn't work properly

#

Can't see the shit

stiff lynx
#

I want to fix my ban command where if u have the permission to ban, u can ban also members with a role higher than your.

How can I check the role position?

surreal sage
#

role.position

surreal sage
stiff lynx
#

but I still don't know how to fix this command, lol.

I should put the roles inside an array and check?

surreal sage
#

Get the role of the member you are going to ban

#

.position that and calculate if its higher then the person that bans the member role

#

btw member.roles.highest.position

eternal osprey
#

How would i send multiple images inside an embed?

#

Santiago your fuckin mom

pearl trail
eternal osprey
#

@rustic nova

rustic nova
#

Yup

eternal osprey
pearl trail
#

yes

eternal osprey
#

how is this done then?

#

it's not an embed.. but still trying to figure out how it's done.

pearl trail
#

that's generated image, combining 3 images into 1 image

eternal osprey
#

AHA! Can probably do the same using jimp

surreal sage
#

How can you delete the pin message using the latest discord.js?

#

I'll find a way, don't respond yet ty ❤️

eternal osprey
#

how do i actually use jimp to put 3 images next to each other?

#

I tried finding their docss but they have no articles about this subject.

woeful pike
#

are you searching for "jimp combine images" or "how to make a gacha game discord bot with jimp"

eternal osprey
#

they are all about compositions and adding layers

woeful pike
#

sounds about right

#

that's the thing you're looking for

eternal osprey
#

Yeah it doesn't really do the job for me

#

it literrally composites 2 image layers onto each other

#

but i want it to be next to each other

woeful pike
#

you take one base image and layer 3 other images on top of each other with a specific offset

#

layer the small squares on top of the red square

#

then figure out the math to have the final thing centered

eternal osprey
#

yeah i could also just make it easier by using a join-images package

woeful pike
#

god forbid you try to solve a problem one time

surreal sage
#

How do you make a interaction button disabled after it has been pressed?

quartz kindle
#

respond with an edit response and give it a button of type disabled

surreal sage
#

Could you give a snippet?

#

Cause I can't find the shit in docs

#

nvm i got it

#

int component

opaque acorn
#
    ^
TypeError: SpotifyPlugin is not a constructor
#

?

#
client.distube = new DisTube.default(client, {
  emitNewSongOnly: true,
  plugins: [
    new SpotifyPlugin({
      parallel: true,
      emitEventsAfterFetching: false,
      api: {
        clientId: "x",
        clientSecret: "x"
      }
    })
  ]
});
stiff lynx
#

if (target.permissions.has("ADMINISTRATOR"))

I don't get why this doesnt work

surreal sage
#

Component.set* doesn't seem to give a effect.
Any solution?

stiff lynx
opaque acorn
stiff lynx
#

13.3.1

earnest phoenix
#

Is it necessary that { should be put on a new line in C#?

opaque acorn
stiff lynx
opaque acorn
#

ok

split hazel
#

sweaty c# devs will probably make comments if you put it on the same line

earnest phoenix
#

I'm a sweaty js dev

split hazel
#

same

#

though i dont code much nowadays and if i do its something new

earnest phoenix
#

if else if else if else if else if in a programming tutorial

split hazel
#

is it really a terrible idea

#

sometimes theres no other choice

woeful pike
#

you ever go back to a codebase after a couple months and have no idea wtf is going on

woeful pike
#

I wrote so much code and I have no idea what any of it does

solemn latch
#

I think he meant the other way around

earnest phoenix
#

it only takes me a couple minutes to forget wtf my code does

#

might be worse in top.gg's case

woeful pike
#

just my own personal mess

split hazel
#

its fine not to admit

eternal osprey
#

embed.setImage('./cards/out.png')```
#

is this even possible?

quartz kindle
woeful pike
#

I have a ton of comments and I still don't know what I'm looking at

#

though it's slowly coming back to me

quartz kindle
#

xD

woeful pike
#

yes very helpful comments

small tangle
#

at least you know why you cant test it

quartz kindle
#

xD

small tangle
#

hello other Tim doggowave

quartz kindle
#

hullo

modest maple
#

also interesting borrow

woeful pike
#

what's wrong with it?

lament rock
#

can't you manually expire a token?

woeful pike
#

not my website

lament rock
#

Fair

#

docing code is helpful. I should probably start to do that

modest maple
#

and the styling Is just a pet peeve, if you stack the attributes like that then I tend to prefer doing


let foo = self
  .creds
  .clone()
  .try_read()
  .map(...);

return Ok(foo)
woeful pike
#

oh I probably wasn't borrowing it at first and forgot to remove it when I changed the method signature

#

literally anything is fine

woeful pike
#

1

vivid fulcrum
#

what do you mean by that

woeful pike
#

the data is persisted directly to the filesystem so you can do as many reads as you want but only 1 concurrent write

#

sqlite is usually enough for most people's needs

#

sqlite libraries handle queueing writes for you

#

if you're going to be on a single process sqlite is fine. It's easy to migrate the data on it to other relational dbs if you need to switch things up later

#

currency bots lol

lyric mountain
#

What lang?

#

Js then

#

Also, when using sqlite don't multithread write ops

#

You can have multiple parallel processes for read operations

#

But keep write operations synchronized

#

The issue with sqlite and pretty much any other file-based database is that only 1 write operation can be happening at my single time

woeful pike
#

pretty sure the node sqlite lib should be handing write queues for you

lyric mountain
#

There is

woeful pike
#

unless your bot is sharded

lyric mountain
#

Don't recall the name tho

#

Are u using a writing queue?

#

Actually, show the code where that error happened

woeful pike
#

@modest maple do you do CI/CD in github actions? how do I setup rust builds so they don't take 10 million years lol

modest maple
woeful pike
#

that's a lot 😦

modest maple
#

but just make sure you're not building on 1.56

#

thats not

lyric mountain
#

Are u using transactions?

woeful pike
#

oh no 1.56? PepeHands what

modest maple
#

trust me 😓

#

1.56 has some pretty bad compile time issues

woeful pike
#

woeisme but my epic captures

lyric mountain
#

Idk how to explain what is a transaction

modest maple
#

if you want fast build times then erm, Ig you gotta setup a custom CI server

lyric mountain
#

But like, if you forget to close it after writing it might hold the database hostage

modest maple
#

I compile in release mode on my CI because the unittesting is too long otherwise

woeful pike
modest maple
#

search engine testing and indexing test 😉

woeful pike
#

my dockerfile builds fail cuz sqlx can't connect to the db I'm so sad

modest maple
#
name: Rust

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Build main
      run: cargo build --verbose
    - name: Run main tests
      run: cargo test --release --verbose -- --test-threads 2   ```
#

le simple ci

woeful pike
#

I also need to build a dockerfile though

modest maple
#

I mean yeah, for the sqlx connect issue at build time is a lol

#

just done use compile time checks in build ig WICKED

#
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
  schedule:
    - cron: '35 8 * * *'
  push:
    branches: [ master ]
    # Publish semver tags as releases.
    tags: [ '*.*.*' ]
  pull_request:
    branches: [ master ]

env:
  # Use docker.io for Docker Hub if empty
  REGISTRY: docker.io
  # github.repository as <account>/<repo>
  IMAGE_NAME: chillfish8/lnx


jobs:
  build:

    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      # Login against a Docker registry except on PR
      # https://github.com/docker/login-action
      - name: Log into registry ${{ env.REGISTRY }}
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v1.9.0
        with:
          username: ${{secrets.DOCKER_USERNAME}}
          password: ${{secrets.DOCKER_PASSWORD}}

      # Extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v2
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

      # Build and push Docker image with Buildx (don't push on PR)
      # https://github.com/docker/build-push-action
      - name: Build and push Docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
``` my docker ci is very basic
woeful pike
#

sqlx prepaer seems like it's working

quartz kindle
#

how much concurrency are you talking about? sqlite can easily make hundreds of writes per second, if not thousands

#

use WAL mode and set synchronous=off, also use better-sqlite3 if node.js, not sqlite or sqlite3

lyric mountain
#

That's why I thought abt open transactions

#

Sqlite is hard to hit two writes at the same time

modest maple
#

I mean its impossible

#

outside of a new connection per write

#

but that still has a lock

#

also sqlite transactions are per connection so it can be a lil iffy

quartz kindle
#

if your sqlite is still being overloaded, you can also implement eventual consistency

#

what i like about sqlite is that its easy to configure it and scale it your own way

lyric mountain
#

I used to use sqlite fully in memory as a caching db

#

The I'd unload it onto the main db each hour or before restart

#

Shit is so small it doesn't really matter how much data u put in it

quartz kindle
#

ye

#

and because its in-process and uses mmaps and shit, its way faster than any thing that uses sockets or tcp

#

like redis

lyric mountain
#

Such that most dbs use sqlite internally somehow

#

Be it for settings or plain caching

wooden ember
#

why doesn't

const Channel = client.channels.cache.get("1234567890");
``` work anymore?
boreal iron
#

The syntax is about right

#

Check your channel ID then

wooden ember
#

i mean its been working in my bots for the past year and a half

quartz kindle
#

nothing changed about that

#

it still works

wooden ember
#

and now it returns undefined

quartz kindle
#

if you have an issue, its likely because of something else

#

not because of that

boreal iron
#

Check your channel ID then

wooden ember
#

i have not altered the id for a year

#

the channel and id are ok

quartz kindle
#

is the id hardcoded?

wooden ember
#

on one it is but the other its just msg.channel.id

#

cuz its on a "say" command

quartz kindle
#

and which one is not working?

wooden ember
#

both

quartz kindle
#

then youre doing something wrong somewhere

#

show code

wooden ember
#

one sec

quartz kindle
#

also which version of djs are you using

wooden ember
#
    run: async function(client, message, args){

    if( swearWords.some(word => message.content.toLowerCase().includes(word)) ) {
        message.reply("sorry no swears").catch(error => {console.log(chalk.red('[ERROR]') + " COULD NOT SEND MESSAGE " + error); });
    }
    else{
           let msg = message.content.split(" ");
        message.delete().catch(error => {console.log(chalk.red('[ERROR]') + " COULD NOT DELETE MESSAGE " + error); });
            message.channel.send(message.content.slice(6)).catch(error => {console.log(chalk.red('[ERROR]') + " COULD NOT SEND MESSAGE " + error); });
    }    
  }
``` this code has not been altered in a year
wooden ember
quartz kindle
wooden ember
#

channel id is undefined

boreal iron
#

Am I blind? I don’t see you getting the channel ID anywhere

quartz kindle
#

there is no channel id in that code?

boreal iron
#

it’s not me then phew

wooden ember
#

wait im very dumb

#

wrong bot

quartz kindle
#

Lol

wooden ember
#

one sec

#

my files aren't that organised

#
if (command === "say") {
        const Channel = bot.channels.cache.get("1234567890");
        if (!Channel) return console.error("Couldn't find the channel.");
              Channel.send(message.content.slice(9)).catch(e => console.log(chalk.red('[ERROR]')+` could not send message:  ${e}`));
    }
``` this is the one
boreal iron
#

You sure your var is bot in this case not client?

lyric mountain
#

Dat casing tho

wooden ember
#

this is from a year ago

lean sinew
#

So I'm trying to make a modmail system but for some reason the channel collector is collecting the same messsage. Any help would be great!

const discord = require("discord.js")
module.exports = {
    name: 'modmail',
    aliases: ['mail'],
    execute: async (client, message, args) => {
        const mes = await message.channel.send("I have sent you a dm.")
    const config = require("/home/runner/Bot2/Handlers/config.json")
        message.author.send("Start typing to chat with the moderators.")
            .then(async (msg) => {
                const filter = m => !m.author.bot;
                const collector = await msg.channel.createMessageCollector({
                    filter,
                });
                const channel = await message.guild.channels.create(`${message.author.username}s-modmail`, {
                    permissionOverwrites: [{
                        id: config.mainrole,
                        deny: ["VIEW_CHANNEL"],
                    }, ],
                })
                collector.on("collect", m => {
                    channel.send(`${m.author.tag}: ${m.content}`)
                    const filter = mm => !mm.author.bot;
                    const channelcollect = channel.createMessageCollector({
                        filter,
                        max: 1,
                    });
                    if (m.content == "?mmclose") {
                        m.reply("Modmail will be closing.")
                        collector.stop()
                    }
                    channelcollect.on("collect", async mm => {
                        if (mm.content == "?mmclose") {
                            return channel.delete()
                        }
                        m.author.send(`${mm.author.tag}: ${mm.content}`)
                        console.log(mm.content)
                    })
                })

            })
         .catch(error => {
            mes.delete()
            message.reply("Something went wrong. Make sure your dms are open. If this happens if when your dms are on then dm !Kweeper#8053")
        })
    }
}

I don't know why this happen because I've set the max messages to 1 and the dm collector max to 1 but it breaks.

boreal iron
#

Oh nooo 4s to scroll up again oldEyes

wooden ember
#

lol

quartz kindle
#

where is the channel from?

lyric mountain
#

Oh how I love to read code in mobile

lyric mountain
#

Imagine if someone created a site for showing code to others...
/s

lean sinew
wooden ember
boreal iron
lyric mountain
#

Skill issue

wooden ember
#

lol

quartz kindle
lean sinew
#

oh lmao thanks i'll try it

quartz kindle
#

console.log that guild's channels and check

boreal iron
#

Somebody may deleted it and added a new one

wooden ember
#

its there i just updated it incase it changed or somthing but nope still the same error

lean sinew
quartz kindle
lean sinew
#

aight thanks

quartz kindle
#

which library are you using?

#

use better-sqlite3

#

read the readme

quartz kindle
#

no

wooden ember
#

only found out about this error whilst working on another bot that posts individual lines from a txt file to a sertain channel and it uses the same channel id thing

#

and yes all the ids are correct for both bots

#

the other bots code is

  for await (const line of rl) {
    const Channel = client.channels.cache.get("760176465513414697");
    const link = ["https://"];
    if (!link.some(word => line.toLowerCase().includes(word)))return
    console.log(`Line from file: ${line}`);
    sleep(5000)
  }
lyric mountain
#

If u use many repeated operations it might be handy to make controller classes (or files whatever)

#

Like, instead of having 30 "SELECT * FROM user" just make a file and make a function that does it

quartz kindle
lyric mountain
#

Less places to change, easier maintenence

quartz kindle
#

console.log(client.guilds.cache.get(guild id here).channels.cache)

lyric mountain
#

Good, that's a good habit

wooden ember
lyric mountain
#

I cringe when I see 6764649 repeated sql queries all around the codebase

quartz kindle
#

just do it

#

put the console.log code just before the .channels.get() code

wooden ember
#

thats the error i get

quartz kindle
#

...

#

thats a completely different error

#

that has nothing to do with channels

#

or the problem you were describing

#

that error means client is undefined

wooden ember
#

bruh

boreal iron
wooden ember
lyric mountain
#

Aaaaand we came all the way around to the start

quartz kindle
wooden ember
#

or else the other parts of the bot wouldnt work

quartz kindle
#

show junk.js

wooden ember
quartz kindle
#

ok so that error means the guild doesnt exist

wooden ember
#

i put the consol log in the other place two but it didnt work their iether

quartz kindle
#

if the guild doesnt exist, neither do all its channels

wooden ember
#

but it does

quartz kindle
#

are you using intents?

wooden ember
#

whats that?

#

thought those where for when you wanted to see when member joined and left

quartz kindle
#

do you have new Discord.Client({ ws: { intents: ... } })

wooden ember
#

cuz thats privalaged or somthing

quartz kindle
#

?

boreal iron
#

He said he's on v12 something

#

So no

#

Probably not

wooden ember
#

thats all i have

quartz kindle
#

console.log client.guilds.cache.size

#

on your client.on(ready)

lyric mountain
#

Also 1yo code, unmodified since then

#

He probably missed the intent stuff

wooden ember
#

i tryed using intents ages ago when the guild.user.add/remove got broken but it never worked so i just commented that out and lived with some stuff not working

#

i mean i have another bot that doesn't have intents but it can list the servers and channels in those servers just fine

lyric mountain
#

If u didn't appear here this year you'd probably suffer when your messages suddenly stopped having content

wooden ember
#

?

#

i mean on of my other projects has a command that just returns "cannot send an empty message now when i cwant it to repeat somthing

lyric mountain
#

Message content will be a privileged intent

#

It is already

#

But they're giving a grace period

wooden ember
#

wait what

lyric mountain
#

After it ends, all bots without it will receive only blank messages

wooden ember
#

why

lyric mountain
#

Except its own messages or those which ping the bot

wooden ember
#

thats literally gonna break everything

lyric mountain
#

It is

wooden ember
#

so why do it

lyric mountain
#

Are u still asking why for discord choices?

wooden ember
#

lol

lyric mountain
#

I stopped when they rebranded the site

wooden ember
#

ah so im not the only one that detests the rebrand

lyric mountain
#

Another why moment

wooden ember
#

i mean its not that bad but the logo being a circle and the new colours are what really annoy me

#

the shade of blue hearts m,y eyes

#

and the green doesnt match

woeful pike
#

omg 😭 after 2 years of building 600mb nodejs dockerfiles I finally have a normal size image

lament rock
wooden ember
#

and you would have thought they would have fixed the fact stuff doesn't match up

#

and the fact that when using a 4:3 ratio monitor nothign is a circle anymore

lyric mountain
#

That's css issue probably

#

Maybe ur browser doesn't support some styling

lament rock
#

looks fine on mine as well

wooden ember
lyric mountain
#

Me 2

wooden ember
#

infact i think the circl issure is just my monitor just in the screen shot they look alright

simple stump
#

What does this:

let user4Sucks = client.users.fetch(player4).then((user4) => {
});

Return? I am trying to use user4.voice.setChannel(<some_channel_id>), but user4.voice returns undefined.

lyric mountain
#

Var

lament rock
#

use await

lyric mountain
#

That too

lament rock
#

fetch returns a Promise<User>

daring geyser
#

Guys can you help me? My bot is crashed

2021-11-06T15:54:11.346531+00:00 app[main.1]: /app/node_modules/discord.js/src/client/ClientDataManager.js:81
2021-11-06T15:54:11.346549+00:00 app[main.1]:         guild.channels.set(channel.id, channel);
2021-11-06T15:54:11.346550+00:00 app[main.1]:                                    ^
2021-11-06T15:54:11.346551+00:00 app[main.1]: 
2021-11-06T15:54:11.346551+00:00 app[main.1]: TypeError: Cannot read property 'id' of undefined
boreal iron
# lyric mountain Maybe ur browser doesn't support some styling

It's not really about supporting things or not, more like different browsers have default settings for various elements.
Like Apple handles tables, font-sizes, p and other elements differently than other browsers do, especially talking about the default padding/margin.

simple stump
lyric mountain
lament rock
#

oh. I may be stupid

boreal iron
#

It's not breaking but handling the elements differently

boreal iron
#

At least their default style

#

To fit into the Apple ecosystem

#

That's why you can disable most of their webkit pre-settings

wooden ember
#

also why am i getting friend requests from bot accounts that aren't even in server im in

lyric mountain
#

More people reported that very same dude here

#

Just deny

boreal iron
#

hmm me, too

#

Just ignore that shit, yeah

spark flint
#

they were scam links

wooden ember
#

ah

simple stump
#

I'm still having trouble moving users to a VC. Even when the bot is Admin and every single user is in a VC, user.voice returns undefined.

let user1 = client.users.fetch(player4).then(async (user) => {
  // Do stuff
  // Wait because moving user to a newly created VC
  setTimeout(async function () {
    if (!user.voice || user.voice === "undefined") {
      // This always happens
      console.log("Could not move players to the voice channel.");
      return;
    } else {
      await user.voice.setChannel(channel1ID);
    }
  }, 4000);
});
quartz kindle
#

user.voice is not a thing

simple stump
#

oops. edited

quartz kindle
#

also, you're trying to use user but you defined it as user1

simple stump
#

ah

#

mb. thx

quartz kindle
#

users dont have .voice

#

members do

simple stump
#

ohhh

#

that makes a lot of sense lol. thanks

boreal iron
#

if (!user.voice || user.voice === "undefined")
"undefined" is already covered in !user.voice

simple stump
#

oops ill fix that to

lyric mountain
#

And undefined isn't a string

boreal iron
#

Also

#

Fetch is a promise

#

await it

simple stump
#

aight

boreal iron
#

enough also(s)

lyric mountain
#

A l s o

simple stump
#

im calling that piece of code inside a function tho. how would i make that function async?

lyric mountain
#

Function() { can be expressed as () => {

simple stump
#
function someFunc(message, userId) {
  let userMember = client.users.fetch(userId).then(async (user) => {
  });
simple stump
lyric mountain
#

Unless you're using this (which for most js coders isn't even heard about), arrows are just fine to use everywhere

boreal iron
lyric mountain
#

Nobody uses arror

boreal iron
#

lol

lyric mountain
#

Not arror

jolly notch
#

not arror but arrow

boreal iron
#

adding profile notice for you: very weird guy

wooden ember
#

lol

lyric mountain
simple stump
#

Would this be the correct syntax?

const function someFunc = async (parameters) => {
  // do stuff
}
boreal iron
#

ewww

jolly notch
#

half of bot developers don't know how to code

lyric mountain
#

Change function to const ig

boreal iron
#

async function KahuwakabunkSuchs(param1)
{
// explode
}

lyric mountain
#

Found the c# coder

boreal iron
#

omg an h instead of a k

#

I'm done

simple stump
#

but im not that experienced with either langs lol

#

i came from html/css/php

lyric mountain
#

Java uses inline brackets

#

C# is newline brackets

simple stump
#

oh mb

#

okay ill fix that. thanks for the help

boreal iron
#

#trash-development

quartz kindle
#

lmao

wooden ember
lyric mountain
boreal iron
lyric mountain
#

Come to strict typing comrade, enjoy the detailed coding habit

#

public static void main ftw

quartz kindle
#

funny to see java getting flamed more than js

wooden ember
#

vood

lyric mountain
#

No need to try

boreal iron
#

At least that's true

lyric mountain
boreal iron
quartz kindle
#

xD

wooden ember
#

alyway how am i suposed to get a channel by an ID if the bot cant access guilds anymore

lyric mountain
#

It can, u just need the right intents

wooden ember
#

how do i get those?

lyric mountain
#

And refrain from using cache inside ready event

wooden ember
#

that was for debugging

lyric mountain
#

Since it's more likely than not to not be cached yet

wooden ember
#

indeed

#

i tested it in other places too befor that and it all had the same result

quartz kindle
#

did you do the test i told you to do?

#

console.log(client.guilds.cache.size)

#

in your ready event

#

thats important to figure out if the problem really is a missing intent, or if it just a broken guild

wooden ember
quartz kindle
#

2 guilds?

wooden ember
#

that is correct its only a testing bot account

quartz kindle
#

and one of those two guilds is the guild you are trying to access?

wooden ember
#

its in my test server and my mates server two

#

yeah

#

i have tryed multiple channels

#

all are unfindeable

quartz kindle
#

console.log(client.guilds.cache.get(guild id here))

#

if thats still undefined, do console.log(client.guilds.cache)

errant perch
#

do all servers my bot is in have to reauthorize in order to allow the bot to create slash commands in their server?

simple stump
#

Sorry I know I asked this recently but having this:

let getUserVarIdkWhatToNameThis = await client.users.fetch(player1).then(async (user) => {
  setTimeout(function () {
    var channelID = message.guild.channels.cache.find(c => c.name === "Game " + game + " Team 1").id;
    if (!user.voice) {
      // Couldn't move user
    } else {
      user.voice.setChannel(channelID);
    }
  }, 3000);
});

user.voice always returns undefined. If I use user.member.voice though, user.member returns undefined. How would I fix this?

quartz kindle
boreal iron
#

Oh you're using then(), my bad, not need to await it then

quartz kindle
#

discord did a mass migration last year and gave all existing servers the slash command scope to all bots

boreal iron
#

Didn't see that

errant perch
#

ok thanks

wooden ember
quartz kindle
wooden ember
#

the guild was found

simple stump
quartz kindle
wooden ember
#

yeah

simple stump
quartz kindle
#

i already told you users dont have voice

#

members do

boreal iron
#

Oh you're using then(), my bad, not need to await it then

simple stump
#

user.member returns undefined though

quartz kindle
#

because user.member also doesnt exist

#

users dont have members

#

membes have users

simple stump
#

ohh. to fix this would i just call the var itself (let someVar = await <stuff>)

quartz kindle
#

no

#

you need to stop using client.users.fetch()

#

as that returns a user object

#

and instead use guild.members.fetch()

wheat mesa
#

A Member object is associated with a guild, a User object has no association with a guild (Just saying)

quartz kindle
#

which returns a member object

simple stump
#

ah okay

#

thanks

wheat mesa
#

That’s why you can’t use User objects to perform methods related to guilds

simple stump
#

alr. thanks for the help

bright talon
#

hey all, when I restart my bot, I get a guildDelete event for 2 guilds. They have unknown attributes, but I have their ID's. They don't appear in my database of known guilds. Any way for me to understand why I'm getting this event?

wheat mesa
#

Could be unavailable guilds. Make sure to check if the guild is available before running any code in your guildDelete event

boreal iron
#

They can always be unavailable

wooden ember
#

when some one dms the bot does it count a guild? or just a channel

boreal iron
#

text channel

wooden ember
#

ah

boreal iron
#

guild is not present then, never

bright talon
#

if they're unavailable, why are they signaling an event?

#

(same 2 guilds on every restart)

quartz kindle
#

broken guilds

daring geyser
#
2021-11-06T16:38:13.698546+00:00 app[main.1]: > node server.js
2021-11-06T16:38:13.698546+00:00 app[main.1]: 
2021-11-06T16:38:16.691389+00:00 app[main.1]: /app/node_modules/discord.js/src/client/ClientDataManager.js:81
2021-11-06T16:38:16.691409+00:00 app[main.1]:         guild.channels.set(channel.id, channel);
2021-11-06T16:38:16.691410+00:00 app[main.1]:                                    ^
2021-11-06T16:38:16.691410+00:00 app[main.1]: 
2021-11-06T16:38:16.691410+00:00 app[main.1]: TypeError: Cannot read property 'id' of undefined
2021-11-06T16:38:16.691411+00:00 app[main.1]:     at ClientDataManager.newChannel (/app/node_modules/discord.js/src/client/ClientDataManager.js:81:36)
quartz kindle
#

i believe someone said they were soft-deleted guilds

#

guilds that were deleted but are still within a 30 day revert window

wooden ember
daring geyser
boreal iron
bright talon
#

ok thanks peeps

boreal iron
#

Obviously channel is undefined

quartz kindle
grim aspen
#

Pastebin*

boreal iron
wheat mesa
#

v11 🤨🤨🤨🤨🤨

wet fog
#

Alright so I want my bot to auto role when a member joins but I want the auto role to be set so it my case they have to run k autorole (the role) and it will set that servers auto role. Role to that role however I’m unsure on how to do this can anyone help

quartz kindle
grim aspen
#

V11?

#

That was discontinued a long time ago

quartz kindle
#

ClientDataManager.js doesnt exist since v12

wheat mesa
#

He’s a walking djs doc

wet fog
wheat mesa
#

I love it

wooden ember
#

from 3 years ago

grim aspen
#
quartz kindle
quartz kindle
#

because a LOT of things are different between v11 and v13

daring geyser
#

omg

quartz kindle
#

so be sure to read the v13 guides

wooden ember
#

also make sure you have node 14 or somthing installed too

wheat mesa
#

Node 16

wet fog
#

sudo n v13 @daring geyser

wheat mesa
#

16+

boreal iron
#

looks like you still store unnecessary things in your head

wet fog
#

Lmfao

wooden ember
#

im still on mode 12 lol

wheat mesa
#

For v13 you need node 16+

wooden ember
#

oof

wheat mesa
#

I was on node 14 until recently when I decided to finally upgrade

#

But I don’t use djs so that wasn’t really a problem for me

wooden ember
#

when i upgrade my server I'll ipdate node

wooden ember
#

planning to use debian cuz centos is eol

wheat mesa
#

Now I’ve just gotta make sure I don’t fuck up with any unhandled promise rejections KEKW

wooden ember
#

sad

lyric mountain
#

node was too lenient, errors must feel like errors

#

panic and despair is necessary to create solid progs

wheat mesa
#

Agreed

#

Requires a lot more testing on my end for updates now though

#

I got a 404 unknown message from discord and it crashed my bot

#

Lmao

wooden ember
#

you talking about when you get an error but the program doen't actually crash cuz that annoys me

#

i just have my bots running in a screen session

#

how am i suposed to knwo discord broke the api again if the bot just spamms the console

wheat mesa
#

That’s not true

daring geyser
#

What highlighting should I choose for this code in pastebin?

wheat mesa
#

That’s deprecated in higher node versions

modest maple
#

sip The language highlight

boreal iron
wheat mesa
#

Your program will crash if you fail to handle those errors in the future

wooden ember
daring geyser
#

js

boreal iron
#

Hastebin or whatever that shit called, may be better than pastebin

daring geyser
#

but its logs

wooden ember
#

so set it as js then

wooden ember
# daring geyser but its logs

thought we already established that the code wasnt working cuz you are using a package thats almost 4 years outdated

daring geyser
quartz kindle
daring geyser
#

okay

wheat mesa
#

For promises, should I be adding a .catch() on every single one in case it fails...? Seems counterintuitive to do that, so I’m probably wrong.

#

Yes let me just perfectly think of all possible cases while writing my bot

boreal iron
#

That unnecessary else on the return

quartz kindle
#

or a combination of both

#

for example ```js
let a = await x().catch(() => null);
if(!a) return;

daring geyser
quartz kindle
#

if you have native packages that need compiling, they have to be reinstalled

#

other than that, you should probably check the ones you use to see if they need updating as well

daring geyser
#

It's probably easier to create a new project.

quartz kindle
#

possibly yes

earnest phoenix
#

Is it good thing moduling everything?

wooden ember
#

how do i enable the message content intent on a bot?

earnest phoenix
#

Guild messages

wooden ember
#

i did the thing in the dev portal but i cant find the name for the intent

wooden ember
earnest phoenix
#
const client = new Discord.Client({
intents: [new Discord.Intents('32766')]
});

And bum you have all intents

wooden ember
#

yeah but i dont need all of themthough

earnest phoenix
wooden ember
#

so: ```js
const bot = new Discord.Client({ intents: ["GUILD_MESSAGES"] })

earnest phoenix
#

No

#

You cant reach guild messages without guilds

earnest phoenix
earnest phoenix
#

Your code line will seem more clear

jolly notch
earnest phoenix
#

Np

quartz kindle
#

in v13 they are mandatory, you need at least GUILDS and GUILD_MESSAGES

#

eitherway this is not what was being talked about before, about message content being disabled

#

starting from april 2022, message.content will be behind a new intent

#

and without that intent, you will recive messages with no/empty content

#

this is because discord wants you to use slash commands instead of message commands

wooden ember
#

one of my bots relyes on having acces to the message content so ima have to rewrite it at some point

quartz kindle
#

yes

wooden ember
#

i gave up on the other thing and just wrote 2k lines from a txt file into various discord channels to be sorted

wooden ember
#

its called notebot and allows a user so save a message that can be read later, intended uses are for:
> saving a list of prefixes for bots if the server has lots of them
> saving a rules list that can be posted anywhere instead of just telling peopel to "go look at the rules channel"
> people also use it to save todolists and reminders

boreal iron
#

hmm doesn't sound like a valid use case to get verified

#

(for the intent)

wooden ember
#

yeah well i doubt that it will ever get over 100 users and if it does i'll just make another one with exactly the same code

#

and if discord doesn't like it they can suck on my 20 alternative accounts

#

its only in16 servers atm and its been up for almost a year now

dusty garden
#

selling a tts bot for 20$ if anyone is interested dm me

#

price can be lowered to 15$

wooden ember
#

mm yes a bot that does the exact thing thats built into discord its self

#

revolutionary

vivid fulcrum
#

sorry to break it to you bud,

dusty garden
#

welp for 30$ i can offer a moderation bot

#

with other features too

wooden ember
#

>i google dyno
> free moderation bot

vivid fulcrum
#

also sorry to break it to you,

wooden ember
#

putting a ad to sell a bot in a server where almost ever person has made a bot isn't that good on an idea

vivid fulcrum
#

especially with an idea that's been made hundreds of thousands of times

wooden ember
#

at this point anything that you can make a discord bot do has already been done

#

unless you are making a privet bot

errant perch
#

69$ for hot sex robot

#

(real)

wooden ember
#

omg

proven lantern
quartz kindle
#

mine is still unique as far as i know

proven lantern
#

you know stars are actually aliens rightr?

#

what's the array look like?

#

["asdfasdfasdf", "asfasdfasdfasdf"] like this?

boreal iron
#

each array object?

#

object or item?

proven lantern
#

["1234567"].map(str => str.slice(0, -3))

boreal iron
#

yeah nvm, he's faster

proven lantern
#

👍

#

madness

#

javascript must be broken

boreal iron
#

["aaaz", "bbby", "cccd"].map(x => x.substr(0, x.length - 1));

#

FakE likes it complicated

proven lantern
#

oof

boreal iron
#

funny that slice already know the length

proven lantern
#

it's going to make a new array. the original array will not change

proven lantern
#

const newArray = ["1234567"].map(str => str.slice(0, -3));

boreal iron
#

We don't see what u're doing without code

proven lantern
#

use globby

#

x.lenght

boreal iron
#

xD

vivid fulcrum
#

async func
sync readdir
angeryBOYE

boreal iron
#

-999 social credits

proven lantern
#

promises are like actors or threads

vivid fulcrum
#

huh

#

sync readdir is blocking in both cases

#

lol

proven lantern
#

blocks the promise. jk

earnest phoenix
proven lantern
boreal iron
#

langdh

#

fuck ordered food and it's still not ready

earnest phoenix
#

I have question

x calls y function
y calls z function

So when you call x you will call z is it good idea?

boreal iron
earnest phoenix
#

Cnsöfmksmfmsmdms

vivid fulcrum
#

what lol

#

that question makes no sense

earnest phoenix
#

Yes it makes

boreal iron
#

You never heard of classes or OOP?

earnest phoenix
#

I have message and slash command and i am lazy to code all shit twice so i did it

boreal iron
#

dunno why "it" it's a bad idea to use

earnest phoenix
#

Buda %99 cpu usage

boreal iron
#

that second it lol

glacial vapor
#

i want to clean and use loop instead of this amazing yandere dev code but im lazy lmao maybe one day

earnest phoenix
#

Okay is good than?

vivid fulcrum
#

oh my god

glacial vapor
#

thats for 2 different image parts from embed

boreal iron
#

what in the name of...

glacial vapor
#

but it works tho so its good enough for now

glacial vapor
#

and my bot has not fallen from the free host yet

proven lantern
boreal iron
#

yeeey my food is done, brb

#

NOT burned, Tim, not burned

glacial vapor
glacial vapor
proven lantern
#

use that idea. you'll have to change it a little since you are doing > and not ==

#

But that should be data driven

proven lantern
#

nope

#

only greater than

#

jk

glacial vapor
#

you see them flipped KEK

proven lantern
#

so make an object that represents all the info in the if conditions. then write code based on that object. then all you need to do is update the object to add more features

quartz kindle
#

the level ifs could be replaced by an array

earnest phoenix
#

I have this code

async function ping(i) {
i.reply(ping)
}

slashCommand

module.exports = {
name: ping
run:
ping(i)
}

messageCommand 
module.exports = {
name: ping
run:
ping(msg)
}
quartz kindle
#

since they can be used as indexes

earnest phoenix
proven lantern
earnest phoenix
proven lantern
#

the canvas only supports rasterize images

earnest phoenix
#

And ?

proven lantern
#

they dont scale

earnest phoenix
#

Doesnt he want it for level system?

#

just canvas.filltext(level)

woeful pike
#

if only you had a type system that would simply tell you what broke

round cove
round cove
#

Is that what that is? Lmfao

spark flint
#

yep

#

a livestream

slow terrace
#

@round cove wow your avatar is so cool

#

Did you draw it by your self?

round cove
#

No I commissioned it.

earnest phoenix
#

does anyone here know how can i get all intents in discord.js?

earnest phoenix
#

yes

round cove
earnest phoenix
earnest phoenix
proven lantern
wooden ember
#

if i update to node 16 will d.js v12 stop working?

grim aspen
#

Yes

#

Discord.js v13 is available and only supported for nodejs v16

#

Wait nodejs upped a version

#

v17

boreal iron
#

16.6+

grim aspen
quartz kindle
#

16 is now lts

earnest phoenix
#

@quartz kindle nice pfp

quartz kindle
#

ty

frigid grail
#

hello

#

can you help me plz

#

the bot does not start

#

@earnest phoenix

#

I did

#

edited script

#
const client = new Discord.Client();

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

client.once('ready', c => {
    console.log(`Ready! Logged in as ${c.user.tag}`);
});

client.on("message", message => {
    if (message.content === "!ping") {
      message.channel.send("Pong.")
    }
  })
#

client.login('blablabla')

west stag
#

You are declaring client twice

frigid grail
#
const client = new Discord.Client();

client.once('ready', c => {
    console.log(`Ready! Logged in as ${c.user.tag}`);
});

client.on("message", message => {
    if (message.content === "!ping") {
      message.channel.send("Pong.")
    }
  })


client.login('blablabla')```
#

is good ?

west stag
#

Missing the message intent now but should start

frigid grail
#

MODULE_NOT_FOUND'

#

fuck

west stag
#

Do you have discordJS installed

frigid grail
#

yes

#

npm i discord.js

west stag
#

npm install discord.js

#

Yeah I works too

frigid grail
#

i run in a terminal

#

but is not running

west stag
#

Do: node .

#

While in the folder

frigid grail
#

and in debugger the app send message

#

i dont use

#

i use only terminal

#

yes in terminal

#

@earnest phoenix

earnest phoenix
#

npm i node@latest || npm i node@16.13.0

wooden ember
#

judging by the fact that its saying that discord.js is the issue i ould guess that node or d.js is outdated

earnest phoenix
#

Iam not pretty sure if djs 13 works perfect with node 17

spark flint
#
from quart import Quart, render_template, redirect, url_for
from quart_discord import DiscordOAuth2Session, requires_authorization, Unauthorized
import os

app = Quart(__name__)

app.secret_key = b"random bytes representing quart secret key"
app.config["DISCORD_CLIENT_ID"] = os.environ["clientid"]    # Discord client ID.
app.config["DISCORD_CLIENT_SECRET"] = os.environ["clientsecret"]                # Discord client secret.
app.config["DISCORD_REDIRECT_URI"] = "https://discord-thingymabob.benchurton.repl.co/callback"                 # URL to your callback endpoint.
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'

discord = DiscordOAuth2Session(app)

@app.route("/")
@requires_authorization
async def index():
    if not await discord.authorized:
        return await render_template("index.html")
    
    user = await discord.fetch_user()
    return await render_template("profile.html", useravatar=user.avatar_url or user.default_avatar_url, username=f"{user.name}#{user.discriminator}", guildcount = len(await discord.fetch_guilds()), friendcount=len(await discord.fetch_connections()))

@app.route("/login/")
async def login():
    return await discord.create_session()
    

@app.route("/callback/")
async def callback():
    await discord.callback()
    return redirect(url_for(".me"))


@app.errorhandler(Unauthorized)
async def redirect_unauthorized(e):
    return await render_template("index.html")


if __name__ == "__main__":
    app.run("0.0.0.0")``` returns ```py
oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response.``` on login
#

how to fix?

frigid grail
earnest phoenix
#

Dont copy paste

#

Choose one

spark flint
#

or him

earnest phoenix
#

Him

wooden ember
#

him

spark flint
#

ah

#

ok

earnest phoenix
#

Idk python so even didnt read your issue lol

frigid grail
#

@earnest phoenix

spark flint
#

lmao

wooden ember
#

same

earnest phoenix
wooden ember
#

using another language

earnest phoenix
#

Using javascript

jolly notch
#

^

earnest phoenix
frigid grail
earnest phoenix
#

type it in console

frigid grail
#

im noob

wooden ember
#

i casn tell lol

earnest phoenix
#

Yes i noticed that

frigid grail
west stag
wooden ember
#

you posted that laready

earnest phoenix
#

He get it again i think

wooden ember
#

ah

earnest phoenix
jolly notch
wooden ember
#

i mean no one is activly updating the py version so you will have to change languages or learn how to patch d.py yourself

earnest phoenix
#

But best option is js because its fast and flex

jolly notch
spark flint
#

both work pretty much identical

jolly notch
#

wouldn't trust either of them

spark flint
earnest phoenix
jolly notch
#

^

#

I only use the official versions of the api wrapper

spark flint
earnest phoenix
#

Then use js

earnest phoenix
frigid grail
#

you speak french ?

earnest phoenix
#

Yes i can use translator

wooden ember
#

no

earnest phoenix
#

dis moi ton problème mec

earnest phoenix
frigid grail
jolly notch
#

@earnest phoenix is french i think and i hope

earnest phoenix
#

The only thinh i know in french is
bonjour madam cammon tappeles tu?

frigid grail
#

is not " tu " is " vous "

earnest phoenix
#

Is it updated?

#

My application said its tı

#

Tu*

#

vous is polite form

wooden ember
frigid grail
#

tu is for friends, family and other

earnest phoenix
#

tu is formal

earnest phoenix
frigid grail
#

" vous " is for respect

earnest phoenix
#

I updated last before 5 years ago

earnest phoenix
#

french is easy, except everything about french

frigid grail
#

" Tu vas bien " = you're doing well ( for friends )
" vous allez bien " = you are fine ( for you boss in work )

earnest phoenix
#

French pronounce is kinda hard

frigid grail
earnest phoenix
#

for that i develop a conjugator in my bot

frigid grail
#

if you talk to someone you don't know, use " vous "

earnest phoenix
earnest phoenix
spark flint
#
[2021-11-06 22:08:34,464] ERROR in app: Exception on request GET /callback/
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 190, in _load
    signing_input, crypto_segment = jwt.rsplit(b".", 1)
ValueError: not enough values to unpack (expected 2, got 1)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1467, in handle_request
    return await self.full_dispatch_request(request_context)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1492, in full_dispatch_request
    result = await self.handle_user_exception(error)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 968, in handle_user_exception
    raise error
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1490, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1536, in dispatch_request
    return await self.ensure_async(handler)(**request_.view_args)
  File "main.py", line 31, in callback
    await discord.callback()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart_discord/client.py", line 163, in callback
    return jwt.decode(state, current_app.config["SECRET_KEY"], algorithms="HS256")
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jwt.py", line 119, in decode
    decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jwt.py", line 90, in decode_complete
    decoded = api_jws.decode_complete(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 149, in decode_complete
    payload, signing_input, header, signature = self._load(jwt)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 193, in _load
    raise DecodeError("Not enough segments") from err
jwt.exceptions.DecodeError: Not enough segments``` how to fix ![angery](https://cdn.discordapp.com/emojis/903340317770649610.webp?size=128 "angery")
earnest phoenix
#

And my learn french application teached me as that

frigid grail
earnest phoenix
#

My point is i dont ask my friends their name

spark flint
#

i sent it before iirc

earnest phoenix
tribal crow
#

Hey! How do i add a number option for slash commands?

#

I've tried .addNumberOption, but it says its invalid

boreal iron
#
options:
[
        {
            name: "unique_number",
            description: "A very unique number.",
            type: "NUMBER"
        }
]
glacial vapor
west stag
#

I'm new to typescript, trying to switch to it with my existing code, what's the proper way to get rid of the error?

woeful pike
#

the proper way is to stop mutating types you don't own

#

go construct a context object and put the stuff commands need inside there

#
type CommandContext = {
  client: Client
  buttons: Buttons
  guild: Guild
}

then you can just pass that around to your commands

function someCommand({ buttons, client }: CommandContext) {
  // whatever
}

and pull out whatever you want

coral sigil
tribal crow
#

nvm, figured it out with .addIntegerOption

coral sigil
split hazel
#

tfw you spend more time fixing typescript errors than actual program errors

loud ore
#

JS is only fast to write

night fiber
tribal crow
loud ore
night fiber
#

im not sure why slashCommandBuilder.addNumberOption(...) isnt working

tribal crow
night fiber
#

alr

eternal osprey
#

I have a for loop. I want to check if a certain word is in a database.

#

How could i safely if else it none word was found:

#

  for (const key in carddatabase){
    if(key == test[0][1]){
      const embed = new Discord.MessageEmbed()
  embed.setColor("RANDOM")
  embed.setFooter("Your daily dose of KPOP!")
  embed.attachFiles([`./cards/${key}`]);
  embed.setTimestamp()
  embed.setDescription(`Name: ${carddatabase[key].name}----Group: ${cardatabase[key].group}----Collection Number: ${carddatabase[key].number}\n`)
  message.channel.send(embed)
    }else if(key !== test[0][1] && (I NEED AN ARGUMENT HERE SO THE BOT DOESN`T SAY THIS MESSAGE FOR EACH KEY THAT ISN'T THE SAME){
      
   }
  }```
hybrid cargo
#

If u don't want the bot to send any message of there is no key, just remove the else if as a whole

eternal osprey
boreal iron
#

you just wanna send one message after the loop if one or more keys wasn’t found?

hybrid cargo
# eternal osprey i do want to send a not valid message

Declare a Boolean variable before the loop starts and assign it as false

Inside the first if statement make the variable as true, indicating that the for loop has found the word in database

After the loop, check if the variable is false, if it's still false then send that single message that u want

#

Or if u want to check if one or more keys is not found, make the variable true inside the else if block, and then check if the variable is true outside the loop

eternal osprey
#

thanks

quartz kindle
#

another way is to use returns

#
for(...) {
  if(found) return message.channel.send("found")
}
return message.channel.send("not found")
split hazel
#

does js have inverse sin?

#

i plotted it into a calculator which returned 30 while js asin returned 52.xxx

#

oh wait js gives the answer in radians doesnt it

#

that precision sucks ass

wheat mesa
#

pretty close

split hazel
#

radians are bad

#

degrees for life

wheat mesa
#

fr

quartz kindle
#

rads are better for computation i guess

#

computing in degrees would likely need a ton of control rules and shit

split hazel
#

rules?

spark flint
#

@quartz kindle you know how you are smart and all

#

jwt.exceptions.DecodeError: Not enough segments

#
[2021-11-07 01:09:52,600] ERROR in app: Exception on request GET /callback/
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 190, in _load
    signing_input, crypto_segment = jwt.rsplit(b".", 1)
ValueError: not enough values to unpack (expected 2, got 1)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1467, in handle_request
    return await self.full_dispatch_request(request_context)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1492, in full_dispatch_request
    result = await self.handle_user_exception(error)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 968, in handle_user_exception
    raise error
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1490, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1536, in dispatch_request
    return await self.ensure_async(handler)(**request_.view_args)
  File "main.py", line 28, in callback
    await discord.callback()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart_discord/client.py", line 163, in callback
    return jwt.decode(state, current_app.config["SECRET_KEY"], algorithms="HS256")
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jwt.py", line 119, in decode
    decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jwt.py", line 90, in decode_complete
    decoded = api_jws.decode_complete(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 149, in decode_complete
    payload, signing_input, header, signature = self._load(jwt)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 193, in _load
    raise DecodeError("Not enough segments") from err
jwt.exceptions.DecodeError: Not enough segments```
quartz kindle
#

make sure your jwt token is valid

#

A valid JWT has three segments separated by dots: <base64_encoded_header>.<base64_encoded_payload>.<signature>

spark flint
#

i don;t have control over that shit

#

its quart_discord which i use

quartz kindle
#

no idea then

#

make an issue on their repo

spark flint
#

will do

woeful pike
#

spent 1 hour debugging this YEP

wheat mesa
earnest phoenix
lament rock
#

Yes

#

Although you should just write data on INSERT statements

lament rock
#

INSERT INTO table (column1, column2) VALUES (2, 'poggers');

earnest phoenix
#
class Helpcmd(commands.Cog):

       def __init__(self, client):
           self.client = client

       @commands.command()
       async def help(self,ctx):
           self.client.help_pages=[page1,page2]
           buttons = [u"\u23EA", u"\u2B05", u"\u27A1", u"\u23E9"]
           current = 0
           msg = await ctx.send(embed=self.client.help_pages[current])

           for button in buttons:
               await msg.add_reaction(button)

           while True:
               try:
                   reaction, user = await self.client.wait_for("reaction_add", check=lambda reaction, user: user == ctx.author and reaction.emoji in buttons, timeout=60.0)

               except asyncio.TimeoutError:
                   embed = self.client.help_pages[current]
                   #embed.set_footer(text="\n\nTimed out")
                   await msg.clear_reactions()

               else:
                   previous_page = current

                   if reaction.emoji == u"\u23EA":
                       current = 0

                   elif reaction.emoji == u"\u2B05":
                       if current > 0:
                           current -= 1

                   elif reaction.emoji == u"\u27A1":
                       if current < len(self.client.help_pages)-1:
                           current += 1

                   elif reaction.emoji == u"\u23E9":
                       current = len(self.client.help_pages)-1

                   for button in buttons:
                       await msg.remove_reaction(button, ctx.author)

                   if current != previous_page:
                       await msg.edit(embed=self.client.help_pages[current])

       @help.error
       async def on_error(self,ctx,error):
           if isinstance(error,commands.CommandInvokeError):
               await ctx.send("Missing Permission: Manage Messages")
#

@finite quiver

finite quiver
#

Is it js?

earnest phoenix
#

no py

finite quiver
#

Py is dead If I'm right

earnest phoenix
#

ye

#

but idk js

finite quiver
#

I will check yr code in my pc

earnest phoenix
#

hmm

#

d.py is dead but there are active forks of it iirc

#

👀

#

js is gud for discord bot

#

java idk

#

Ok

earnest phoenix
#

i want that this help cmd should work without manage msg perm

#

it says missing permission

#

lemme check that

earnest phoenix
royal pawn
#

How to set different cooldown for different users?

finite quiver
royal pawn
#

Current code: Only whitelist

@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def example_command(ctx):
    await ctx.send("Hi")

whitelist = [762143182250442773, 987654321]

@example_command.after_invoke
async def reset_cooldown(ctx):
    for e in whitelist:
        #to whitelist a person:
        if e == ctx.author.id:
            example_command.reset_cooldown(ctx)
            
        #to whitelist a channel:
        if e == ctx.message.channel.id:
            example_command.reset_cooldown(ctx)
            
        #to whitelist a guild/server:
        if e == ctx.message.guild.id:
            example_command.reset_cooldown(ctx)
            
        #to whitelist a role:
        if e in [role.id for role in ctx.author.roles]:
            example_command.reset_cooldown(ctx)```
earnest phoenix
#

@carmine topaz ```Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

earnest phoenix
#

@royal pawn

client.cooldown.set(`${member.id}_${command.name}, 1000`)
royal pawn
earnest phoenix
#

Yes