#development

1 messages · Page 1504 of 1

slender hamlet
#

if it doesnt exist, return an error message

#

yes

lusty quest
#

if you mention the channel you can get the channel id from the mentioned channel

slender hamlet
#

you can also do #channel

#

and parse the id from the mention

lament rock
#

Like they mentioned, GuildChannelManager.delete isn't a function. get the instance from cache and call instance.delete

slender hamlet
solemn leaf
#

now I get thic

#

(node:15968) Warning: Accessing non-existent property 'func' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)

slender hamlet
#

you'd probably do message.guild.channels.cache.get(msgArgs[0])

#

itll return a promise of a channel

earnest phoenix
#

hey hello can you put the shard in discord.py and you can explain me how to put them

lament rock
#

get the channel from cache and call channel.delete

slender hamlet
#

then once the promise is resolved, itll return a channel

lament rock
slender hamlet
#

ah my bad

#

cache.fetch does

lusty quest
#

but there is no need to fetch

slender hamlet
#

yeah

#

ik

lament rock
#

Collection<string, GuildChannel>.fetch is not a function

earnest phoenix
#

?

slender hamlet
#

youll have to iterate through the cache

lament rock
#

Looks good

lusty quest
#

i mean you probably could wrap the get into a Promise function and then call the function, but its stupid

earnest phoenix
#

HELP ME PLS

lament rock
#

Making a Map based cache op async is stupid

slender hamlet
#

lol

earnest phoenix
#

help me

#

No command called "me" found.

slender hamlet
#

ik thats what you were saying

earnest phoenix
#

hey hello can you put the shard in discord.py and you can explain me how to put them

lusty quest
#

there are 2 ways to shard your client @earnest phoenix

solemn leaf
#

ok

lusty quest
#

this will spawn a new Process with the shard running on it

solemn leaf
#

so its not my node

lusty quest
#

the other method will use a worker to spawn more shards

solemn leaf
#
URL = match ? `https://cdn.discordapp.com/emojis/${match[2]}.png` : emojiMap.emojiDefinitions.find(x => x.surrogates === mB[1]).assetUrl || message.attachments.first().url || mB[1];
#

the last or of the thing should be running

slender hamlet
#

you could probably do a message.guild.channels.cache.resolve(msgArgs[0])

solemn leaf
#

not the emojimap

slender hamlet
#

correct me if im wrong

#

oh wait

solemn leaf
#

@pale vessel

lusty quest
pale vessel
#

?

lament rock
earnest phoenix
#

is this shard okay?

pale vessel
#

you removed the ? i added

lusty quest
solemn leaf
#

i dont think I did

lusty quest
solemn leaf
#

show me where it was

earnest phoenix
lusty quest
#

did you placed the shard manager in a different file from your bots main file?

earnest phoenix
#

yes

lusty quest
#

ok and inside the new ShardingManager set the path to your bots main file

lament rock
#

I suggest looking at the source. iirc, there is no distinction from internal sharding and ShardingManager. ShardingManager uses internal sharding. The easiest way to test this is if both shards can log to the same console

solemn leaf
#

ok

lusty quest
#

iirc there is a difference between Internal Sharding and the Sharding Manager

lament rock
#

internal and via IPC is only distinct in Eris

lusty quest
lament rock
#

They were talking to me about that statement

lusty quest
#

if your bot main file is called index.js change bot.js to index.js

solemn leaf
#

ah ok

lusty quest
#

Internal sharding is on the Same process and Sharding manager uses Worker threads.

lusty quest
earnest phoenix
#

client.shard

lusty quest
earnest phoenix
#

bot.js

lusty quest
#

how is your sharding manager file called?

lament rock
#

worker_threads is within the same process. There is no "cluster" based sharding where events from all shards are forwarded to a single client to manage the cache and worker tasks.

earnest phoenix
lament rock
#

Also, is that Eris docs?

lusty quest
#

ok and they are in the same folder?

#

anidiotsguide

solemn leaf
#

How can I make an image transparent on canvas

solemn latch
#

the same basic idea of internal and external sharding is true for all libs

lusty quest
#

ok if you want to start the bot with shards start index.js without sharding use bot.js

lament rock
#

I don't believe that's up to date with how discord.js manages sharding unless I missed something when I read through the ShardManager code

earnest phoenix
#

this is work?

lusty quest
#

yes?

#

it spawned 1 shard

#

bcs its in auto mode

earnest phoenix
#

1 shard that's enough?

misty sigil
#

yes

#

until 2500 servers

lusty quest
#

if you want to set a certain amount of shards pass the totalShards: "auto or number of shards" in your Sharding Manager constructor

#

discord suggest to start sharding at 1k guilds

earnest phoenix
#

ok

lusty quest
#
    // for ShardingManager options see:
    // https://discord.js.org/#/docs/main/v12/class/ShardingManager
    totalShards: 'auto',
    token: 'YOUR_TOKEN_GOES_HERE'
});```
earnest phoenix
#

I just wanted to test I deactivate it now and activate it soon

lusty quest
#

it requires some other modification on certain stuff tho

#

bcs not all things are shared between the shards

lament rock
#

Oh. I guess the default is still using worker_threads but shards having separate caches. I didn't realized there was a mode specification

#

So I guess we were both correct in our own regards

lusty quest
#

probably

#

if i would hit the region of the need to shard i would probably Modify the lib i use to have a shared cache for all shards

earnest phoenix
#

sorry

lament rock
#

That's what I do currently. Sort of. I just have one logical processor for all gateway events for all shards within a cluster

lusty quest
#

lol fill it in yourself

#

i had the idea to use Redis for a unified cache

lament rock
#

Discord object caching is still handled in Redis though

solemn leaf
#

How can I make the background be transparent

lament rock
#

Redis caching is stronk

solemn leaf
#

ctx.fillStyle = "white";

lusty quest
#

sure will be a bit slower than directly in memory but still less headache then using Brodcast eval

earnest phoenix
#

okay i'm only left with one shards

lament rock
#

You should check to make sure you're sending the file to Discord or wherever as a png since discord.js defaults to jpg

solemn leaf
#

so wait

#

just remove the filltype

lament rock
#

What are you drawing onto the canvas?

solemn leaf
#
    let invertCanvas = canvas.createCanvas(image.width, image.height);
    let ctx = invertCanvas.getContext("2d");
    ctx.drawImage(image, 0, 0, ctx.canvas.width, ctx.canvas.height);
    ctx.globalCompositeOperation = "difference";
    ctx.fillStyle = "white";
    ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
#

its invert

lament rock
#

Does the input image you're drawing onto the ctx have transparency

solemn leaf
#

yes

pale vessel
#

loop through the image data, invert the color and put the new image data

solemn leaf
#

its

#

🙂

#

that im inverting

lament rock
#

Ah. The svg should have transparency then

solemn leaf
#

it doesnt

lament rock
#

Try flaze's suggestion. Perhaps it's a lower level issue when it comes to decoding SVGs

solemn leaf
#

how do I do that lol

#

volt shut me down

lament rock
#

@pale vessel ?

solemn leaf
#

I was gonna do buffer

lament rock
#

For context, I don't use node-canvas

solemn leaf
#

me neither

#

I use nothing

lament rock
#

so I can only help so much

pale vessel
#

i'm not sure if it works for inverting, i only used it for recoloring the entire image

solemn leaf
#

what did you do>?

pale vessel
#

br

#

well never mind

#

I use graphicsmagick anyway

solemn leaf
#

yeah I was doing soemthing liek that

#

yesterday

#

not cap

#

and volt shut me down

lament rock
#

If they shut you down for being too much of a noisey neighbor, you should probably not use image manipulation.

solemn leaf
#

what lol

#

I just asked him to eval it bcs my bot was down

lament rock
#

Oh. I thought volt was some provider or something

solemn leaf
#

voltron

lament rock
solemn leaf
#

voltrex

lament rock
#

Ah. Now that name rings a bell

solemn leaf
#

master mobile developer

#

well

#

imma work on decompiling gifs

#

imma do switch

#

@pale vessel

#

can I do this

#
URL = match ? `https://cdn.discordapp.com/emojis/${match[2]}.png` || `https://cdn.discordapp.com/emojis/${match[2]}.gif` : ...
pale vessel
#

Nope

open flicker
#

how can you exclude 0 from the loop when there are two 0 and 1 in the array

module.exports.fetchAPI = async function (url) {
    const response = await axios.get(url)

    let image = response.data

    const count = Object.keys(image).length

    for (let i = 0; i < count; i++) {
        return Object.values(image)[i]
    }
}```
pale vessel
#

you need :

lament rock
#

decoding gifs is a cheap task, but if you wanna encode, good luck lol

pale vessel
#

i misread

solemn leaf
#

@lament rock I found a good npm

pale vessel
#

aaa never mind

solemn leaf
#

I can just loop it

pale vessel
#

it works, but not the way you intend it to

solemn leaf
#

how do I make it work the way I intend it to

pale vessel
#

Check if the regex matched a before the first :

#

if so, change png to gif

#

you can't use ||

#

that makes no sense and it will never fallback to that since the first string will always be truthy

solemn leaf
#

I mean if the custom emoji was a gif

pale vessel
#

yes

lament rock
#

obviously replace thing with whatever can be 0 or 1

solemn leaf
#

goes a mean soemthing?

lament rock
#

animated

solemn leaf
#

ok

solemn leaf
#

so I could need a different regex?

#

or a new if??

pale vessel
#

you can wrap the a with ()

solemn leaf
#

for what

#

const match = mB[1].match(/^<(a)?:(\w+):(\d+)>$/);

pale vessel
#

can you show me your regex

#

ah

lament rock
#

the same concept applies for user avatars btw, avatars which have gif formats start with a_

solemn leaf
#

doesnt the format for the avatar webm

lament rock
#

discord.js defaults to webp

solemn leaf
#

so I cant really do much to check if it is a gif or png

lament rock
#

webm is not a supported file extension for avatars

solemn leaf
#

ok

#
message.author.displayAvatarURL({
        dynamic: true,
        size: 1024,
        format: 'png'
    });
#

if the user has an animed pfp

pale vessel
#

if it's undefined, then it's not a gif

lament rock
#

if (message.author.avatar.startsWith("a_")) // user has animated avatar

pale vessel
#

so something like ```js
URL = match ? https://cdn.discordapp.com/emojis/${match[2]}.${match[1] ? "gif" : "png"} : a || b || c;

solemn leaf
#

can you explain this to me lol

#

the ? and :

lament rock
#

? and : is a ternary expression.
boolean value ? code to do if boolean is true : code to do if boolean is false

solemn leaf
#

o

mellow kelp
#

condition ? [if true] : [if false]

#

its like an inline if statement

solemn leaf
#

okay well that helps

#

how do I check if its a gif

#

Imma use a switch to switch between gif and png

lament rock
#

match[1] is the result of the first capture group if the a is in the emoji. If a was not present in the string between the < and : then it will be undefined

wheat mesa
#

Ok so I've been testing some code recently for a test bot I'm messing around with, and I can't seem to properly make a json file. I can get my code to read from it and write to it, but every time I want to add something to the json file it just rewrites the old json file with the new content. Here's my code: ```js
if(command == 'new') { // w!new
commandArg = message.content.indexOf(' ', 7)
commandStr = message.content.substring(6, commandArg)
commandSay = message.content.slice(commandArg+1)

  var dataobj = {}
  dataobj.CustomName = commandStr
  dataobj.CustomPhrase = commandSay
  const JSONString = JSON.stringify(dataobj, null, 2)
  fs.writeFile('CustomCommands.json', JSONString, (err) => {
    if (err) {
      throw err
    }
    console.log('JSON successfully saved')
  }
)

}

fs.readFile('CustomCommands.json', (err, jsonStringlocal) => {
if(err) {
throw err
}
const CustomNameCommand = JSON.parse(jsonStringlocal)
if(command == CustomNameCommand.CustomName) {
message.channel.send(\``${CustomNameCommand.CustomPhrase}````)
}
}
)

lament rock
#

the ternary expression is for if the result of that capture group is not undefined, then its a gif

#

You need to assign new data to the Object you parse, then stringify the Object and write the string back to the JSON

wheat mesa
#

So parse the JSON and add what I need in the variables and then stringify it back into a json?

lament rock
#

Also, I think your code might be susceptible to race conditions if you're writing and it does properly write but the read doesn't show that new data. You might wanna use the sync methods which don't take callbacks or you put subsequent code within the callbacks

wheat mesa
#

So use readFileSync and writeFileSync instead

solemn leaf
#

so

lament rock
#

Yeah. That'll pause the thread until those IO ops finish

solemn leaf
#

if (message.author.avatar.startsWith("a_") || URL.endsWith(".gif)) {.}

slender hamlet
#

I'm not sure if this is practical, but you might want to consider using a database if you want to regularly read and write to and from something

#

Again, that's up to you

#

Talking to Waffle, FYI

lament rock
solemn leaf
#

if (message.author.avatar.startsWith("a_") || URL.endsWith(".gif)) { type = "gif" }

snow urchin
slender hamlet
#

in cant be used there

#

its a snowflake value

#

not a list

lament rock
#

fun fact, you don't need curly braces after if statements unless you're doing multiple lines if a condition a met

slender hamlet
#

yeah

#

if you just want to do one line it can literally be
if (condition) doMyStuff()

#

doesnt have to be a method

ornate otter
#

@lament rock would you mind if i dm'ed you

lament rock
#

Why would that be necessary

ornate otter
#

its about your bot i wanted to ask a question about it

wheat mesa
slender hamlet
#

alrighty

lament rock
#

Okay

slender hamlet
#

still an option, up to you

drifting wedge
#

guys, this is good? py memberCount = 0 for g in self.client.guilds: for user in g.users: memberCount += 1

#

it wont break anything?

solemn leaf
slender hamlet
#

self.client.guilds returns a guildmanager

#

you could do self.client.guilds.forEach((g) => { //do stuff })

pale vessel
#

Pretty sure it returns a list of guilds the clientis in

lament rock
#

That's Python isn't it

pale vessel
#

it is

drifting wedge
#

YEEE

slender hamlet
#

my bad

pale vessel
#

why not g.member_count?

drifting wedge
#

ig i dont have member intent

pale vessel
#

you don't need it

solemn leaf
#

How do I loop throu an array

slender hamlet
#

js?

solemn leaf
#

yes

lament rock
#

member_count is always sent over GUILD_CREATE. It's an approximate

slender hamlet
#

aki

#

for (let x of array) {}

drifting wedge
#
            for g in self.client.guilds:
                memberCount + g.member_count```
pale vessel
#

+=

slender hamlet
#

for (let i = 0; i < array.length; i++) {}

lethal ginkgo
#

so i have this little image problem ^^" my long discription is approximately
<div>
<div class = "image"> </div>
</div>

earnest phoenix
#

sum exists

slender hamlet
#

either works @solemn leaf

drifting wedge
#

wait why not just +?

pale vessel
#

you're not doing anything to memberCount

lament rock
#
  • doesn't mutate the state of a variable
slender hamlet
#

let x of array gives you an x which is the item at any particular index

drifting wedge
solemn leaf
#

for (var i = 0; i < frameData.length; i++) { }

slender hamlet
#

ok

#

that should be fine

#

i'd recommend let instead of var in a for loop initializer

pale vessel
#

like cry said, you can use sum() and [g.memberCount for g in client.guilds]

#

i think that's the syntax

drifting wedge
slender hamlet
#

otherwise if you uses a var called i earlier on it can mess with it

#

and its generally good practice

pale vessel
#

you're not modifying the variable

#

a one liner would be better though

slender hamlet
#

yeah you have to do += to actually update the value of the variable

drifting wedge
#

i did

#

oh

#

sorry

#

wrong thing

solemn leaf
#

idk

drifting wedge
#

i did it as +=

lament rock
#

use const over let if you don't reassign the value of the variable. That's practically the only way to get "statically typed js". With that comes it's own performance benefits. let implies type reassertion

solemn leaf
#
            let images = []
            gifFrames({ url: URL, frames: 0 }).then(function (frameData) {
                //frameData[0].getImage().pipe(fs.createWriteStream('firstframe.jpg'));
                for (var i = 0; i < frameData.length; i++) {
                    let image = await canvas.loadImage(frameData[i]);
                    let invertCanvas = canvas.createCanvas(image.width, image.height);
                    let ctx = invertCanvas.getContext("2d");
                    ctx.drawImage(image, 0, 0, ctx.canvas.width, ctx.canvas.height);
                    ctx.globalCompositeOperation = "difference";
                    ctx.fillStyle = "white";
                    ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
                    images.push(ctx.canvas.toBuffer())
                }
            });
#

const can tbe cahnged

#

what you mean

lament rock
#

I know. If you don't reassign the value of a const, use it over let

slender hamlet
#

obv with i = 0; i++; you're modifying i so that will be let

lament rock
#

getting as close as possible to statically typed is good

solemn leaf
#

wait

#

do I just remove the await

#

let image = await canvas.loadImage(frameData[i]);
^^^^^

SyntaxError: await is only valid in async function

lament rock
#

make the function you're calling that in async

#

function thingy(params) {
const thing = await code(params); // not valid
}

async function thingy(params) {
const thing = await code(params); // valid
}

solemn leaf
#

gifFrames({ url: URL, frames: 0 }).then(async function (frameData) {

lament rock
#

sure

solemn leaf
#

is it wrong?

lament rock
#

No

#

That is valid syntax

#

I would have use arrow functions, personally, but we all have our own styles

solemn leaf
#

ohh

#

I jsut copied from the doc

lament rock
#

thats fine

#

arrow functions are es6. If a lib supports node versions earlier than when arrow functions were added, they would have to use that

pale vessel
#

are you going to loop through the frames and use gifencoder

lament rock
#

Passing it an Array of all the frames can cause the heap to run out of free space depending on the size of the gif

slender hamlet
#

basically all that's different is that instead of it being function (abc) {} it would be (abc) => {}

#

regarding arrow functions

pale vessel
#

you can't access this in anonymous functions

solemn leaf
#

?

pale vessel
#

and no arguments

solemn leaf
#

do I use arrow

#

or no

pale vessel
#

sure

slender hamlet
#

you dont need to

#

but you can

pale vessel
#

doesn't matter in this case

lament rock
#

You're fine either way

#

just a preference

solemn leaf
#

ill just do what the docs did

#

can I buffer.from() to make it a gif

pale vessel
#

not like that]

solemn leaf
#

ok

#

flaze

lament rock
#

If I regularly evaluated this, that would be the return value as well

#

Well. Amanda handles Promises, so I shouldn't have added the async, but whatever

wheat mesa
#

So I've been trying to fix this code, but I just can't get it to work

#

I started using fs.appendFile and it's getting close, but it's still improper

slender hamlet
#

you might have to append a \n after

#

at the end

lament rock
#

,\n

slender hamlet
#

right

wheat mesa
#

How would I do that?

lament rock
#

commas are important in JSON

solemn leaf
#

how should I encode the gif

slender hamlet
#

fs.appendFile(jsonObj + ", \n")

#

my guess

lament rock
#

that's the error causing the parsing to fail

pale vessel
#

it seems to depend on how you call it

lament rock
#

PLEASE JSON.stringify the Object before you write. JSON.stringify handles the commas for you. Improperly managing commas can be catastrophic

lethal ginkgo
#

could someone pls help me with html/css for long bot description? qwq

slender hamlet
#

sure, why not

#

you can actually use bootstrap too

pale vessel
slender hamlet
#

speaking of which, I used bootstrap for my bot description but I want to force dark theme, what do I do?

#

it's not recognizing it as "advanced css" or whatever it said

pale vessel
#

this in that context is the global object and not an instance of CanvasRenderingContext2D

lament rock
#

assigning to the prototype implies it's a static method. this would not be defined in context to the class

solemn leaf
#

flaze

#

the url is broken again

lethal ginkgo
solemn leaf
pale vessel
slender hamlet
#

the one you sent?

#

i'd assume its a simple <img src="url_to_image"> like any other image

lethal ginkgo
#

the one which is at bottom of the site for no reason qwq

slender hamlet
#

I'm confused... which one? Sorry if this is annoying I just don't know what image you mean

#

regardless, it should be as simple as an img tag

pale vessel
wheat mesa
#

After putting in ", \n" the comma is still wrong

slender hamlet
#

ah

slender hamlet
lament rock
#

use JSON.stringify like I mentioned

slender hamlet
#

ah right

lament rock
#

not adding content after a comma is improper management

#

JSON.stringify handles commas for you

wheat mesa
#

I am using JSON.stringify

lament rock
#

Then don't add the ,\n

formal ridge
#

ض

#

a

solemn leaf
#

why didnt it work

#

it didnt do the gif

#

when this is a gif

#

@pale vessel this no workie

URL = match ? `https://cdn.discordapp.com/emojis/${match[2]}.${match[1] ? "gif" : "png"}` : emojiMap.emojiDefinitions.find(x => x.surrogates === mB[1])?.assetUrl || message.attachments.first()?.url || mB[1];
wheat mesa
#

I tried using stringify normally earlier

#

This is the result

pale vessel
#

log the url

quartz kindle
lethal ginkgo
solemn leaf
#

@pale vessel

pale vessel
#

log URL

wheat mesa
solemn leaf
#

that was url

slender hamlet
#

message.attachment.first().attachment seems to give a url

quartz kindle
lament rock
#

I was mentioning earlier that you need to assign data to the old object then stringify the old object with the new data and write that

solemn leaf
#

they both give one

quartz kindle
#

you need to read the json file, convert it to object, add the data to the object, stringify it again, and save the full file again

solemn leaf
#

I used .url bcs doc

wheat mesa
#

ugh

slender hamlet
#

whoops i meant url

solemn leaf
#

flaze

quartz kindle
#

thats why json is heavily not recommended for usage as a database

pale vessel
#

sungl

solemn leaf
#

it should be 0938906189057190875

#

liek that

#

or soemthing lol

lament rock
#

ENOMEM waiting to happen

earnest phoenix
#

🗿 Memory leak

quartz kindle
#

voltrex leak

lament rock
#

JSON is memory leak confirmed

wheat mesa
lament rock
#

Since it's so small, JSON is fine

wheat mesa
#

Alright

solemn leaf
#

@pale vessel can you fix the attachments one

slender hamlet
#

I think regardless of size you should still maybe use a db, but again up to you

quartz kindle
#

could also use a simple delimited text file

#

you can append to that

slender hamlet
#

that too

#

i used to use csv... not great but not horrible

quartz kindle
#

if its something small, you can use json, but keep it also loaded in memory

#

only write when you need to change it

#

and only read once at startup

solemn leaf
#

killed chat

slender hamlet
lament rock
#

You need to put CSS in your long description

slender hamlet
#

I would like to force a theme but I'm using bootstrap

solemn latch
#

use css if you want a forced theme

slender hamlet
#

I'm using css

#

just an external ss

pale vessel
#

adds the word CSS in description

slender hamlet
#

lmao

#

i'll just add an empty style tag lmao

pale vessel
#

pretty sure it checks for style tag

slender hamlet
#

wonder if itll work

pale vessel
#

probably

solemn leaf
#

flaze

pale vessel
#

i asked xetera and he said he checked for that

solemn leaf
#

attachments broke

solemn latch
#

yeah it just checks for style tags

limpid bear
#

how do i get it. where a command will have reactions, and if the user his one of them, it will change the message

slender hamlet
#

LMAO it worked

slender hamlet
#

be sure to react to the message before awaiting reactions via message.React(emoji)

limpid bear
#

thanks

slender hamlet
fervent goblet
#

anyone know how to get the current position a track is in using the spotify presence?

slender hamlet
#

as in viewing a user's status and seeing what pos they're at?

fervent goblet
#

yes

slender hamlet
#

in that song?

#

hm

solemn latch
#

probably just regex it

slender hamlet
#

yeah

fervent goblet
#

what would i "regex"?

solemn leaf
#

you have to do math

#

not regex

solemn latch
#

i didnt realize they gave a timestamp, thought it was a string pogey

fervent goblet
#

does the start time start where they are in the song or is it the beginning of the song tho?

pastel horizon
#

eyo! I would like know how to do modif for doing a bot to a public bot
Can someone help me ?

#

You know, I did an bot but it's like if their is the mute command.... The client will can't have the command. So ,I'm trying to know how to put my bot with the modif ...

fervent goblet
#

modif?

#

you mean settings?

pastel horizon
#

Nah

solemn latch
#

@fervent goblet looks like the start time

pastel horizon
#

Like put the request of the client to put or no a mute command.

#

for exemple

fervent goblet
#

so what would i need to use to calculate the current pos?

pastel horizon
#

...for the welcome message...

slender hamlet
#

do the same for the starttimestamp

#

then subtract

fervent goblet
#

ah

#

ok

#

ty

slender hamlet
#

to convert to a number, use the date library

#

i think you can say const start = new Date(usrActivity.timestamps.start);

#

otherwise just look up the format

#

im fairly certain tho

limpid bear
#

i been messing around with the add reaction code. but i cant get it to react to the bot message, it only reacts to the users

solemn latch
#

you're reacting to your input message, not the message you sent

#

save the sent message in a variable(with the promise awaited) then react to that message

slender hamlet
#

you would say const botMessage = await message.channel.send("xyz");

#

then to react you'd do botMessage.react('👍');

trim saddle
#

@lament rock fecking

#

websockets went wonky on me

lament rock
#

mood

lament rock
trim saddle
#

package stopped importing right

earnest phoenix
pale vessel
#

Ok

trim saddle
#

omg

#

tsconfig hurts

earnest phoenix
slender hamlet
#
  1. I'll do it tomorrow
gilded olive
earnest phoenix
#

-1. I'm too tired rn

mellow kelp
#

-2. I'm not being paid enough

slender hamlet
#

-3. OH MY GOD I AM AN IDIOT I FORGOT TO PUT COMMAS

earnest phoenix
#

-4. welp, stack overflow here i come

sinful belfry
#

this is not the channel for memes....

earnest phoenix
slender hamlet
#

feelsbadman

sinful belfry
#

it pretty much is a meme

slender hamlet
#

yeah starman's right

regal creek
earnest phoenix
#

wrong one

#

Do y'all know when discord is actually going to properly implement slash commands for bots?

gilded olive
#

never

regal creek
#

What

gilded olive
#

probably in a few months

#

but for anyone to actually use it

#

eh maybe a year

#

unless they fix it fast

regal creek
#

Wtf will slash commands help with

pale vessel
#

Properly? You can already implement it

earnest phoenix
pale vessel
#

You mean like a UI for it?

earnest phoenix
#

he's using it for a translate command

pale vessel
#

I see

gilded olive
#

Not just becaue it can be used means it's good

earnest phoenix
#

@regal creek

swift cloak
trim saddle
#

although discord hasn't made a way to fetch members

#

so it's just best that you use id

pale vessel
#

What

trim saddle
#

you can't get members like you could with a regular command handler

pale vessel
#

Ah yeah

#

They only give you the id

trim saddle
#

now shut up flaze

#

trying to figure out how to get member permissions

pale vessel
#

Compare the bits

trim saddle
#

how

earnest phoenix
#

hi hi

misty sigil
#

using a bit comparison machine

earnest phoenix
trim saddle
#

ew

#

i'm not working on d.js

earnest phoenix
#

oh lol

trim saddle
#

i'm making my own lib

earnest phoenix
#

my bad

solemn leaf
sudden geyser
#

You could see Discord.js' implementation.

solemn leaf
#

?

#

@sudden geyser

sudden geyser
#

Not you.

solemn leaf
#

oh

sudden geyser
#

But you should explain what you need help with.

#

What about the package.

solemn leaf
#

here is my code

#
            gifFrames({ url: URL, frames: 0 }).then(async function (frameData) {
                console.log(frameData[0].frameInfo)
                const encoder = new GIFEncoder(frameData[0].frameInfo.width, frameData[0].frameInfo.height);
                encoder.start();
                encoder.setRepeat(0);   // 0 for repeat, -1 for no-repeat
                encoder.setDelay(frameData[0].frameInfo.delay);  // frame delay in ms
                //frameData[0].getImage().pipe(fs.createWriteStream('firstframe.jpg'));
                frameData.forEach(async function (frame) {
                    let image = await canvas.loadImage(frame.getImage());
                    let invertCanvas = canvas.createCanvas(image.width, image.height);
                    let ctx = invertCanvas.getContext("2d");
                    ctx.drawImage(image, 0, 0, ctx.canvas.width, ctx.canvas.height);
                    ctx.globalCompositeOperation = "difference";
                    ctx.globalAlpha = 1.0;
                    ctx.fillStyle = "white";
                    ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
                    encoder.addFrame(ctx);
                });
                encoder.finish()
                const buf = encoder.out.getData();
#

the buffer is right

#

but when I send it

#

supposed to be a gif there

solemn leaf
neon condor
#

how do you dashboard a discord bot?

earnest phoenix
#

you just make a dashboard and code it into your bot

twilit geode
#

is there a way to see when a bot was uploaded to topgg

#

I think someone stole my bot's identity

earnest phoenix
#

F

twilit geode
#

I want to see when they posted their bot

twilit geode
earnest phoenix
twilit geode
#

im looking rn

earnest phoenix
#

How did you find out about this identity thief

twilit geode
#

I was getting the link to my bot for a url shortener

#

and I just searched for it on topgg

#

and there were two...

#

just one was a white avatar instead of an orange one

neon condor
#

give me a hand to make my dashboard for my bot there any videos on yt?

twilit geode
#

@drowsy sentinel

neon condor
#

give me a hand to make my dashboard for my bot there any videos on yt?@misty sigil

misty sigil
#

bRo?

gilded olive
#

not how it works

neon condor
#

Ma ce qualcuno italiano o devo usare google XD

gilded olive
#

english

#

anyways

#

it's just http requests

#

with some oauth2

neon condor
#

how do you dashboard a discord bot?

earnest phoenix
#

Bruh google it if no body answers

gilded olive
#

You make a dashboard

#

but instead

#

you connect it with ouath

neon condor
#

Gz

misty sigil
#

if you don't know how to make a dashboard

#

you probably shouldn't be making one

earnest phoenix
#

^^^^^^^^^^^

misty sigil
#

it requires extensive knowledge of

  • http requests
  • web frameworks
  • frontend development
  • db interactions
    and a shit ton more
gilded olive
#

you don't have to use a framework

earnest phoenix
misty sigil
#

eh you'd be best to

gilded olive
#

true

misty sigil
#

i guess you could make a dash in ejs or somethin similar

#

it'd be a pain tho

gilded olive
#

o

solemn leaf
#

can i gets helps

solemn latch
#

using gif encoder 1 🤔

solemn leaf
#

?

solemn latch
#

gifencoder 2 is so much better

solemn leaf
#

what

solemn latch
#

gifencoder is slow

#

gifencoder 2 can be several times faster

#

also, looks like your foreach is async, which means its not running until after you do encoder.finish

solemn leaf
#

ohhhh

#

what should I do then

quartz kindle
#

async forEach is a very bad idea

#

you'll likely get frames mixed up in the middle

misty sigil
#

make foreach sync

solemn latch
#

when i used gifencoder i would use promise.all

#

for loading frames

solemn leaf
#

what im confused

earnest phoenix
#

for best performance you can also avoid forEach and do a normal for loop

quartz kindle
#

still a bad idea

#

does the gif encoder know which frame is supposed to go where? do frames have indexes or something?

solemn leaf
#

uh

#

yes

quartz kindle
#

or does it just push frames like you would push items into an array?

solemn leaf
#

1 sec

solemn latch
#

you push frames

solemn leaf
#

frameData[x].frameIndex

quartz kindle
#

because if you push frames, you have to do it sequentially

#

doing it concurrently will not guarantee frame order

#

async forEach is concurrent, not sequential

#

Promise.all() is also concurrent

solemn leaf
#

I needed async for the await

quartz kindle
#

use async outside

#

and use a nomal for loop

solemn leaf
#

how should I do the loop

#

I was doing this

#

but I didnt think it worked

#

for (var i = 0; i < frameData[i].getImage().data_length; i++) {

quartz kindle
#

isnt that for getting frames? not for adding them?

solemn leaf
#

idk exactly

#

its for looping through the array of frames?

quartz kindle
#

Pure JavaScript tool for extracting GIF frames and saving to file

#

thats only for reading gifs, not creating them

solemn latch
#

yeah hes using gif-encoder

solemn leaf
#

that is why I have the encoder

solemn latch
#

why does promise.all not work for loading the images?

quartz kindle
#

so you're reading from one gif and enconding it in another? like a gif transformer

#

there is a way to do it concurrently

solemn leaf
#

yes

quartz kindle
#

but you need to change your code a bit

solemn leaf
#

but im editting each frame

#

kk

#

what should I do

quartz kindle
#

you can use an async map

#

with Promise.all()

#

but you cant use encoder.add() inside it

#

you have to use encoder.add() in the end, after all frames are done

solemn leaf
#

ok

solemn latch
#

yeah, all editing and adding of frames after loading them with promise all.

solemn leaf
#

what

quartz kindle
#
promises = frames.map(async frame => {
  // do async transformation here
});
transformed = await Promise.all(promises);
transformed.forEach(frame => {
  encoder.addFrame(frame)
});
solemn leaf
#

so wait

#

I dont have any of these values

#

frames isnt a thing

quartz kindle
#

frames is whatever you get your frames from

solemn leaf
#

frameData

quartz kindle
#

frameData

solemn leaf
#

so I could put the canvas stuff in there?

quartz kindle
#

let me look at your code again

solemn leaf
#
promises = frameData.map(async frame => {
  // do async transformation here
        let image = await canvas.loadImage(frame.getImage());
        let invertCanvas = canvas.createCanvas(image.width, image.height);
        let ctx = invertCanvas.getContext("2d");
        ctx.drawImage(image, 0, 0, ctx.canvas.width, ctx.canvas.height);
        ctx.globalCompositeOperation = "difference";
        ctx.globalAlpha = 1.0;
        ctx.fillStyle = "white";
        ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
});
transformed = await Promise.all(promises);
transformed.forEach(frame => {
  encoder.addFrame(frame)
});
#

tim died

solemn latch
#

hes a busy man

solemn leaf
#

ik

quartz kindle
#

dont forget the consts and lets

#

i didnt write them because they are fairly obvious

solemn leaf
#

wdym

quartz kindle
#

let promises =

#

let transformed =

#

etc

solemn leaf
#

oh that

#

I thought you meant the canvas

quartz kindle
#

inside your map, you need to return something

#

in your case, you can return ctx

solemn leaf
#

return ctx;

quartz kindle
#

so the variable promises is an array of promises that return ctx

#

[Promise<ctx>,Promise<ctx>,Promise<ctx>] etc

solemn leaf
#

then encoder.finished() before I buffer it

quartz kindle
#

then you can await all of them at once with await Promise.all()

#

that will give you an array of results, like this [ctx,ctx,ctx]

#

so then you can forEach them and addFrame(ctx)

solemn leaf
#

you called it frame

quartz kindle
#

for simplicity

solemn leaf
#

should I change it to ctx

quartz kindle
#

doesnt matter

#

you can name it whatever you want

solemn leaf
#

ikay

quartz kindle
#

then at the end you can finalize the encoder

#

and it should work

solemn leaf
#
gifFrames({ url: URL, frames: "all", outputType: "png" }).then(async function (frameData) {
                console.log(frameData[0].frameInfo)
                const encoder = new GIFEncoder(frameData[0].frameInfo.width, frameData[0].frameInfo.height);
                encoder.start();
                encoder.setRepeat(0);   // 0 for repeat -1 no-repeat
                encoder.setDelay(frameData[0].frameInfo.delay);  // frame delay ms
                const promises = frameData.map(async frame => {
                    // do async transformation here
                    let image = await canvas.loadImage(frame.getImage());
                    let invertCanvas = canvas.createCanvas(image.width, image.height);
                    let ctx = invertCanvas.getContext("2d");
                    ctx.drawImage(image, 0, 0, ctx.canvas.width, ctx.canvas.height);
                    ctx.globalCompositeOperation = "difference";
                    ctx.globalAlpha = 1.0;
                    ctx.fillStyle = "white";
                    ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
                    return ctx;
                });
                const transformed = await Promise.all(promises);
                transformed.forEach(ctx => {
                    encoder.addFrame(ctx)
                });
                const buf = encoder.out.getData();
                const buf = encoder.out.getData();
#

then I can send the buffer in an attachment

quartz kindle
#

where are the consts

#

lul

#

better

solemn leaf
#

how long you think it would take to load

quartz kindle
#

should be pretty fast

solemn leaf
#

then there is an issue

quartz kindle
#

then something is broken

#

check logs

#

i g2g brb

solemn leaf
#

no error

#

can I catch the promise

earnest phoenix
#

how can it so the bot picks up what a user says in discord and makes it a variable in python?

solemn leaf
#

@quartz kindle It could be getting stopped on the await

#

ok its stopped on the await

#

the image type is unsupported

earnest phoenix
solemn latch
earnest phoenix
#

i have no idea what i was just told, my iq is not that high

solemn leaf
#
gifFrames({ url: URL, frames: "all", outputType: "png" }).then(async function (frameData) {
earnest phoenix
#

This does have nothing to do with iq doe kekw, can you explain what you want to do more then?

#

what im trying to do is number = input("please input number")

except make it so people can do it through discord

#

Aha, wait_for suits more then

#

thanks

solemn leaf
#
ContentStream {
  _readableState: ReadableState {
    highWaterMark: 16384,
    buffer: [],
    length: 0,
    pipes: null,
    pipesCount: 0,
    flowing: false,
    ended: false,
    endEmitted: false,
    reading: false,
    calledRead: false,
    sync: true,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    objectMode: false,
    defaultEncoding: 'utf8',
    ranOut: false,
    awaitDrain: 0,
    readingMore: false,
    decoder: null,
    encoding: null
  },
  readable: true,
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  _obj: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 84 00 10 0b 0c 0e 0c 0a 10 0e 0d 0e 12 11 10 13 18 28 1a 18 16 16 18 31 23 25 1d ... 2764 more bytes>,
  [Symbol(kCapture)]: false
}
#

@quartz kindle epic

earnest phoenix
#

not loading, epic

solemn leaf
#

yep exactly

#

its 1 frame

#

wait

#

nvm

#

its the full thing

#

discord is having troubles rendering it

earnest phoenix
#

ok i still have no idea what to do, this is what i get for trying to do this while knowing little about python

solemn leaf
#

open it in browser

earnest phoenix
#

send your code ig

#

this is gonna be cheesy code kekw

#
import discord
import time
from discord.ext import commands

client = commands.Bot(command_prefix="!")


@client.event
async def on_ready():
    print("Bot is ready")
    
@client.command()
async def sos(ctx):
    await ctx.send("The bot needs the following permissions to work in special channels")
    await ctx.send("https://cdn.discordapp.com/attachments/786890463834538006/795771449432473670/unknown.png")
    await ctx.send("https://cdn.discordapp.com/attachments/786890463834538006/795771603534741594/unknown.png")
    await ctx.send("https://cdn.discordapp.com/attachments/786890463834538006/795771705234686002/unknown.png")


@client.command()
async def start(ctx):
    repeat = 0
    number = 0
    while repeat == 0:
        number = number + 1
        time.sleep(1)
        await ctx.send(number)



#

i forgot that i did not fix the counting on this

#

```py
code
```

solemn latch
#

its probably not a good idea to make a py bot without knowing py

earnest phoenix
#

yeah this tbh

earnest phoenix
solemn leaf
#

woo

earnest phoenix
#

i know

solemn leaf
#

do you think that the fram delay is to fast

#

?

solemn latch
#

you should probably not change the frame delay

earnest phoenix
#

i also forgot to add the wait

solemn leaf
#

encoder.setDelay(frameData[0].frameInfo.delay); // frame delay ms

solemn latch
#

didnt you say the format isnt supported @solemn leaf ?

solemn leaf
#

I changed to jpg

earnest phoenix
#

DABOSS, don't use time.sleep, it's blocking. Use asyncio.sleep instead, it's a coroutine btw, needs to be awaited

solemn leaf
#

but now Im having troubles with delay

earnest phoenix
#

ok

earnest phoenix
#

also, you're doing nothing with the repeat value, so it's gonna be an infinite loop

solemn leaf
#

and it not loading on discord

#

you talking to me?

earnest phoenix
#

then the repeat var isn't needed, just do while True

#

ok

#

though, why would you want to do that

cinder fulcrum
#

How to make a dashboard for my bot?

earnest phoenix
#

idk lmao

#

i just wanted a bot that counter until it dies

silver lintel
#

so i have message.client.guilds.cache.filter(g => g.member('id')) to get all the guilds which the user and client share but how to i put all of the guilds' id into an array

earnest phoenix
#

Well I'd just set the number as the client attribute, so there's another whole command that send the number attribute. That way you don't send it in every loop

# start command
client.number = 0
while True:
  client.number += 1
  # sleep

# some another command
await ctx.send(client.number)
gilded olive
solemn leaf
#

uh guys

#

my gif is glitched

#

or soemthing idk

gilded olive
#

you don't have to do ctx.send three times

#

you can use \n to declare a newline

rose warren
earnest phoenix
#

yeah that's better than sending 3 messages

#

ok

solemn latch
earnest phoenix
#

i just wanna know how i can make it so the user can choose what the variable number is so they can start off on a number other than 0, because if the bot goes down its just gonna start from 0 again

#

Have you looked at the link I sent? There's example there

silver lintel
earnest phoenix
#

Try doing it on your own first, then we'll help you

#

ok

#

thanks

solemn leaf
#

any idea why my gif wont load in discord

earnest phoenix
#

the gif is a lie

solemn leaf
#

no not

#

bcs Im viewing it rn

solemn latch
#

when you view it on your pc, does it also go transparent on the second frame?

solemn leaf
#

Nope I dont think so I can screen share

#

it also works on the site

solemn latch
#

honestly, potential discord bug then 🤷‍♂️

solemn leaf
#

just not on the client

solemn latch
#

or your encoding settings are not discord compatible, discord does have a list of supported formats somewhere.

sick cloud
#

can't get the auto popup to go

silver lintel
#

console.log([...message.client.guilds.cache.filter(g => g.member(message.author.id))]); its makes an array length 2, even though im in like 5 mutual servers, someone told me that g.member uses cache but i dont know what that means or how to do it now

silver lintel
#

i have guild member intent but not presence

solemn latch
#

yes, it does use cache.

#

cache is what your bot has in memory

silver lintel
#

oof

earnest phoenix
#

i actually have no idea how to do this, i tried but it just killed my whole bot somehow

silver lintel
#

so is there like a way to fetch them?

solemn leaf
#

.fetch

#

its really nice

solemn latch
#

dont think fetch can do that in one api call 🤔

earnest phoenix
silver lintel
earnest phoenix
#
@client.event
async def on_message(message):
    if message.content.startswith('number'):
        channel = message.channel
        await channel.send('Please input number you would like to start on')

        def check(m):
            return m.content == 'hello' and m.channel == channel

        number = await client.wait_for('message', check=check)
        await channel.send('Hello {.author}!'.format(msg))
#

oh god

#

this is my pathetic attempt

#

why do you copy the whole thing

solemn leaf
#

god appears* "yes?"

earnest phoenix
#

you just need the check and the wait_for

#

oh

#

for instance, if you only want it to wait for your message, you can do something like

def check(m):
    return m.content.isdigit() and m.author.id == your_id  # could be m.author == ctx.author if you want it to wait for the message from whoever invoked the command

msg = await client.wait_for('message', check=check) 
number = int(msg.content)  # cast it to int since it returns Message object and the content attribute is str
#

thanks

solemn latch
silver lintel
#

oof

#

its in more than 100

solemn latch
#

your best bet is using oauth iirc.

silver lintel
#

whats oauth

solemn latch
#

its a way for your bot to make user specific api requests, such as all their guilds.

silver lintel
solemn latch
earnest phoenix
#

my brain hurts from this

solemn latch
#

its generally a bad idea making a bot in a language you dont know

#

discord bots are not really the best first or first few projects.

earnest phoenix
#

True, my bot is my first project and it was awful

dusky sundial
#

That's like writing a book in a language you don't understand. It's better to start with the basics or you're gonna mess a lot of things up.

#

It might work, but you're probably not gonna understand why lol

earnest phoenix
#

devs be like: as long as it works™️

#

i can make it work without any user input but i want the user to choose what number they start on

#

and i have no idea why its not working, its probably really dumb

solemn latch
#

your using dpy right?

earnest phoenix
#

I've literally spoon-fed you though

solemn latch
#

they have a whole thing already for it afaik.

#

in the docs

#

the new py docs are so clean

earnest phoenix
#

I already linked to wait_for, Woo

#

yeah indeed

#

wait, py?

solemn leaf
#

how do I use canvas

#

im very new to it

solemn latch
#

canvas is really simple, read the npm page for canvas

solemn leaf
#

to like detort

inner roost
solemn leaf
#

distort

earnest phoenix
#

i cba to figure this out, im just gonna make a bot that obnoxiously keeps counting

earnest phoenix
#

one day

solemn latch
earnest phoenix
#

but for now i'm happy with an obnoxious discord bot that repeatedly counts

#

my useless little curb stomped baby

#

imo it's easier to look for class attributes on the new docs

sick cloud
#

what would be the most 'non messy' way to format a Date object as DD/MM/YYYY at HH:MM TT but inline

#

doing it in vue so it has to go inline in {{ }}

earnest phoenix
#

can someone help me rq?

#

what's the issue

#

so

#

I'm trying to mention a role

#

and I don't think message.guild.roles exist

#

you could just do message.guild.get_role(id) btw

#

OH

#

thanks ❤️

earnest phoenix
#

Oh wait

#

can I mention the role with that?

solemn latch
#

i think you want to use mentions

earnest phoenix
#

<Guild>.roles returns list of role

solemn leaf
#

message.guild.roles.get

earnest phoenix
#

stfu js

solemn latch
#

oh snap its py

solemn leaf
#

yep its ez

solemn latch
solemn leaf
#

py bad bcs based off everything else

earnest phoenix
#

so by doing get(message.guild.roles, id=id) you're getting an element from the list which has given attribute

#

but that's redundant as you can just do, message.guild.get_role(id). This is faster as getting a value from a dict is faster than iterating and finding an element in a list

solemn leaf
#

woo

#

can you help with canvas

#

pls

solemn latch
#

what are you having trouble with?

solemn leaf
#

image is blank

#

idk the eroror

solemn latch
#

your not using gif encoder in this example are you?

solemn leaf
#

nope

#

its a png

#

my avatar url

solemn latch
#

whats the code look like

solemn leaf
#

this is what draws on ther image

#
ctx.drawImage(image, wide, y, ctx.canvas.width / 2 - wide * 2, yh, 0, i * cH, canvas.width, step * cH);
#

unless if you want the whole thing

solemn latch
#

with canvas you kinda need the whole thing.

solemn leaf
#
let image = await canvas.loadImage(URL);
            let invertCanvas = canvas.createCanvas(image.width, image.height);
            let ctx = invertCanvas.getContext("2d");
            var easeInOut = function (x, pow) {
                x = x < 0 ? 0 : x > 1 ? 1 : x; // clamp x
                var xx = Math.pow(x, pow);
                return xx / (xx + Math.pow(1 - x, pow));
            }
            ctx.setTransform(1, 0, 0, 1, 0, 0); // reset transform
            ctx.globalAlpha = 1; // reset alpha
            ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
            var step = 1 / canvas.height;;
            var y = 0, yh = 0, cH = canvas.height / 2;
            var curve = Math.sin(Date.now() / 1020) + 1.2, curve2 = Math.sin(Date.now() / 2217) + 1.4, curve3 = Math.sin(Date.now() / 533) * Math.PI, curve4 = (Math.sin(Date.now() / 731) + 1.1) * Math.PI;
            var wave = 4 / (Math.PI * 1), wave1 = curve4 / (Math.PI * 1);
            for (var i = 0; i < 1; i += step) {
                var wob = Math.sin(i * wave);
                var wide = (Math.sin(i * wave1 * 3 + curve3) + 1.0) * 100;
                y = easeInOut(easeInOut(wob, curve), curve2);
                yh = easeInOut(easeInOut(wob + step, curve), curve2) - y;
                y *= ctx.canvas.height;
                yh *= ctx.canvas.height;
                ctx.drawImage(image, wide, y, ctx.canvas.width / 2 - wide * 2, yh, 0, i * cH, canvas.width, step * cH);
            }
#

woo?

solemn latch
#

sorry in the middle of a game :p

solemn leaf
#

what game

solemn latch
#

valorant

#

are you supposed to be drawing the entire image every for loop?

solemn leaf
#

uh idk not my math lol

#

prob shouldnt

#

that wouldnt do anything

solemn latch
#

its kinda hard to tell whats going on, but it could be placing the images at a height outside the height of the canvas

#

y *= ctx.canvas.height;
if y > 1 it will just place it off the canvas, right?

solemn leaf
#

I mean the image size looks about right

#

idk

#

didnt change anything

solemn latch
#

this is why copy pasting code is considered a real bad idea 😛

#

op, x is being clamped

#

x = x < 0 ? 0 : x > 1 ? 1 : x; // clamp x

solemn leaf
#

lol didnt see that

#

I didnt know the math for it

#

I know how to do the bytes

#

but not in canvas

solemn latch
#

yeah, ive moved off canvas awhile back

solemn leaf
#

ok

solemn latch
#

might be easier if you tried writing it yourself.

#

reading this is kindof a pain not really writing it myself

#

and since its not commented its even harder to tell.

solemn leaf
#

how hard would it be to make a magik command

#

?

crimson vapor
cursive spire
#

DM me if you know how to make a music bot with discord.py

crimson vapor
#

if else else

oak cliff
#

they arent doing anything wrong

#

just tell them not to ask for help in dms

crimson vapor
#

im pretty sure they are asking for someone to code them something

solemn leaf
#

profiling illegal

astral plank
#

can someone help me?

crimson vapor
#

whats your language, lib, and issue

astral plank
#

i think node?

crimson vapor
#

lol whats the issue

#

probably node

astral plank
#

i don't understand the .env file type

crimson vapor
#

sorry idk env yet

astral plank
#

its fine

#

sneezes

heavy anchor
#

What part do you not understand?

astral plank
#

how do i put the token in

heavy anchor
#

TOKEN="token"

astral plank
#

ok thanks!

heavy anchor
#

This explains a lot about the .env file

#
freeCodeCamp.org

Environment variables are a fundamental part of Node development, but for some reason I never bothered with learning how to properly use them. Maybe because they are called “Environment Variables.” Just the words “Environment Variable” trigger a PTSD-laced flashback in which I am trying to add the correct path to

woeful minnow
#

Hio! Someone can help me with discord Oauth2?

solemn latch
#

@crimson vapor its someone clamping

#

not sure why math.clamp wasnt used, but it works so 🤷‍♂️

crimson vapor
#

its scary

earnest phoenix
#

Can someone help me rq 👁️ e

#
    async def leaderboard(self, ctx):
        rankings = levelling.find().sort("xp", -1)
        i = 1
        embed = discord.Embed(title="Leaderboards")
        for x in rankings:
            temp = ctx.guild.get_member(x["id"])
            tempxp = x["xp"]
            embed.add_field(name="{}:".format(temp), value="{} xp".format(tempxp), inline=False)
            if i == 6:
                break
            i+=1
        await bot_channel.send(embed=embed)```
#
NameError: name 'leaderboard' is not defined```
solemn leaf