#development

1 messages · Page 540 of 1

normal wyvern
#

But differnt people wanna use differnt things at different times

queen violet
#

yeah

#

make a different timer for each thing

normal wyvern
#

ye exactly

queen violet
#

not a different timer for each person

normal wyvern
#

I did

knotty steeple
#

store the time they run it or something

normal wyvern
#

No not for each person.

#

For each server using it say they have like 3 going on

#

say i have 1000 servers running that code? is that bad?

mossy vine
#

yes

#

very bad

queen violet
#

^

#

also have no idea how having a timer that takes 20 hours

knotty steeple
#

think about this

queen violet
#

will do anything

#

ever

knotty steeple
#

im a plumber

#

a shitty one

#

i fix my pipes in the worst way

#

literally with cloth

#

how well will that work

queen violet
#

lmao i love that analogy

knotty steeple
#

ikr

normal wyvern
#

whar if time = 240 not 1500

queen violet
#

you made the time in the settimer

#

60 seconds

knotty steeple
#

ok

#

thats like

#

me fixing the pipes with tape instead

queen violet
#

so it would actually be 240 minutes not seconds

normal wyvern
#

ye i know

#

but what if time = 240

queen violet
#

ok why the acutal fuck

#

dont you just do this

normal wyvern
#

and it does -=15000

#

instead of -=1

queen violet
#

let timeInterval = setInterval(() => {

  }, 240 * 60000)
normal wyvern
#

-=15 sorry

queen violet
#

boom

normal wyvern
#

no no no

knotty steeple
#

dep

#

wont that make it longer

normal wyvern
#

i need time-=1

#

so if i have tim -=15

topaz fjord
#

why does

#

css

#

have to be

#

autistic

knotty steeple
#

because it is

queen violet
#

thats what hes doing

#

isnt it

normal wyvern
#
js
let time = 240
let timeInterval = setInterval(() => {
        if (time === 1){
            
          clearInterval(timeInterval)
        }else {
          time -=15;
        }
      }, 900000)
#

Is that acceptable?

#

With say like 2200 people using at same time.

late hill
#

So you're using an interval to countdown a time and once it's passed you'll end the interval?

#

setTimeout ❓

earnest phoenix
#

Okay so! I am creating a giveaway command, however, the bot is able to win sometimes. I don't want that to happen but even when I specify that in the filter, it still picks the bot!

client.channels.get(config.channels.giveawayChannelID).send({embed}).then(msg => {
  msg.react("🎉");
  const filter = (reaction, user) => reaction.emoji.name === '🎉' && user.id !== client.user.id;
  const collector = msg.createReactionCollector(filter, { time: 10000 });
  collector.on('collect', r => console.log(`Collected ${r.users}`));
  collector.on('end', collected => console.log(collected.map(r => r.users.random().tag)));
})
``` JavaScript
#

Ping me when you respond to this kthxbai

keen drift
#

@inner jewel So, does it help in any way with gathering scattered data?

knotty steeple
#

@earnest phoenix filter the bot

earnest phoenix
#

I have if you can see.

user.id !== client.user.id; 
#

@knotty steeple

knotty steeple
earnest phoenix
#

Anyone else?

fierce thorn
#

If that's not working check if bot is winner and "reroll"

viscid agate
lusty dew
#
undefined
(node:4632) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'run' of undefined
    at Client.client.on (C:\Users\Aj\Desktop\Senpai\senpai.js:44:33)
    at Client.emit (events.js:182:13)
    at MessageCreateHandler.handle (C:\Users\Aj\Desktop\Senpai\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (C:\Users\Aj\Desktop\Senpai\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\Aj\Desktop\Senpai\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)    at WebSocketConnection.onMessage (C:\Users\Aj\Desktop\Senpai\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Aj\Desktop\Senpai\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:182:13)
    at Receiver._receiver.onmessage (C:\Users\Aj\Desktop\Senpai\node_modules\ws\lib\websocket.js:137:47)
    at Receiver.dataMessage (C:\Users\Aj\Desktop\Senpai\node_modules\ws\lib\receiver.js:409:14)
(node:4632) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4632) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Error

#
client.on("message", async message => {
    if(message.author.bot) return;
    if(message.content.startsWith(`@ripe burrow `) || client_settings.prefix){
        let command = message.content.slice((message.content.startsWith(client_settings.prefix) ? client_settings.prefix : `@525815816411676673`).length)
        let cmd = command.split(" ")[0];
        let args = command.replace(cmd+" ", "");
        let commandfile = commands.get(cmd);
        console.log(commandfile)
        console.log(commandfile.run)
        if(commandfile) {
            commandfile.run(client, message, args).catch((e)=>console.error(e));
    }
}
});

Code

#

It worked fine when using the prefix

#

but when I tried doing @ bottest

#

It threw that error above

#

I fixed the error but the mention still doesn't work

frail terrace
#

ok should i use json for queues or what bc dbs are hella gay

#

music queues that is

amber fractal
#

I use a javascript object

#

Lol

frail terrace
#

well my bot is c#

amber fractal
#

AH

#

Ah*

frail terrace
#

but idk how else to store the queue because litedb (the db i use) won't serialize the song class, and so when trying to restore the saved queue the queue is null

#

so i get an exception/error

high anchor
#

anyone with discordjs regularly getting this

#
{ DiscordAPIError: Invalid Form Body
avatar: File cannot be larger than 10240 kb.
at item.request.gen.end (/app/node modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:79:15),
at then (/app/node modules/snekfetch/src/index.js:215:21)
at process. tickCallback (internal/process/next_tick.js:68:7)
name: 'DiscordAPIError',
message:
"Invalid Form Body\navatar: File cannot be larger than 10240 kb.',
path:
"/api/v7/webhooks/525859688873721867/cXW2uhlKJØjI1A2A46Z1pMZY3Uuggm8wTdwtJWvIfeyin21cgKpVnwgaA0b2wWLI26UT',
code: 50035,
method: 'PATCH' }
#

the only things i am using for webhook avatars are the avatars from actual users themselves

#

so i didn't assume it would be an issue

#

oh

#

oh god oh fuck

#

it's that guy with the 30 minute GIF avatar

#

shit

modest shore
#

@fervent oyster do u know how i do this "streaming" status in eris ?

fervent oyster
modest shore
#

i already red this

#

but where do i have to set the "game.type"

#

ay

#

i think i know

bright spear
#

lmao uhtred

modest shore
#

in the embed *

faint junco
#

hayyyyyyyy whats going on

modest shore
#

can someone help me?

#

its not working

warm marsh
topaz fjord
#

show

#

more

#

code

modest shore
#

i fixed it

#

i uploading the image to imgur and then i am sending the message

#

@topaz fjord it was an normal embed where i wanted to provide an image

#

like

earnest phoenix
#

One of you can help me for sharding ? With JDA

quartz kindle
#

@modest shore you need to load the image into an embed attachement before you can use it in embeds

modest shore
#

i tried everything

#

but still invalid form body

quartz kindle
#

embed.attachFile

#

then in the image url: attachment://fileName.extension

modest shore
#

so do i have to do this ?

embed: {
    attachFile: "ok.png",
    image: {
        url: "attachment://ok.png"
    }
}
#

@quartz kindle `

quartz kindle
#

no, you have to use discord's richembed builder

modest shore
#

yeah i am trying not to use djs

#

for this time

#

i am redoing my bot in another lib. the version which is now up and running is in djs

quartz kindle
#

idk if you can do it in an embed literal, have you tried using Discord.attachment?

modest shore
#

i try some things now

quartz kindle
#

if you plan to use another lib, then that other lib should tell you how to upload files

modest shore
#

the docs are really shitty tbh

quartz kindle
#

rip

modest shore
#

yeah

sick cloud
#

eris @modest shore?

#

have fun

#

eris docs are annoying

modest shore
#

yes @sick cloud

quartz kindle
#

yeah embeds only support http urls or attachments, and to send an attachment you need to upload it via multipart/form-data, which should be handled by the lib

modest shore
#

yeah so i am using imgur atm to upload the image to send an embed lmao

quartz kindle
#

that sounds disturbingly inefficient lmao

modest shore
#

it is

#

if my vps has an bad time the response is delayed af

last ferry
#

what are you trying to do

#

if you have a set of static images why not just upload them all beforehand

earnest phoenix
#

Anyone use JDA ?

last ferry
#

or are you uploading images you dont have yet

modest shore
#

@last ferry i have to edit an image and then upload it

last ferry
#

ah i see

#

i have something like that with mine to and i just send it as a message

inner jewel
#

@earnest phoenix just ask the question, don't ask to ask

earnest phoenix
#

for Sharding

#

if anyone can help me

modest shore
#

@last ferry which lib are u uing?

last ferry
#

C#

modest shore
#

oof

inner jewel
#

just ask your question

last ferry
modest shore
#

my problem is that the docs of the lib that i use are so shitty

earnest phoenix
#

How do you get an information about a shard ?

quartz kindle
#

i dont see anything about attachments in eris docs, maybe it isnt supported

inner jewel
#

what kind of information?

last ferry
#

is it possible for you to just send the image alone or does it have to be embeded

quartz kindle
#

or maybe it uses the same file as the message.file

earnest phoenix
#

numbers of users and guild

last ferry
#

cause that may be your only option

inner jewel
#

use a shard manager

#

and then ShardManager#getXyzCache().size()

earnest phoenix
#

And you create shard manager with ?

modest shore
inner jewel
#

new DefaultShardManagerBuilder().setToken(...).setWhatever(...).build()

modest shore
#

nothing else

earnest phoenix
#

A DefaultShardManager work ?

inner jewel
#

DefaultShardManagerBuilder

#

use the builder

#

the DefaultShardManager constructor is huge

modest shore
inner jewel
#
createMessage(channel.id, "this is my file", {
    file: Buffer.from("this is my text"),
    name: "buffer"
});```
modest shore
#

damn

#

ty

bright spear
#

is that eris?

modest shore
#

yes

bright spear
#

if you're a beginner u should probably be using d.js

#

its way better/easier and much more people can help

modest shore
#

im not a beginner my current version of the bot is djs but i dont want to use it anymore

#

and the docs from eris are way worse than the docs from djs

bright spear
#

why are you switching?

modest shore
#

want to see which lib is perfoming better on my vps

opal copper
#

Hey

#

How can I do two .setActivity (ex: "Look everyone" 2 seconds later "On 4 servers") on discord js

quartz kindle
#

set activity => setTimeout(function(){ set activity }, time to wait)

shy rose
#

if 2 people have the same avatar will the hash of both be the same?

bright spear
#

i dont think so

opal copper
#

thx @quartz kindle

bright spear
#

u can test it

modest shore
#

@inner jewel ok its working but it was the wrong thing oof

quartz kindle
#

did it just put the image outside of the embed?

modest shore
#

no

#

it does this

quartz kindle
#

thats because the buffer type is wrong

modest shore
#

of

#

nevermind

#

forgot to save

inner jewel
#

no

#

that's because no extension

opal copper
#

ThinkEyes the setGame not working

inner jewel
#

Buffer.from doesn't read files

modest shore
#

what do i have to provide there

quartz kindle
#

you need to use fs.readFile

inner jewel
#

also if you're generating an image, don't write to disk

#

i'm pretty sure most image manipulation libs allow you to export the result to a buffer

modest shore
#

okay

#

i look

quartz kindle
#

fs.readFile can read a file into a buffer, so if you have any static images such as backgrounds, etc that you use in manipulation, load them and keep them in memory for future uses

opal copper
#

How can I do two .setGame (ex: "Look everyone" 2 seconds later "On 4 servers"), not the .setActivity

earnest phoenix
#

For get the shard where I am it's ShardManager#getShardsQueued() ?

inner jewel
#

no

#

get it from the current JDA instance

#

with JDA#getShardInfo()

earnest phoenix
#

oh yes x)

#

but for get the JDA instance I need the shardID 🤔

modest shore
#

@quartz kindle when i want to read the file what parameter do i have to give instead of "utf8" to get the buffer

quartz kindle
#

buffer should be the default i think

#

let me check

modest shore
#

ok

inner jewel
#

no

#

you can get the instance from events

#

Event#getJDA

quartz kindle
#

yeah buffer should be the default if nothing is specified

earnest phoenix
#

I did not think about it é_è

modest shore
#

ITS WORKING

#

Thank you guys !

quartz kindle
#

did it upload inside the embed? or outside?

earnest phoenix
#

Thank's Natan it work

high anchor
#

if you do any file reading make sure it's async
mmLol
also there's lots of modules that can do compression for you

modest shore
#

@quartz kindle atm just as an image

#

without anything

#

but i am going to sleep now 2AM for me atm

earnest phoenix
#

I'm confused on why my Beta version of my bot has more delay then the release version, there isn't any code differences besides adding a few more commands, which aren't big.

high anchor
#

Is there any option to get compressed versions of images from the CDN
like a size parameter/query in the url

#

the discord CDN ofc

bright spear
#

yes

#

?size=whatever

opal copper
#

hey, i have installed ffmpeg in my node_modules but when i use my play command, the console write that ffmpeg is not found

earnest phoenix
#

download the binaries

opal copper
#

Yes I found before, thanks anyway

earnest phoenix
#

k

formal agate
#

For oauth I'm trying to receive the access token, i already have the access code. When I tried following the directions, porting it to js and I even tried using postman to send a request. I still was getting errors saying method not allowed.
Ex from discord: https://discordapp.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-exchange-example
Sending request to: https://discordapp.com/api/oauth2/token

Discord

Step up your game with a modern voice & text chat app. Crystal clear voice, multiple server and channel support, mobile apps, and more. Get your free server now!

sick cloud
#
.addField('Moves (incl. possible moves)', `${pokemon.moves.slice(0, 16).map(m => m.move.name).join(', ')}, and ${pokemon.moves.slice(16, pokemon.moves.length)} other${pokemon.moves.slice(16, pokemon.moves.length) > 1 ? 's' : ''}`)

still being thrown Must be 1024 or fewer in length., any ideas here

#

i've cut off loads

formal agate
#

add other fields

#

make it inline to

#

@sick cloud

sick cloud
#

how is making it inline going to help lul

formal agate
#

looks nice

opal copper
#

Hey, I have create a play command but this command not working and I don't why

formal agate
#

thats the most important thing

#

the url format is wrong

#

show the whole code

#

hide keys

opal copper
sick cloud
#

that is the most horrible play command ive seen in a while

formal agate
#

ok first const voiceChannel = message.member.voiceChannel;

west raptor
#

args isnt defined

#

ou wait

#

nvm

formal agate
#

it is

west raptor
#

I see it now

formal agate
#

simple args

const args = message.content.slice(prefix).trim().split(/ +/g);
const cmd = args.shift().toLowerCase();```
opal copper
#

?

formal agate
#

after the like 4th episode the code is all wrong

#

but before that it is all fine

#

fourth, make a command hanlder

bright spear
#

youtube tutorials

#

nice meme

formal agate
#

lol

#

if only oauth for discord had one

high anchor
#

@bright spear thanks! you saved me a lot of time

bright spear
#

yw

high anchor
#

i was ready to programmatically resize

earnest phoenix
#

I want to know, the method ShareManager#restart is for ? Because when I use it, my uptime didn't change so it's not a real restart

inner jewel
#

it only reconnects the shard

#

it won't restart your process

earnest phoenix
#

hmm ok

#

I can't do a real restart command ? Restarting the jar file

inner jewel
#

have something waiting for your process to exit and restarting it

#

eg a shell script

earnest phoenix
#

Hmm ok I see

modest shore
#

has someone an idea what i did wrong ?

mossy vine
#

i dont know eris, but why is the url attachment://

modest shore
#

because an image in an embed cannot have an local file so some guy told me to use the attachment thing

mossy vine
#

post the image in a private server and use its cdn.discordapp link

modest shore
#

never tought about that

modest shore
#

and without channel it returns Promise<Message>

misty rune
#

should await it i guess ?

#

(i don't know this lang but i guess since it's a promise)

topaz fjord
#

If you don't know the lang

#

Learn the lang

misty rune
#

why tho

topaz fjord
#

So you know what your doing?

#

That's the stupidest question I've heard

last apex
#

@topaz fjord Can you code using MongoDB?

topaz fjord
#

Yes

#

I do use mongodb

last apex
#

What for?

topaz fjord
#

Storing bot settings, votes, user data

keen drift
#

Can you code using mongo

#

What kind of question

earnest phoenix
#

you are doubling the request and putting more work in

the attachment thing is just fine, you just need to figure out how your library handles it because the attachment protocol is built in discord

topaz fjord
#

Or just store the file in /tmp/ and send it then delet it

earnest phoenix
#

thonk

#

the point of the attachment protocol is to utilize it in embeds

mossy vine
#

why would it double the request?

#

the code doesnt need the image to send the url

earnest phoenix
#

exactly however youd need to send 2 requests

one to send the image in the private guild and the other to send an embed in desired channel with the first requests image url

mossy vine
#

you dont need to senf it in a private guild

#

send it once yourself, get the link, and send the link via code

earnest phoenix
#

still doubles the requst msthonk3

#

request**

keen drift
#

If you plan to reuse it, it's prob better to use the link

earnest phoenix
#

even if you needed to keep the link, you could save the message object and later. access its attachments

keen drift
#

Then there's no need to attach it per message later, just extra cost

earnest phoenix
#

what

#

literally read my message above

keen drift
#

I'm assuming we are talking about sending images

earnest phoenix
#

yeah...?

keen drift
#

If you were to attach it per message, that's new upload per message

#

Link wise it just uses the existing resource instead of creating new ones

earnest phoenix
#

yeah, thats why i said if you want to reuse it, youd save the message object and access the attachments and grab the url from there

#

my point is optimization; use minimal requests you can

keen drift
#

It's really the same if he supplies it manually

earnest phoenix
#

it is not msthonk3

keen drift
#

How is it not

#

Both reusing it if he access it later

earnest phoenix
#

is giving a pear then an apple to a person the same as giving them both at the same time? you could just give both the pear and the apple at the same time, saving time, would it be just a second.

#

the reusing process is the same in both cases, the initial request is not

#

something is telling me you jumped into the conversation before reading what was discussed msthonk3

keen drift
#

The end result is still the same

#

Sure initial steps is different

#

But what's the outcome?

earnest phoenix
#

youd worry about the process, not the outcome

#

one process is saving time and resources, one is wasting them

keen drift
#

This discussion is getting nowhere and is just repeating previously discussed points

earnest phoenix
#

dot dot dot

keen drift
#

I'm going to get back to work, but C's method is undoubtedly the easiest for a single resource

earnest phoenix
#

it would also fall under api abuse 🤷

yall never heard of optimization and respecting ratelimits

keen drift
#

How is using an image link api abuse

marble juniper
#

how do i make a bot 24/7 online

earnest phoenix
#

use a host

#

id suggest DigitalOcean or Scaleway

marble juniper
#

ok

misty rune
#

@topaz fjord why should i know what i'm doing since i don't even code with this lang

#

i just tried to help the user who was looking for help

topaz fjord
#

then don't try to help if you don't know the lang or the lib

#

it will lead to nothing

misty rune
#

wasn't it to just add .then after the getMessage() ?

mossy vine
#

okay so im quite new to fs and all that stuff, but how can i get a list of subdirectories in a directory

bitter sundial
#

node.js, right?

mossy vine
#

yup

#

the fs docs are confusing as fuck and dont answer any questions

bitter sundial
#

not that hard

formal agate
earnest phoenix
#

can anyone help me with discord.js-lavalink
this is what i have atm

if (!msg.member || !msg.member.voiceChannel) return msg.reply("Must be in a voice channel");
        let [...track] = args[1]
        track = track.join(" ");
        const [song] = await getSong(track);
        const player = await client.player.join({
            guild: msg.guild.id,
            channel: msg.member.voiceChannel.id,
            host: getIdealHost(msg.guild.region)
        }, { selfdeaf: true });
        if (!player) throw "No player found...";
        player.play(song.track);
        player.once("error", console.error);
        player.once("end", data => {
            if (data.reason === "REPLACED") return;
            msg.channel.send("Song has ended...");
        });
        return msg.reply(`Now playing: **${song.info.title}** by *${song.info.author}*`);

but every time i play a link it says "no track found

(node:15944) UnhandledPromiseRejectionWarning: No tracks found
(node:15944) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15944) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
west raptor
#

what's getSong

dreamy breach
#

Someone know how to check with discord.js if a player is into the discord? (To remove @ with numbers)

earnest phoenix
#
async function getSong(string) {
    const res = await snekfetch.get(`http://${config.restnode.host}:${config.restnode.port}/loadtracks`)
        .query({ identifier: string })
        .set("Authorization", config.restnode.password)
        .catch(err => {
            console.error(err);
            return null;
        });
    if (!res) throw "There was an error, try again";
    if (!res.body.length) throw `No tracks found`;
    return res.body;
}
formal agate
#

wdym if player is into the discord?

#

oh to remove the mention?

#

but only a specific type?

#

umm

dreamy breach
#

Just check if it’s on the server

#

I want a leaderboard of the guild

formal agate
#

.....

#

do you have something setup for that?

dreamy breach
#

So only actual members cqn be added

formal agate
#

do you want to check if it was sent in a guild?

#

idk what you mean rn

dreamy breach
earnest phoenix
#

@west raptor this is getSong

async function getSong(string) {
    const res = await snekfetch.get(`http://${config.restnode.host}:${config.restnode.port}/loadtracks`)
        .query({ identifier: string })
        .set("Authorization", config.restnode.password)
        .catch(err => {
            console.error(err);
            return null;
        });
    if (!res) throw "There was an error, try again";
    if (!res.body.length) throw `No tracks found`;
    return res.body;
}
mossy vine
#

(node.js) is there any way to define a variable in one file and use it in another one? (global.x doesnt work)

knotty steeple
#

make it in a module

mossy vine
#

im reading a directory with fs so i dont want to do it every single time i need to work with it

knotty steeple
#

well then

#

no other way

mossy vine
#

hmm thats big sad

knotty steeple
#

how are you doing it

amber fractal
#

cant you require?

#

Idk how other files work

#

I do all mine in the same file lol

mossy vine
#

i read the dir in index.js and save the output to a variable
i need to use the same variable in ./src/hi.js

knotty steeple
#

global.thing = thing

mossy vine
#

yes, that doesnt work

#

hold on lemme just

#

okay im actually stupid

#
global.loadedModules = 'hi'

fs.readdir('./src/modules', (e, f) => { 
    loadedModules = f
    console.log(`Loaded modules:\n${f}`) 
})```
#

i was doing it totally wrong

#

now it works lmao

knotty steeple
#

lmao

earnest phoenix
#

What is the code for displaying all emojis? [Eval]

knotty steeple
formal agate
#

Ok, i need an example of what to do in js when making a token exchange. I've tried a few ways including postmaster and I still need help.

UPDATE
All I've just realized that I need a header like such but I'm still getting errors saying method not allowed. ```js
'Authorization': Bearer ${code}


Link to what I'm talking about https://discordapp.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-exchange-example
Discord

Step up your game with a modern voice & text chat app. Crystal clear voice, multiple server and channel support, mobile apps, and more. Get your free server now!

earnest phoenix
#

When I try to bump my server as a test, it comes out like this when it should be on seperate lines, anyone know how to fix this. JavaScript and I'm using SQLite

mossy vine
#

is this an issue with the bot?

#

if so go to the bots support server

#

if not, \n for seperate lines

earnest phoenix
#

I am the owner of the bot

mossy vine
#

oh, then \n

earnest phoenix
#

But I don't want them to have to do \n every new line

mossy vine
#

iirc they cant even do that lmao

earnest phoenix
#

You can. Partner Bot has it

formal agate
#

then break all the data up

#

into let staments

#

then compile it

#

happy? its pretty simple

earnest phoenix
#

Still unsure of how I do it 😦

formal agate
#

omg

#

break up all the data in the response

#

because your making a api call right?

#

then it will give it to you in sperate sections already

#

then you can output it how you like

earnest phoenix
#

I'm not using an API call LUL

formal agate
#

OMG

earnest phoenix
#

😂

formal agate
#

then how you pulling data from a server list?

earnest phoenix
#

SQLite DB

formal agate
#

is it your own?

#

omg

#

then you should set it up better then

earnest phoenix
#

What do you mean

#

It's set up properly

earnest phoenix
formal agate
#

you can have differents section is a sqlite db right?

earnest phoenix
#

English please mate...

formal agate
#

im done

earnest phoenix
#

Your sentence does not even make sense

formal agate
#

like in a json

earnest phoenix
#

Yes

formal agate
#

then do it like that

#
xp[message.author.id] = {
            xp: 0,
            level: 1
        };```
#

nice json example

earnest phoenix
#

Wait no, I didn't understand. Sorry. It isn't like JSON lol

#

Want me to send you doc link?

#

for SQLite?

formal agate
#

i know sqlite basics

#

you can have "sections" or what ever

#

name then what you will

earnest phoenix
#

I just have different columns in the table

formal agate
#

fill it with you corresponding data

#

omg

earnest phoenix
#

Yes

formal agate
#

then pull the data from that

#

line by line

#

organize it like that

earnest phoenix
#

Okay

#

@formal agate This is how I done it. Is this right? :o

sql.run(`UPDATE guildConfig SET description = "${description.replace(/\r\n/, "\n").split("\n")}" WHERE guildID = ${message.guild.id}`).catch(console.error);
formal agate
#

i only know sqlite basics

earnest phoenix
#

I done that, but still nothing unfortunately

formal agate
#

from web devolvement

earnest phoenix
#

hmm okay 😦

formal agate
#

use google

earnest phoenix
#

Already tried. Have not came upon anything

quartz kindle
#

show the embed code

formal agate
#

tim

earnest phoenix
#
var embed = new Discord.RichEmbed()
  .setAuthor(`${message.guild.name} | Server Bumped (Preview)`, message.guild.iconURL)
  .setDescription(`${row.description}\n**[Click here to join the Server!](${row.invite})**`)
  .setImage(row.banner)
  .setColor(row.color)
  return message.channel.send({embed}).catch(console.error);
  }).catch(console.error);
formal agate
#

he didn't separate the data

#

thats the only thing

earnest phoenix
#

So

#

Split it by line

#

Then join it?

#

idfk fml

quartz kindle
#

so basically row.description is a single string

#

do you ever update it? or it is always the same

earnest phoenix
#

It's customisable per guild

#

You can update it with the same command

quartz kindle
#

do you customize it or can people also do it?

earnest phoenix
#

Admins of servers can customize it.

#

Per Server

quartz kindle
#

then you need to check how you receive the data, im not sure how discord gets messages that contain new lines

#

or you can make a special character act as a separator for new lines, and tell people to use it

earnest phoenix
#

hmm

#

Such as \n?

quartz kindle
#

yeah

#

for example, what happens if you do

earnest phoenix
#

Would this code work with \n

sql.run(`UPDATE guildConfig SET description = "${description.replace(/\r\n/, "\n").split("\n")}" WHERE guildID = ${message.guild.id}`).catch(console.error);
quartz kindle
#

setdescription this is a test description line 2 description line 3

#

what happens if someone types that, does discord show new lines in the message content?

earnest phoenix
#

Have not tried it. I'm not sure how I would actually make that happen

quartz kindle
#

let me test actually

#

it should work, the message should contain \n in it

#

what happens if you update the database with a description that contains new lines?

modest shore
formal agate
#

that seems like somthing for discord js

west raptor
#

its not

formal agate
#

idk eris

modest shore
#

can someone tell me how to get it working ?

#

i try to switch from djs to eris

#

in djs i would know it but in eris dik

west raptor
#

whats uh

#

eris

#

docs

#

nvm

quartz kindle
#

try type 1 instead of type streaming

modest shore
#

okay

gilded blaze
#

No need to specify game

modest shore
#

@quartz kindle nope doesnt work either

quartz kindle
#

did you do 1 or "1"

modest shore
#

just

#

1

quartz kindle
#

then idk

modest shore
#

already rad this

mossy vine
#

Maybe you should set status to online?

gilded blaze
#
client.setStatus({gameprop})
modest shore
#

it seems to me that nothing is updateing

west raptor
#

odd

#

you restarted the bot right?

modest shore
#

yeah

#

everytime

#

ay

#

i think its working now

formal agate
#

Ok because this place is active again I'm gonna ask this question. Ik this code is wrong, but idk why. The errors say basically nothing as to why. (I basically just changed a few things from the ex from discord.) js const exchange = await fetch(`https://discordapp.com/api/oauth2/token`, { data = { 'client_id': process.env.CLIENT_ID, 'client_secret': process.env.CLIENT_SECRET, 'grant_type': 'authorization_code', 'code': code, 'redirect_uri': `MY CRAZY URL HERE`, 'scope': 'identify guilds' }, headers = { 'Authorization': `Bearer ${code}` } });

inner jewel
#

that's not valid js

formal agate
#

thanks

#

ive figure that much out

inner jewel
#

k: v

#

not k = v

gilded blaze
#

Don't use template literals if you are not templating

bright spear
#

why? it doesnt break anything

formal agate
#

i no nothing of oauth

bright spear
#

its not oauth its invalid js

formal agate
#

ik that

bright spear
#

you dont need to know oauth to see issues there

mossy vine
#

This is basic js object stuff

bright spear
#

you just need to know js

formal agate
#

im stupid

bright spear
#

did u read wot natan said?

formal agate
#

no

#

but i just did

mossy vine
inner jewel
#

i'd recommend not copy pasting discord's example python code and learn the language properly instead

formal agate
#

never really learned js

#

just went off docs

inner jewel
#

you should learn it before trying to make something complex

mossy vine
#

That was a bad idea

formal agate
#

ik

#

thats the fun part

inner jewel
#

if you don't even know the syntax you can't expect to make something that works

mossy vine
formal agate
#

managed to get the token so far so

bright spear
#

wait

formal agate
#

code sorry

#

not token

bright spear
#

you used a python example in js???

#

the frick

formal agate
#

yes

#

ik

#

so ive been told

quartz kindle
#

well if you know then it shouldnt be surprising that it doesnt work

formal agate
#

🤷

#

got a nice method not allowed

inner jewel
#

because you did a GET instead of POST

formal agate
#

oh

#

now its bad request

#

ok

#

yay

keen drift
inner jewel
#

now it's go-read-the-docs-for-whatever-fetch-library-you-use-to-find-out-how-to-make-an-url-encoded-post-request

formal agate
#

fish enjoy this show

earnest phoenix
formal agate
#

its real "fun"

earnest phoenix
#

not skim read over it, actually read it with understanding

formal agate
#

ok

#

well my issue is that its not in the correct format now

quartz kindle
#

are you just blinding trying out things until you accidentally do something that works?

formal agate
#

mostly

#

and looking at docs

tall gyro
#

what do I do if I need to contact someone who turned down my bot wrongly but they don't answer my DMs?

earnest phoenix
#

what you mean

tall gyro
#

Well the same mod declined my bot twice because he said my help command sucked

#

but it works and explains everything there is to explain

formal agate
#

contact support

earnest phoenix
#

can we see the help command

formal agate
#

we have been over this

tall gyro
#

I thought you said to just message the guy who declined it, I dodn't realize there was actual support

formal agate
#

there is

#

we told you to

tall gyro
formal agate
#

then you said you where gonna message him

tall gyro
#

o

#

I was at a parade when that happened so I was a lil distracted

formal agate
#

or you could ask other staff

earnest phoenix
#

@tall gyro did you say in the long description or short description that your help command was token what can you do?

tall gyro
#

yeah in the long one, and it also says that when the bot is added to the server, if a text channel named "general" exists

quartz kindle
#

why dont you switch them around?

#

make token help the main help command

#

and use something else for your support server link

zealous veldt
#

like token support

quartz kindle
#

token what can you do is not a very intuitive help menu

earnest phoenix
#

i mean like

#

most people don't read the long desc

tall gyro
#

I could switch it around if something like
if message.endswith == 'more':
exists - I know the startswith is a thing but is ending too?

quartz kindle
#

it exists in js, idk about python

#

but anyway you shouldnt rely on that, because it can more easily be triggered by long sentences who randomly end with that keyword

#

unless you check for both start and end

inner jewel
#

message.endswith("more")

tall gyro
#

yeah it's check if it included "token help" and if it ends in more then it'd send the support link

earnest phoenix
#

How to create a temporary invitation from a server with a command?

#

JS

formal agate
#

what library

earnest phoenix
#

discord.js

quartz kindle
earnest phoenix
#

Thx Tim

formal agate
#

omg

#

omg

#

idk what i did

#

but i got a response

#

YES!!!!

#

oh

#

wait no

#

it still is broken

inner jewel
#

how about learning the language/fetch library first 🙃

formal agate
#

i was logging the wrong thing

#

lol

#

Natan, why learn, when you can try for hours and hours of changing little amounts of code in hopes of it working?

formal agate
#

ok every single thing I've basically says this is correct for oauth, but it still says 'BAD REQUEST' and idk why. ```js
let exchange = await fetch(https://discordapp.com/api/oauth2/token, {

  method: 'POST',

  data: {
    'client_id': process.env.CLIENT_ID,
    'client_secret': process.env.CLIENT_SECRET,
    'grant_type': 'authorization_code',
    'code': code,
    'redirect_uri': `http://kool.kool/api/discord/callback`,
    'scope': 'identify guilds'
  },
  headers: {
    'Authorization': `Bearer ${code}`
  }

});```

earnest phoenix
formal agate
#

did you use edit?

earnest phoenix
#

What

formal agate
#

also what lang

earnest phoenix
#

Why would I need to do that

#

d.js

formal agate
#

what library

#

ahhh

#

did you use message.edit or something like that?

earnest phoenix
#

No

formal agate
#

that is why

earnest phoenix
#

How

#

What

#

Those are separate messages

formal agate
amber fractal
#

wait whats the problem?

earnest phoenix
#

My bot adds logs onto other logs

#

In new messages

formal agate
#

use google

earnest phoenix
#

So basically

#

This

#

This this

#

This this this

#

It just adds

formal agate
#
#

its simple

earnest phoenix
#

My problem isn’t what you are assuming it is

#

I’m not editing anything

#

It’s obviously how to edit messages

amber fractal
#

Clearly what your saying is not what his problem is.

earnest phoenix
#

Hold on

formal agate
#

what are you trying to do then?

#

"Why does my bot add on logs instead of replacing them?"

#

thats what you said

earnest phoenix
inner jewel
#

what's your code?

formal agate
#

so the fact that it sends to messages?

#

thats your issue?

earnest phoenix
#

I’m on mobile and it’s too hard

#

you are probably reusing the same embed

#

making it duplicate fields

#

retake a good look at your code and fix any loopers

#

also you should probably explain your problem instead of giving us little to no context and expecting us to understand it

late hill
#

Because you have a variable with those logs

#

And you're just adding more to it

earnest phoenix
late hill
#

Clearly

#

Make sure musicEmbed is a new embed

#

For a new log

earnest phoenix
#

I have it as new Discord.RichEmbed()

late hill
formal agate
#

that means nothing

#

if there are other named that

#

they would need to be in other files

#

REPOST:
ok every single thing I've basically says this is correct for oauth, but it still says 'BAD REQUEST' and idk why. ```js
let exchange = await fetch(https://discordapp.com/api/oauth2/token, {

  method: 'POST',

  data: {
    'client_id': process.env.CLIENT_ID,
    'client_secret': process.env.CLIENT_SECRET,
    'grant_type': 'authorization_code',
    'code': code,
    'redirect_uri': `http://kool.kool/api/discord/callback`,
    'scope': 'identify guilds'
  },
  headers: {
    'Authorization': `Bearer ${code}`
  }

});```

quartz kindle
#

is the code even defined?

formal agate
#

yes

#

the request is passing through

quartz kindle
#

i mean, where are you getting the code from? do you get it from a page where you have to click authorize?

formal agate
#

yes

#

it is showing up in the browser

quartz kindle
#

it doesnt say anything about authorization headers being needed, but they do have 'Content-Type': 'application/x-www-form-urlencoded'

#

so try adding that to your headers

formal agate
#

hmm ok

#

i thought you replaced content-type with Authorization

#

error (same as before): ```error
Response {

size: 0,

timeout: 0,

[Symbol(Body internals)]:

{ body:

  PassThrough {

    _readableState: [Object],

    readable: true,

    domain: null,

    _events: [Object],

    _eventsCount: 3,

    _maxListeners: undefined,

    _writableState: [Object],

    writable: false,

    allowHalfOpen: true,

    _transformState: [Object] },

 disturbed: false,

 error: null },

[Symbol(Response internals)]:

{ url: 'https://discordapp.com/api/oauth2/token',

 status: 400,

 statusText: 'BAD REQUEST',

 headers: Headers { [Symbol(map)]: [Object] } } }```
quartz kindle
#

you dont need authorization

formal agate
#

ok

#

bad request

#

omg

#

i think i was using the wrong redirect

#

and still a bad request

quartz kindle
#

idk then, i need to go sleep

formal agate
#

ok

#

thank you

#

your honestly the most help I've gotten today

wise plume
#

discord.js

idle mountain
#

restate your question ^

#

I can't help you so someone else will have to

wise plume
#

trying to finish my addrole command and its telling me "find" is depreciated. Not sure where to find what im supposed to use

sick cloud
#

use a function

#

.find(u => u.thing === anotherThing)

#

find takes a function, not the old 2 parameter way

wise plume
#

I'll see what I can do.

slim heart
#

@wise plume what @sick cloud said. but basically in english;

When you do like .find('type', 'string') is deprecated meaning it's not supposed to be like that anymore i gues lol, not supported.

So now what you have to do is .find(thing => , thing represents the object that has whatever type you're trying to find so when you do like .find('name', 'namehere') you needa do .find(objWithName => objWithName.name === "namehere")

sick cloud
#

basically in English, cool

slim heart
#

Big english

wise plume
#

oof let google be my friend lol im still very new to both js and bot dev

#

that does point me in the right direction though so thank you

slim heart
wise plume
#

thank you 0.0

formal agate
#

can anyone help with oauth in js?

amber fractal
#

I do .find('type', 'string') and it works just fine tho

#

🤔

sick cloud
#

@amber fractal it's being removed

#

@formal agate what kind of oauth

formal agate
#

oauth 2 for disocrd

inner jewel
#

i'll assume you're using node-fetch

#

2 minutes in the readme

#

that's the solution for your issue

amber fractal
#

doing it with arrow notation is literally just over doing it, making it harder tbh

sick cloud
#

no

formal agate
#

also Natan, your solution to fixing the code for my oauth token exchange does not work

inner jewel
#

s/find\((\S+), (\S+)\)/find(x=>x[$1] == $2)

formal agate
#

its something in this ```js
let exchange = await fetch(https://discordapp.com/api/oauth2/token, {

  method: 'POST',

  data: {
    'client_id': process.env.CLIENT_ID,
    'client_secret': process.env.CLIENT_SECRET,
    'grant_type': 'authorization_code',
    'code': code,
    'redirect_uri': `http://fdasdfg/api/discord/callback`,
    'scope': 'identify'
  },
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }

});```

#

ooops

inner jewel
#

yes

#

that's wrong

#

if you read the docs, you'll know

formal agate
#

i did

inner jewel
#

data is ignored

formal agate
#

tim had me change part

inner jewel
#

don't expect code copy pasted from a python example into a js thing will work

formal agate
#

ik

#

im not that dumb

inner jewel
#

yet you're doing exactly that

amber fractal
#

Wait were you not talking about discord.js @sick cloud ?

formal agate
#

tim told me the auth in header was pointless

sick cloud
#

@amber fractal no i am, it's being removed from js

amber fractal
sick cloud
#

aka everything

amber fractal
#

Oh

sick cloud
#

so you use a function

inner jewel
#

find(key, value) isn't even a js thing

#

it's a discord.js thing

#

Array#find always required a function

amber fractal
#

Either way I gtg

inner jewel
#

that's just a function

#

array.find(x => ...)/array.find(function(x) {}) are the only things JS has

#

collection.find("somekey", "somevalue") is something discord.js has

#

in it's collection class

proven surge
#

how would i detect upvotes for my bot (in discord.py)

proven surge
#

hm

upper tundra
#

How do I make the bot check if the channel is NSFW? (Discord.NET 1.0.2)

blazing star
#

<Channel>.IsNsfw

upper tundra
#

Okay Thanks

blazing star
#

wait

#

<Channel>.IChannel.IsNsfw iirc

upper tundra
#

Not IChannel though

blazing star
#

what is the channel type?

upper tundra
#

Huh?

#

What does the [RequireNsfw] do though?

blazing star
#

I think it makes the command be for nsfw channels only, I’m not so sure tho

upper tundra
#

But it doesn't work in NSFW channels

blazing star
#

hmm

prime cliff
#

@upper tundra why are you on v1 thats the very old version you need to be on v2

proven surge
#

lol

upper tundra
#

How much do I need to change when I switch to v2?

lilac grail
#

How i can customize my page on DBL...

keen drift
#

with css

lilac grail
#

But i dont know how

#

I tried, but failedf

#

Is there any example?

keen drift
#
<style>
// ... style
</style>
lilac grail
#

AAHHHH

#

Failed again

mossy vine
#

put valid css in the style tag

lilac grail
#

I've been, but why isn't appeared.

#

I use Microsoft Edge, lel.

keen drift
lusty dew
jagged plume
#

await(mMember) isnt valid code, not sure what you're trying to do there

jagged plume
#

args isnt an array

#

might need to look at your command handler setup

#

.join only works for arrays

lusty dew
#

args isn't an array?

jagged plume
#

yes it must not be because it's saying that join isnt a function

slow moth
#

can anyone tell me what to set limit to when i want to get all the logs from a channel. seems to max out at 500 for some reason. if i dont set limit it maxes at 100

modest sorrel
#

You should go to the discord.py server for this stuff

slow moth
#

oh

#

can you send me a link to that?

modest sorrel
#

Sure

#

This server mainly focuses on js

keen drift
#

Debatable, we have plenty of other lang peps

quartz kindle
#

js is just the cool kid of the moment, so everyone here is basically a wannabe js coder

keen drift
#

Cool kid

#

Hue

#

shoot me

jagged plume
#

how can a bot list server focus on js

#

yes lots of people know js but i wouldnt say dbl is js focused lol

lusty dew
#

How can I remove a person from channel permissions after they have been unmuted?

#

My mute command changes the person channel permissions so when the person is muted the perms of all channels change for them so they have the send message perm removed but after being unmuted they stay on the list of people in channel permissions

#

I want them to be removed after being unmuted

amber junco
#

How do I make my bot send gifs and custom emojis in a messages

ruby dust
#

depending on your programming language, there must be a way to send files to discord

#

and emojis can be sent by specifying the full emoji string

blazing star
#

<:name:id>

#

iirc

idle mountain
#

which is done by putting a \ in front of the emote/emoji name
emoji: \🐀
emote: !bingSip

blazing star
#

and there always is a way to send files

#

unless mising perms ofc

knotty steeple
#

iirc you can send files like {files: "urfile.png"}

#

or something like that

#

in discord.js

#

add that as an option on send()

#

or just use an embed and the image property

#
image: {
    url: "https://this.is/my/image.png"
}```
#

@amber junco

lusty dew
#

How do you delete someone from channel perms?

#

So they no longer show on the list

knotty steeple
#

you check the docs

lusty dew
#

I have

#

I can't find what I need

#

Can you point me in the right direction?

knotty steeple
#

no

lusty dew
#

....

#

So much for a help server

#

Smh

#

Im not even asking for code

#

just where I would look at on the docs

knotty steeple
#

idk

lusty dew
#

Ok

#

I can't find anything on it

#

But I have seen other bots do it

earnest phoenix
#

donate

lusty dew
#

donate

#

?

sick cloud
#

what

lusty dew
#

donate what

#

?

sick cloud
#

@lusty dew what lib

lusty dew
#

D.js

sick cloud
#

of course

lusty dew
#

Heh...

sick cloud
#

look at the docs, along the lines of channel overwrites

knotty steeple
#

use eris kthx

sick cloud
#

or ask in the djs server

lusty dew
#

Oh uea

#

I forgot I was in the djs server

sick cloud
#

lul

#

i left

lament meteor
#

same

mossy vine
#

can anyone tell me why this isnt a valid markdown table? it doesnt render properly

**__Word bank:__**
| ---- | ---- | ---- | ---- | ---- |
| JQXZ | QEW  | AC   | ZNY  | TJL  |
| OKBV | DFW  | YKQ  | LXE  | GS   |
| VSI  | PQJS | VCN  | JR   | IRNM |
| OP   | QYDX | HDU  | PKD  | ARGF |```
#

tried putting text above the hyphens

#

and even tried removing them

#

still renders everything as one line D:

#

all fixes tell me to use 3 hyphens with text above them. it still doesnt work

bold dock
#

After each line put 2 spaces (example: **__Word bank:__**[space][space])

#

this will tell Markdown that it should force a new line

#

@mossy vine

mossy vine
#

@bold dock that worked, thank you!

bold dock
#

noice 😃

formal agate
#

I've gotten far enough in the oauth flow of discord to get the following response from discord but idk why I'm not getting a token of any kind. I thought sending the code in the proper format would return a token to be used to access the user data. ``` [Symbol(Response internals)]:

{ url: 'https://discordapp.com/api/oauth2/token?grant_type=authorization_code&code=THE_CODE_WOULD_BE_HERE&redirect_uri=MY_KOOL_HIDDEN_URL_HERE',

 status: 200,

 statusText: 'OK',

 headers: Headers { [Symbol(map)]: [Object] } } }```
earnest phoenix
#

you're misunderstanding the process

i'm going to quickly go over it from the beginning because i don't know where you got that from

okay, so first you are supposed to make a call to /api/oauth2/authorize with the required url parameters (client_id, redirect_uri, response_type and scope), if and when the authorization process is done, it will redirect the user to your redirect url with a url parameter named code.

Then in order to exchange for an access token, you need to make a POST call to /api/oauth2/token with these values in the body; grant_type, client_id, client_secret, redirect_uri and code, they need to match the values that were used in /api/oauth2/authorize, and for code you'd use the code you got in the url parameter.

If the request was successful, you'll get a JSON response which contains a access_token field, you need to cache that access token. access tokens last for a week, so i make my sessions last exactly a week so i don't have to bother with automatic token refreshes. anyways, you'd use that access token in the authorization headers now. for e.g, to get the info about your logged in user you'd call /api/users/@me with the Authorization header set to Bearer accesstoken

bitter sundial
#

replace so first you are supposed to make a call to to so first you are supposed to redirect the user to

modest shore
#

2h work -> lost / broken

zealous veldt
#

rip

modest shore
#

i am just going to recode everything tomorrow

lofty hamlet
#

Hi

#

I have a problem

#
                fonction.channellogs(message)
                var args = message.content.split(' ').slice(1)
                var achievement1 = args.slice(1).join(" ");
                if (!Dresseurs[sender.id]) return message.channel.send("Erreur :Croix: : `Vous devez être un Dresseur pour effectuer cette commande : ?start`")
                var user;
                if (message.mentions.users.first()) {
                    user = message.mentions.users.first();
                    if (Dresseur.Pokedollars >= achievement1) {
                        if (Dresseurs[user.id]) {
                            Dresseur.Pokedollars -= achievement1
                            var DresseurPAY = Dresseurs[user.id]
                            message.channel.send(`__Vous avez envoyé :__ **${achievement1}** à **${user}**`)
                            DresseurPAY.Pokedollars += achievement1
                            message.channel.send(DresseurPAY.Pokedollars - achievement1)
                        } else return message.channel.send("Le membre n'est pas encore dresseur !")
                    }
                    else return message.channel.send("Vous n'avez pas assez d'argent !\n*Il vous manque " + (achievement1 - Dresseur.Pokedollars) + " P$.*")
                }
                else return message.channel.send("Vous devez mentionner un membre !")

            }```
#

My code

#

My code is functional except for the addition of pokedollars to the person mentioned it's completely bored, it adds 0 etc ... Do you want screens?

#

Who can help me ?

amber fractal
#

Wish I could, but I dont even understand the language

lofty hamlet
#

:/

lofty hamlet
#

If i add a number : ex : DresseurPAY.Pokedollars += 1000

#

He fonctionnaly

#

🤔

knotty steeple
lofty hamlet
#

? @knotty steeple

#

My command is over broken

quartz kindle
#

achievement1 is not a number

#

its a string

#

you have to convert it into a number before you can do math

#

Number() or parseInt()

keen drift
#

m e t h

lofty hamlet
#

Mmmmhh @quartz kindle i don't understand everythink

#

So ?

#

But achievement1 works for the - = but not for the + =

keen drift
#

it's prob concating with the latter

lofty hamlet
#

Mmmmhh you can edit my code plz because i don't understand ...

#

Or explain me

keen drift
#

strings can be concated with +=

amber fractal
#

We cant spoonfeed. but I think he means it needs to become a number before you do the math with it.

knotty steeple
#

is it good my memory usage is consistent af

lofty hamlet
#

So ?

knotty steeple
#

its like always 35mb

amber fractal
#

Idek how to check mine so I can say... Yes!

prime cliff
#

35mb ram for a bot LUL

knotty steeple
prime cliff
#

Wait till it gets added here and cache breaks

knotty steeple
#

its already here

prime cliff
knotty steeple
#

@woeful saffron

amber fractal
#

I had to turn off my console logging for messages being deleted lol

knotty steeple
#

i mean i use eris so mmspin

lofty hamlet
#

How should I do it? @keen drift ?

keen drift
#

convert it a number

lofty hamlet
#

How ?

faint junco
#

Okay so! I am creating a giveaway command, however, the bot is able to win sometimes. I don't want that to happen but even when I specify that in the filter, it still picks the bot!

client.channels.get(config.channels.giveawayChannelID).send({embed}).then(msg => {
  msg.react("🎉");
  const filter = (reaction, user) => reaction.emoji.name === '🎉' && user.id !== client.user.id;
  const collector = msg.createReactionCollector(filter, { time: 10000 });
  collector.on('collect', r => console.log(`Collected ${r.users}`));
  collector.on('end', collected => console.log(collected.map(r => r.users.random().tag)));
})
``` JavaScript
knotty steeple
#

parseInt

lofty hamlet
#

I have never used a parseint @keen drift ...

knotty steeple
#

literally

#

parseInt("e")

keen drift
#

parseInt(s: string, radix?: number): number

lofty hamlet
#

So : i can : parseInt(achievement1) ?

#

I don't understand 🤔

amber fractal
#

@faint junco You could just have it so i the winner is a bot to reroll, not the best way but a way

faint junco
#

Hm, makes sense. Thanks!

inner jewel
#

filter all bots instead

#

then pick a random

amber fractal
#

He said even when it's filtered it doesnt work

inner jewel
#

rerolling if the winner is a bot would kill your cpu if all users are bots

#

users.filter(u => !u.bot).random()

lofty hamlet
#

parseInt(achievement1) is fonctionnaly

#

Thanks @keen drift ❤

#

And how i can verify if achievement1 is a number ?

keen drift
#

typeof achievement1

lofty hamlet
#

?

#

What ?

inner jewel
#

npm install is-number

keen drift
#

@inner jewel nooooooooooo

knotty steeple
#

pls

#

isNaN

#

if not nan is number

keen drift
quartz kindle
#

@lofty hamlet ```js
5 + 5 = 10 // number + number = number
5 + "5" = "55" // number + string = string
5 - 5 = 0 // number - number = number
5 - "5" = 0 // number - string = number

knotty steeple
keen drift
lofty hamlet
#

Hu ?

amber fractal
lofty hamlet
#

What is this ?

quartz kindle
#
5 //this is a number
"5" // this is a string (text)```
amber fractal
lofty hamlet
#

Ah ok

#

I understand

#

How i can verify if achievement1 is a number also i return for write a error message

knotty steeple
#
keen drift
#

typeof thing === 'number'

lofty hamlet
#

So : if (achievement1 != 'nuber') return ?

inner jewel
#

typeof(thing)

quartz kindle
#
parseInt("5") // 5
Number("5") // 5
(5).toString() // "5"```
keen drift
#

confuzz8led

amber fractal
#

typeof thing works too doesnt it?

quartz kindle
#

he doesnt need to check if its a number, he needs to convert it to a number

#

because discord will always give you a string

amber fractal
#

he wants to make sure if the input isnt a number at all then it returns something

quartz kindle
#

the input will never be a number

inner jewel
#

^

lofty hamlet
#

if (achievement1 != 'number') return

#

Not work

inner jewel
#

it will never be a number

quartz kindle
#

someone explain to him in french lol

lofty hamlet
#

I understand

#

So ?

#

If a personn write ?gift @earnest phoenix NOTNUMBER my bot crash

keen drift
#

if baguette is not a baguette

#

then you need to turn it into a baguette

knotty steeple
#

i love that