#development

1 messages ยท Page 1339 of 1

slender thistle
#

UNLESS

untold sand
#

YouTube videos for Discord bots
@slender thistle Why ?

slender thistle
#

you didn't import has_permissions directly from discord.ext.commands

zealous sable
#

Because its just copy and paste for most people

modest smelt
#

ok

zealous sable
#

and its in 120p quality

slender thistle
#

@untold sand because they are/will be outdated

#

Also that

drowsy socket
#

Oop> @untold sand because they are/will be outdated
@slender thistle sorry

stoic girder
#

learn the basics of the programming language you want to use and read the documentation

untold sand
#

@untold sand because they are/will be outdated
@slender thistle Oh k

modest smelt
#

@slender thistle so if i have this. the commmand will work right? from discord.ext.commands import has_permissions

slender thistle
#

try it

modest smelt
#

ok

#

it works now thanqie

stoic girder
#

this import just got me thinking, in JS, does it affect the performance if you require the whole Discord lib instead only, for example, MessageEmbed?

slender thistle
#

Performance-wise I wouldn't say so

#

memory-wise probably, but I'm not sure myself

modest smelt
#

shivaco

#

one question

#

how does try and except work with errors?

stoic girder
#

Hmm, interesting. Might do some benchmarks when I get time.

modest smelt
#

suppose for cloning a channel

#

would this be correct:

#
try:
  code
except HTTPException:
  code
else:
  code
```?
#

this is what I'm looking at rn

native quiver
#

would this be correct syntax: @has_permissions(manage_channels = True)?
@modest smelt no try this @command.has_permissions(manage_channels=True)

modest smelt
#

nah i got it to work with the @has_permissions

native quiver
#

oh

#

ok

modest smelt
#

@slender thistle ?

slender thistle
#

try code, if HTTPException is raised, do code, if no error occurs, do code

modest smelt
#

so like this:

#
try:
  code
HTTPException:
  code
else:
  code
```?
earnest phoenix
#

Hi i have a Problem in discord.js canvas
When i am sending with x = db.get(msg_{member.guild.id})
if this is null it is not sending can i fix it

if msg is null can i send canvas?

slender thistle
#

You'd have to use basic Python knowledge to create a proper error handler

#

you almost got it though

modest smelt
#

hmm ok ill take a look at it

#

would this work

#
try:
  code
except HTTPException:
  code
except:
  code
slender thistle
#

what's code

modest smelt
#

the code i will add

#

for example

opal plank
#

do stuffs

slender thistle
#

Should work

modest smelt
#
try:
  await clone('channel')
except HTTPException:
  await ctx.send('could not been made')
except:
  await ctx.send('something')
#

this is not the proper syntax for the code

slender thistle
#

clone is a method of a voice channel

modest smelt
#

but like is the try and except correct?

#

yeah ik

slender thistle
#

don't use except twice

modest smelt
#

ok

#

so remove the bottom except right?

slender thistle
#

Two options, either send the message that says "success" in the try branch

#

or use the else branch for that

modest smelt
#

ok

opal plank
#

can someone explain how a gate and an if on my subscription event(WHICH ISNT EVEN HOOKED TO THE SHARDS) somehow broke my whole sharding pls? Cuz this shit is making no sense whatsoever, and im the one who made it

modest smelt
#
try:
  await send('yay')
except HTTPException:
  await ctx.send('could not been made')
slender thistle
#

sure

opal plank
slender thistle
opal plank
#

shiv help

#

im relating to a video rn

#

about development

modest smelt
#

Thanks shivaco!

opal plank
#

cuz i broke my whole sharding cuz of something completely unrelated to it

#

its the equivalent of sneezing and accidently causing a tsunami in japan

#

how does an event emitter which is hooked to a logger affect sharding?

slender thistle
#

don't know though

earnest phoenix
#

Help

pale vessel
#

sure

#

with what

earnest phoenix
#

???

crimson vapor
#

you have to wait for the moderators to approve your bot

solemn latch
earnest phoenix
#

I put it on for a few months but it is not acceptable at all

#

3 months +

solemn latch
#

looks like you added it under a month ago

stoic girder
#

@earnest phoenix Consider improving your description until it gets reviewed.

obtuse jolt
#

is there anybody that would help me fix some panel security vulnerabilities? not paying money

opal plank
#

hmmmm

#

that gave me an idea

obtuse jolt
#

smh

solemn latch
#

what are you insecure about erwin Thonk

#

does leviathan have a panel

opal plank
#

it does

#

more specifically this

solemn latch
#

o

opal plank
solemn latch
#

404 pogey

opal plank
#

even though you dont have access to the page cuz its a not verified bot

#

you can still get meta from it with the content

#

i was wondering if top.gg meta tags provided that

#

cuz i was thinking how does @stoic girder found about the description

#

if its a non approved bot, therefore only the owner should have access to the bot page

#

probably an oversight in that botlist part tbh

stoic girder
#

@opal plank hehe this is too big brain

opaque eagle
#

What's the purpose of Request.clone() and Response.clone()?

stoic girder
#

he sent a screenshot

#

thats how i saw the description

opal plank
#

LMAO

#

well that explains

#

i was digging in the source code to find security oversights

willow mirage
#
function plusMinus(arr) {
    let result = [];
    let positive = 0;
    let negative = 0; 
    let zero = 0;
    for(let i = 0; i < arr.length; i++){
        if(arr[i] > 0) {
            positive++;
        }else if(arr[i] < 0){
            negative++;
        }else {
            zero++;
        }
    }
    result.push(Math.floor((positive / arr.length) * 1000000) / 1000000);
    result.push(Math.floor((negative / arr.length) * 1000000) / 1000000);
    result.push(Math.floor((zero / arr.length) * 1000000) / 1000000);
    return result.join(" ") + "\n";
}

Help me please

#

uh toFixed()

#

will work

earnest phoenix
#

All that can be shorted to a single map

boreal iron
#

wonder why u put the result into an array and return it as string?

#

just return the string which will save 3 lines lel

opal plank
#

arr.push() is ordered i assume, right?

#

new items will always be put at last position

#

nvm , it does

boreal iron
#
let divisor = 1000000;
return (Math.floor((positive / arr.length) * divisor) / divisor) + "\n" + (Math.floor((negative / arr.length) * divisor) / divisor) + "\n" + (Math.floor((zero / arr.length) * divisor) / divisor);

at least it doesn't require to create and fill an(other) array

#

btw. you're calling arr.length 4 times, which makes it faster to define it once and use the var later

#
function plusMinus(arr)
{
    let size = arr.length;
    let positive = 0;
    let negative = 0; 
    let zero = 0;
    let divisor = 1000000;

    for(let i = 0; i < size; i++)
    {
        if(arr[i] > 0) positive++;
        else if(arr[i] < 0) negative++;
        else zero++;
    }

    return (Math.floor((positive / size) * divisor) / divisor) + "\n" + (Math.floor((negative / size) * divisor) / divisor) + "\n" + (Math.floor((zero / size) * divisor) / divisor);
}```
#

Optimizations are always good

earnest phoenix
#

Instead of all that i did this

#

Wait lemme beautify it real quick

#
function plusMinus(arr) {
    let positive = 0,
        negative = 0,
        zero = 0;
    arr.map(element => {
        if (element > 0) {
            positive++;
        } else if (element < 0) {
            negative++;
        } else {
            zero++;
        }
    });

    let numStream = 1000000;
    return [
        Math.floor((positive / arr.length) * numStream / numStream),
        Math.floor((negative / arr.length) * numStream / numStream),
        Math.floor((zero / arr.length) * numStream / numStream)
    ].join("\n");
    }```
viscid gale
#

eek

#

im gonna see how few lines i cud do the solution cuz im bored

pale vessel
#
function plusMinus(arr) {
    let positive = 0, negative = 0, zero = 0;
    arr.map(element => element > 0 ? positive++ : element < 0 ? negative++ : zero++);
    let numStream = 100000;
    return [
        Math.floor((positive / arr.length) * numStream / numStream),
        Math.floor((negative / arr.length) * numStream / numStream),
        Math.floor((zero / arr.length) * numStream / numStream)
    ].join("\n");
}```
earnest phoenix
#

[Wait that was my solution before i got an error right]

#

Just a little modified

#

Anyone here fluent in NodeJS? I am a bot developer who is pretty skilled in NodeJS and NEVER in my life have I ever caught Python being able to do something NodeJS couldn't do. Is there a way to make a bot respond to a command with a question, and you answer that question by typing just plain text like this?

#

Use message collectors with iterations over questions

boreal iron
#

@pale vessel Ur still calling arr.length 3 times, got ya smirk

pale vessel
late knot
#

yo i need help ive made a bot but i used botghost but i want to make currencies on different website for currencies any ideas/help

viscid gale
#
function plusMinus(arr){
  arr.forEach((a,i)=>{arr[i]=Math.pow(Math.abs(a*1),-1)})
  return(arr.join` `)
}
#

cuz the problem just wanted to show the inverse of the positive form of a number

earnest phoenix
#

yo i need help ive made a bot but i used botghost but i want to make currencies on different website for currencies any ideas/help
@late knot If you use NodeJS, use Fs or mongo.db. I personally use Fs as there is more possibilities, but search NodeJS Fs + economy bot and you will find an answer.

late knot
#

okay thank you

earnest phoenix
#

Np

pale vessel
#

fs thonkhappy

viscid gale
#

i cud make it even shorter, like a

function plusMinus(arr){
  arr.forEach((a,i)=>{arr[i]=1/Math.abs(a*1)})
  return(arr.join` `)
}
#

and.. im still bored ๐Ÿ—ฟ

pale vessel
#

same

#

should probably sleep since it's 2am trollpixel

earnest phoenix
#

@viscid gale Is that Python?

pale vessel
#

no

earnest phoenix
#

JS?

pale vessel
#

yes

#

python uses def

earnest phoenix
#

I am fluent in JS and I don't recongnize anything but "function" and "return" there.

pale vessel
#

you'll get there

#

i guess the lambdas confused you

viscid gale
#

js

#

@earnest phoenix ^

earnest phoenix
#

arr.forEach((a,i)=>{arr[i]=1/Math.abs(a*1)}) threw me off except for the "ForEach".

viscid gale
#

xD

#

ite lemme explain

pale vessel
#

it's modifying the array based on the index

viscid gale
#

LET ME EXPLAIN

earnest phoenix
#

XD I used that system to make a leaderboard for my economy system.

pale vessel
#

no

viscid gale
#

:{

#

but still ;]

#

js is a prototyping language, and one of the prototypes in the Array class is forEach

earnest phoenix
#

OMG GUYS

pale vessel
#

ignored

earnest phoenix
pale vessel
#

who

viscid gale
#

lol

#

i think it was me when i re-pinged to his ping

sudden geyser
#

The good ol' ConcurrentModificationException days

viscid gale
#

or did u get ur bot approved

#

well u did

#

but was that jn?

earnest phoenix
#

The only other ping was me getting declined xd

#

Yeah it did get approved

viscid gale
#

arr.forEach((a,i)=>{arr[i]=1/Math.abs(a*1)}) threw me off except for the "ForEach".
as i was saying, forEach executes the function you give as its parameter. in that function u give, it gives ur function some parameters

  1. data
  2. index
  3. i can't remember also can't remember if there r more params
opal plank
#

FOReACH BAD

#

its the least performant loop

viscid gale
#

u said ur fluent in js... so ur perfect to ask this..
im making a web game in which the main purpose is to "outcode" your enemies
all the game gives you is a simulated processor that takes in about 12 commands(im not finished making so im not sure if im gonna make more base commands). these commands manipulate the file system, attempt connections to other victims users, buying programs people put to sale (or selling your own).. basically a code game

digital ibex
#

for sunglases

viscid gale
#

its the least performant loop
in terms of speed?

opal plank
#

so basically coding wars

viscid gale
#

except no installation needed

#

for anything

opal plank
#

forEach in general is poor

viscid gale
#

meh... i just think u don't like it ;]

opal plank
#

you should look at this

viscid gale
#

i play that

#

it is nothing like that what im making

fervent sparrow
#

im feelin makin a bot

opal plank
#

its not about 'liking'

#

its performance

fervent sparrow
#

hby

opal plank
#

im a bit of an annoying prick when it comes to performance recently due to webscaling

solemn latch
#

^ lol

viscid gale
#

xD

opal plank
#

small things overall dont affect your code much

viscid gale
#

i realised

opal plank
#

but once you scale it DOES impact

fervent sparrow
#

i wanna make a bot that spams

viscid gale
#

so u would make a class to return an object instead of a normal function

#

interesting

solemn latch
#

ima foreach my foreaches of those foreaches @opal plank

restive furnace
#

i wanna make a bot that spams
@fervent sparrow FeelsTOSMan

viscid gale
#

all for that extra 0.02 ms per object

fervent sparrow
#

bruh

viscid gale
#

honestly i cant say my style is made off any full principle

opal plank
#

like i said, in scale it DOES affect performance with all those small nuicenses since they stack

viscid gale
#

so ur better off than me

opal plank
#

didnt i do a performance test?

#

holdup

#

hmmm i didnt run a test for forEach()

quiet arch
#

hi i have an error but dont know how to fix it

opal plank
#

at least i didnt make a tag

quiet arch
#

const Discord = require('discord.js')
const api = require('imageapi.js')
const client = new Discord.Client

client.once('ready', () => {
console.log('Ready!')
})

client.on('message', message => {
console.log(message.content)
})

client.on('message', message => {
if (message.content === 'pepeping'){
message.channel.send('pong!! hehe')
}

client.on('message', async message => {
    if (message.content === 'pepememe'){
        let subreddits = [
            'memes',
            'dankmemes',
            'therewasanattempt',
            'woooosh',
        ]
        let subreddit = subreddits[math.floor(math.random()*(subreddits.length))]

        let img = await api(subreddit)

        const Embed = new Discord.MessageEmbed()
        .setTitle('here ya go')
        .setURL('https://www.reddit.com/r/memes')
        .setColor('RANDOM')
        .setImage(img)

        message.channel.send(Embed)

    }
    client.login('secret')
                                       ^
#

what did i do wrong?

viscid gale
#

erwin u help cuz i gonna bounce

fervent sparrow
#

this confueses me

viscid gale
#

i gotta eat

opal plank
#

lemme read the question again rq

fervent sparrow
#

aaahh big code scares me

misty sigil
#

hi @quiet arch please tell us the error

quiet arch
#

okay

earnest phoenix
misty sigil
#

syntax error

quiet arch
#

ig

misty sigil
#

just fix your syntax

quiet arch
#

how do i fix it?

misty sigil
#

dont use var tho

opal plank
#
function plusMinus(arr) {
let output = '';
for(let e of arr) output+= `${Math.pow(Math.abs(e*1),-1)}`
return output;
}```
quiet arch
#

oh

#

why not?

misty sigil
#

deprecated

#

if you need to change a value, use let, if you don't use const

opal plank
#

while its bigger using for loops is a tad better

#

@viscid gale

quiet arch
#

i use const

#

but let is the same?

misty sigil
#

no

#

let allows you to reassign the value

opal plank
#

const = constant, immutable, fixed

stoic girder
#

const is constant, can't be changed, let isn't available outside its scope (e.g. if statement)

opal plank
#

let is for things that change

fervent sparrow
#

@restive furnace so you mean to tell me some one can make a bot that knows you location to a point but i cant make a bot to spam my own server

earnest phoenix
#

Wotdefok

restive furnace
#

@restive furnace so you mean to tell me some one can make a bot that knows you location to a point but i cant make a bot to spam my own server
@fervent sparrow you can't neither

stoic girder
fervent sparrow
#

i saw a bot on the list that uses you location to tell the weather

opal plank
#

discord doesnt provide your location

earnest phoenix
#

A bot can't detect your location that's Impossible

restive furnace
#

you probably set it yourself or input the town where you want the weather from

fervent sparrow
#

bruh lemme see

opal plank
#

if you provide the bot with your location, its on you

fervent sparrow
#

brb

opal plank
#

ugh.... am i really gonna have to dump logs into database?

fervent sparrow
opal plank
#

again, discord does NOT provide your location

fervent sparrow
#

ik

willow mirage
misty sigil
#

and will NEVER provide location

#

it is not p2p

opal plank
#

if the bot gets that info, you are the one who provide it

earnest phoenix
#

Only if you provide your location for the bot to recognize

fervent sparrow
#

aaahhh

#

ok

umbral zealot
#

Did we mention discord never provides location data? ๐Ÿ˜‚

willow mirage
#

when u try some thing but it goes another way
help meh

opal plank
#

discord ip leak when?

willow mirage
#

im done with this hackerrank

opal plank
stoic girder
#

maybe it did a big brain move and stole your ip via a redirect site once you clicked upvote

opal plank
#

imagine accounting for vpns

earnest phoenix
#

This guy was told to make a lake kind of thing with hashtag and he made a rainbow

opal plank
earnest phoenix
willow mirage
#

@earnest phoenix a triangle

#

:))

earnest phoenix
willow mirage
earnest phoenix
#

I don't see anything different lmao

#

Oh

#

I added one extra spacing

opal plank
#

space i guess

#

yeah

willow mirage
#

smh

#

yey but i didn't use ur method

#

i used only for loops

#
let k, j, i;
    for (k = 1; k <= n; k++)
    {
        let string = "";
        let spaces = "";
        for(j = 0; j <= n-k-1; j++)
            spaces = spaces + " ";
        for (i = 0; i <= k-1; i++)
            string = string + "#";
        console.log(spaces + string)
    }
opal plank
#

i has idea

#

brb

boreal iron
#

u let other people do your homework, hmm?

tulip ledge
#

Anyone has a good drop distribution algorithm?
What I was previously doing was:

["Item1", "Item2", "Item3"]
[20, 50, 30]

Then I'd make an array of 20x Item1, 50x Item2, 30x Item3 and take a random one of that but that's pretty inefficient and I also want to make it so u can increase drop chance, etc

solemn latch
#

numerical mapping?

0-19 = item1
20-49 = item2
50-79 = item3

#

then just rng between 0 and 79

tulip ledge
#

and how would I implement that?

opal plank
#

i got it in 4 lines

#

@willow mirage @earnest phoenix

willow mirage
#

i challenge u to make a rainbow

#

cuz i accedentally made a rainbow

opal plank
#

define rainbow

solemn latch
#

i am working on learning opengl, tried making a rainbow, failed

willow mirage
#

a 1/4 circle

opal plank
#

like

willow mirage
#

a 1/4 circle

opal plank
#

           # 
                      # 
                            # 
                               #
willow mirage
#

ye

proven lantern
#

one line ```console.log(` #
##

######`);```

willow mirage
#

@proven lantern LoL

solemn latch
#

if its just a small number of items(3)
you could just do an isbetween check for each one @tulip ledge

tulip ledge
#

oh ok

waxen chasm
solemn latch
#

if its larger, theres very likly a much better method

opal plank
#

i cant think of a way to reduce it tbh

#

actually

#

i can

solemn latch
#

also, just a note. your numbers are all x10
you could just cut the numbers by /10 and it would be much much more efficient

opal plank
tulip ledge
#

but sometimes I have 35

opal plank
#

there, 3 lines

tulip ledge
#

or 25

#

or 1

faint prism
#

smh
@willow mirage yo I hated that website in my CIS class

willow mirage
#

what ?

proven lantern
#

make sure to memoize the results for larger numbers

willow mirage
#

@willow mirage yo I hated that website in my CIS class
@faint prism what website ?

#

u mean hackerrank?

#

ah

faint prism
#

Just looks like one of those learning websites my prof used for our class

#

Super nit-picky

earnest phoenix
willow mirage
#

imagine making test with hackerrank

#

@earnest phoenix bruh

opal plank
#

i prefer coc over hr

#

crash of codum

willow mirage
#

@earnest phoenix nice idea

#

it is simple but good

#

5
5 + 5
5*3
5*4

right ?

proven lantern
#

i had to write an program that basically did this at work a couple weeks ago

    x
   x
  x
 x
x
    xx
   x x
  x  x
 x   x
x    x
   xx
  x x
 x  x
x   x
  xx
 x x
x  x
 xx
x x
xx
   xxx
  x xx
 x  xx     


` ```
willow mirage
#

oh

#

5
(5 * 2) - 1

opal plank
#

what even is the pattern there?

earnest phoenix
#

0
โ†“
0 + 5
โ†“
5 - 1
โ†“
5 + 4
// Goes on

#

That's thr pattern i used

shy turret
#

is it just me or

#

(expressjs)

module.exports.load = async function(app, db) {
  app.get("/", async (req, res) => {
    // stuff
    res.send("stuf")
  });
}
#

isnt working when i use

#
for (let file of apifiles) {
  console.log(`./api/${file}`);
  let apifile = require(`./api/${file}`);
    apifile.load(app, keyv);
}
#

for 3+ files in the "api" folder

#

same for this

apifiles.forEach(file => {
  console.log(`./api/${file}`);
  let apifile = require(`./api/${file}`);
    apifile.load(app, keyv);
})
#

i made a console.log("<file name> has loaded.") for all of the files and it says they loaded but... the app.get()s dont work

#

i tried to use a module.exports method but it still doesnt like me

viscid gale
#

try exports.varName

#

it worked for me at least

#

well in your case it will legit be exports.load

shy turret
#

i alr tried all that

#

ok it works if i remove all the files but that single one

#

but then i need the other ones loaded too

#

wait

#

oh

#

OH

#

is it possible to... actually yes i can

#

i had a app.get("*", async (req, res) => {

#

fixed

tulip ledge
#

Is there a way to check if the user is on mobile? Discordjs

shy turret
#

prob

#

yes

#

idk how though

bronze flume
#

From where i could find some good tutorials for javascript?

unreal token
#

@bronze flume youtube

#

as simple as that lol

bronze flume
#

I know already furios

#

But not all that tutorials are good

#

I mean

steel drum
#

documentation + experience is the best teacher

bronze flume
#

Some of them are used on an old version

#

Bruh

#

I dont really what to do

unreal token
proven lantern
#

@bronze flume JavaScript: The Good Parts
by Douglas Crockford

unreal token
#

I posted this before but i keep getting Error : (node:13576) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined.
Ive literally tried everything to fix this.

Code : ```shards.on("shardCreate", shard => {
console.log([${new Date().toString().split(" ", 5).join(" ")}] Launched shard #${shard.id});
let embedt5 = new Discord.MessageEmbed()
.setAuthor(Shard Online | Update!, https://cdn.discordapp.com/avatars/163804470763847680/a_bb43ba59ed24339510d344029ac88d95.gif?format=png)
.setColor("YELLOW")
.setDescription(**I am now available in ${shard.id}.**);
bot.channels.cache.get('768218401466220545').send(embedt5);
});

proven lantern
#

@unreal token try getting the guild firstbot.guilds.cache.get(guildId).channels.cache.get("768218401466220545")

unreal token
#

o ill try that ty

bronze flume
#

Idk bro

#

I m gonna see

#

I nees more time to learn this

#

Isnt enough 1 2 hours

proven lantern
#

@bronze flume make a leetcode account and do the problems in javascript

#
boreal iron
unreal token
#

@proven lantern i get this error now (node:8136) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'channels' of undefined

proven lantern
#

that means your bot doesn't have access to the guild i believe. is it a member of the guild?

unreal token
#

i gave it full admin and its there

#

its strange because when i do eval it works

boreal iron
#

Post the line. The property channels doesnโ€™t exist, which means u used a wrong object in front of it

#

wrong_obj.channels

#

If thereโ€™s no channels property defined inside wrong_obj it will throw this error

#

Since u canโ€™t access something that doesnโ€™t exist

proven lantern
#

add these two logs
console.log(bot.guilds.cache.get(guildId))
console.log(guildId)

unreal token
#

o ok

#

@proven lantern undefined
525698955116412928

proven lantern
#

weird

#

i'd double check that your bot is in that guild. make sure the guildId matches

unreal token
#

alr ima try it with a different bot and try to figure something out ty for the help

proven lantern
#

np

boreal iron
#

In how much servers is the bot currently?

#

Just console log the whole cache if itโ€™s just in a few servers to see if the cache is accurate

queen crescent
unreal token
#

lemme check

boreal iron
#

U think deleting and reposting will grant u more publicity?

queen crescent
#

yh

unreal token
#

@boreal iron 464

compact briar
#

@unreal token i use it after i define channel separately and it works for me
try out

channel = bot.channels.cache.get('768218401466220545');
channel.send(embedt5)```
boreal iron
#

Uuuh I think that would be too much for the console

unreal token
#

@compact briar same error sadly

#

@boreal iron i can use a different bot

boreal iron
#

Sure if so try a different one and take a look at the cache

#

And btw. if you just wanna get a channel, you donโ€™t have to get its guild, since channel IDs are unique

compact briar
#

make sure you have the right channel id

unreal token
#

o ok

boreal iron
#

bot.channels.cache ... should be good

unreal token
#

@compact briar i did 100 times

#

alrighty

exotic hemlock
#

Hello im kinda new to discord. How do I get a bot?

boreal iron
#

Is ur djs even up to date? Thought I read that cache shit came in in the latest version

unreal token
#

i think so

#

is there a way to check?

compact briar
#

djs 12 requires the cache

unreal token
#

im sure i was using v12

proven lantern
#

you would see the error being cache is undefined

#

but it's not

boreal iron
#

I donโ€™t see any error ๐Ÿ‘€

proven lantern
#

Cannot read property 'channels' of undefined

#

that's the error

boreal iron
#

Of undefined

compact briar
#

change it to shards.channels

boreal iron
#

Uhh

proven lantern
#

bot.guilds.cache.get(guildId).channels

earnest phoenix
#

how long can a discord id be?

boreal iron
#

Is object bot defined correctly?

unreal token
#

yes

boreal iron
#

Just show the line please to make sure

compact briar
#

have you tried shards.channels.cache.get('768218401466220545').send(embedt5);?

i dont see bot anywhere in your code

unreal token
#

const bot = new Client({
disableMentions: "all"
});

compact briar
#

just making sure

unreal token
#

@compact briar didnt work still

boreal iron
#

Err whatโ€™s the const for the discordjs

unreal token
#

@compact briar when i do that i get TypeError: Cannot read property 'cache' of undefined

#

@boreal iron const Discord = require("discord.js");

#

but it wasnt used in that file

#

I used const { Client } = require("discord.js");

#

for bot

boreal iron
#

Isnโ€™t it const bot = new Discord.Client

compact briar
#

that was if you had bot defined as shard instead.

boreal iron
#

?

#

Oh ok

compact briar
#

was talking to them

boreal iron
#

Didnโ€™t know that, donโ€™t know ur code

unreal token
#

@boreal iron that does the same
@compact briar yes

compact briar
#

but no. you can do bot = new client if you have it set to { client } = require("discord.js")

proven lantern
#

@unreal token try using the fetch method

guild.channels.cache.get().send()
boreal iron
#

Just console log the object bot please

unreal token
#

o ok

boreal iron
#

With the test bot

#

Not gonna catch 440 servers lmao

#

that silence tho

proven lantern
unreal token
#

@proven lantern it still didnt work :v i got the same 'send' error

#

@boreal iron i got a big answer

proven lantern
#

send error this time and not channels error?

#

maybe just need to use the fetch method for the channel too

boreal iron
#

I know does the object contain an object called channels?

unreal token
#

@proven lantern it went back to the (node:10720) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined

boreal iron
#

Or cache

unreal token
#

guilds: GuildManager {
cacheType: [Function: Collection],
cache: Collection(0) [Map] {}
},
channels: ChannelManager {
cacheType: [Function: Collection],
cache: Collection(0) [Map] {}
},

proven lantern
#

await bot.channels.fetch('channelId')

unreal token
#

@proven lantern if i take await bot.channels.fetch('channelId') as is it doesnt give me any errors it just goes on

#

but if i add .send beside it it goes bot.channels.fetch(...).send is not a function

proven lantern
#
channel.send()```
boreal iron
#

Well gtg, sorry imma not familiar with djs

#

Good luck, Ben

proven lantern
#

are you doing it like that?

#

thanks @boreal iron

unreal token
#

@boreal iron o thank u btw

boreal iron
#

Np I tried at least

unreal token
#

@proven lantern im getting TypeError: Cannot read property 'send' of null

sharp thicket
#

hello

unreal token
#

it changed from undefined to null

sharp thicket
#

can i confess to something stupid that i did?

faint prism
#

does fetch return null if it doesn't find anything?

unreal token
#

@faint prism yes

sharp thicket
#

i dual booted kali linux and windows and turned out i wasn't dual booting but was installing a new system so that's nice

proven lantern
#

if your bot has access then fetch should get it. even if it's not in the cache. Obtains a channel from Discord, or the channel cache if it's already available

unreal token
faint prism
#

i dual booted kali linux and windows and turned out i wasn't dual booting but was installing a new system so that's nice
@sharp thicket did you format over your windows partition?

sharp thicket
#

yes

#

sadly

faint prism
#

wow, that sucks

sharp thicket
#

i forgot i split that too

#

kali linux ended up erroring

#

and i had to restore windows to where i had saved it in a usb

faint prism
#

Do you ever backup?

earnest phoenix
#

i used a package called prettier or some shit and it made all ' to ", is there any way to revert this? it changed it in every file ๐Ÿ˜ญ

faint prism
#

@earnest phoenix ez just use git reset HEAD~1 if you use source control and committed
Otherwise git reset --hard

sharp thicket
#

yes

#

i've backed up multiple times

#

thankfully

proven lantern
#

@unreal token what is the channel.type?

#

voice channels wont have a send function

unreal token
#

text channel

sharp thicket
#

text or category for that matter

#

i think....

proven lantern
#

text channel has one

rich stone
#

How can I see the number of servers my bot is active on?

solemn latch
#

what library/lang

proven lantern
#

@unreal token if you log channel.type does it throw an error saying channel is null?

rich stone
#

How can I see the number of servers my bot is active on?

faint prism
#

||$5 it's d.js||

unreal token
#

@proven lantern it wont let me log that

#

nvm im dumb

#

@proven lantern it said undefined

rich stone
#

$5 it's d.js
@faint prism what

faint prism
#

@faint prism what
@rich stone dude, what programming language are you using?

solemn latch
#

we cant tell you how to do anything since we dont know what language/library your using

rich stone
#

@rich stone dude, what programming language are you using?
@faint prism Google Translate

unreal token
#

@proven lantern bruh I tried it in a completely different file like this ```const Discord = require('discord.js');

const client = new Discord.Client();
const token = '-'
const Discord = require("discord.js");

client.on('ready', () => {
console.log('Ready!');
client.channels.cache.get('768218401466220545').send('0')
});

client.login(token);```

#

and it worked

proven lantern
#

i think it's the const {Client} = require

#

the destructor

#

it can break class objects in javascript

rich stone
#

I always translate your language, don't you translate Turkish at once?

unreal token
#

@proven lantern even when I changed that it still gives me this error idk why it gives me this error all of a sudden

rich stone
#

Botumun Ne Kadar Sunucuda Aktif OlduฤŸunu Nasil Gรถrebilirim

unreal token
#

@proven lantern welp i gtg tysm for the help

proven lantern
#

np

#

gl

unreal token
#

ty!

royal slate
#

Zdravstvuyte

#

hello

slender thistle
#

-noru @royal slate

gilded plankBOT
#

@royal slate

ะ’ั‹ ะผะพะถะตั‚ะต ะณะพะฒะพั€ะธั‚ัŒ ะฟะพ-ั€ัƒััะบะธ ะฒ #general-int.
ะ•ัะปะธ ะ’ะฐะผ ะฝัƒะถะฝะฐ ะฟะพะผะพั‰ัŒ ั top.gg, ะ’ั‹ ะผะพะถะตั‚ะต ะพะฑั€ะฐั‚ะธั‚ัŒัั ะทะฐ ะฟะพะผะพั‰ัŒัŽ ะฒ #support.

royal slate
#

@gilded plank i was messing around, im dont speak russian

#

but you want me to go to general 2

#

okay

drifting wedge
#

how with dpy do i set a image to an embed?

#

but its a file?

thin cedar
#

Someone have a command to see the number of people connected in a voice room on their server?

solemn latch
#

depends on the library

hollow sedge
#

It's not that hard to search it up before asking here lol

drifting wedge
#

i found this

#

but i did look it up

hollow sedge
#

Are you..just proving my point?

drifting wedge
#

i had to go to google page 2

thin cedar
#

Library? Sorry I'm French so I'm using google translate

solemn latch
#

djs, eris, dpy, discordnet

hollow sedge
#

i had to go to google page 2
@drifting wedge usually stackoverflow answers are at the top for me

#

What did you search?

drifting wedge
#

add image file as embed dpy

thin cedar
#

js

solemn latch
#

google page 2, explains why you didnt find it

#

js has two libraries for discord(primarily)

#

eris and discordjs

hollow sedge
#

Change dpy to discord py

#

When you're looking stuff up

#

@drifting wedge

thin cedar
#

discordjs

proven lantern
#

Emitted when the stats have been posted successfully by the autoposter

  console.log('Server count posted!');
});```
what is the autoposter?
drifting wedge
#

ty

hollow sedge
#

np, you'll get much better results from that

thin cedar
solemn latch
#

whats the structure of voiceChannels

thin cedar
#
client.on('message', message => {
    if(message.content.startsWith('!voice')) {

var Count;
for(Count in client.users.array()){
   var User = client.users.array()[Count];
   console.log(User.username);
}

const voiceChannels = message.guild.channels.forEach(c => c.type === 'voice');
let count = 0;

for (const [id, voiceChannel] of voiceChannels) count += voiceChannel.members.size;

message.channel.send(count);

    };

});
solemn latch
#

I feel like voiceChannels is undefined

#

i think you want to filter rather than foreach

earnest phoenix
#

Yay NodeJS

#

Can I help

thin cedar
#

Yes woo

boreal iron
#
const voiceChannels = message.guild.channels.forEach(c => c.type === 'voice');
#

Thatโ€™s ur issue

thin cedar
#

yes

boreal iron
#

Youโ€™re checking each channel if itโ€™s and voice channel, thatโ€™s it, ur not doing anything if the statement is true

solemn latch
#

which is why i suggested filter

thin cedar
#

Oh ok and do you have any idea how to fix it?

#

filter dont work for me

tame kestrel
#

const vcs = guild?.channels.cache.filter((channel) => channel.type === 'voice');

#

I tested this ^ and it works

boreal iron
#

Does filter return the objects in this case?

tame kestrel
#

ye it just returns another collection

boreal iron
#

Ah ok makes sense then

boreal iron
#

Huh imma not working with djs, so donโ€™t nail me down on it

thin cedar
solemn latch
#

i think your in an older version of djs

#

so no .cache needed

thin cedar
#

Ohh thx

#

Its works

earnest phoenix
#

order user's roles in a descending order by the role position

#

that you need to get the user roles and order/sort them in a descending order by the role position

waxen tinsel
#

That should be how it is returned automatically

earnest phoenix
#

the api returns it unordered

waxen tinsel
#

What lib

earnest phoenix
#

any

#

api returns the roles unordered lol

waxen tinsel
#

Not py

earnest phoenix
#

dpy probably internally sorts them

waxen tinsel
#

Probably

#

Thats why I asked what lib

earnest phoenix
#

the roles can get reordered again depending on the storage because of the role id

waxen tinsel
#

Wdym script, you mean code?

solemn latch
#

its kindof a script isnt it? technically

#

like javascript itself is just a scripting language isnt it ๐Ÿค”

tame kestrel
#

ye

boreal iron
#

Anyway you need to code that by yourself or copy and paste shit which isnโ€™t recommended

#

Just watch the docs and examples

#

Iโ€™m sure somewhere around the net is an example of how to get the roles of a guild in program language xyz...

solemn latch
#

well, what language?

#

and lib

faint prism
#

@faint prism Google Translate
@rich stone not a spoken language. A computer programming language

sharp thicket
#

^ lol

proven lantern
#
        console.log(e);
        msg.reply(`There was an issue during your search.\n${e}`);
    }```
is there a good way to check if the error was a permission error and find the permission that is missing?
sharp thicket
#

if(e.includes("Missing Permissions")){
// ur code
}

#

if that's wrong someone correct me

proven lantern
#

what about finding the type of permission missing?

#

i see there is a path property

sharp thicket
#

uh

#

i don't know

#

is e an object?

proven lantern
#

yeah a stacktrace like object

sharp thicket
#

so

sudden geyser
#

I don't think Discord tells you which permission you're missing, so you'd need to calculate it yourself. Though, that can only be done if you know what permissions you were trying to use as well.

sharp thicket
#

yeah

#

path is just where the error happened right?

sudden geyser
#

I also recommend you check the code property rather than checking if the message of the error message includes "Missing Permissions" as its constant.

#

It's just the endpoint you hit.

sharp thicket
#

yeah

#

that's a good answer

sudden geyser
#

So if missing permissions is there, maybe you don't have permission to view invites, or would it be to create invites, delete invites, etc.

sharp thicket
#

maybe theres something in docs?

proven lantern
#

i was thinking something like if(e.path.includes("channels")){// missing channel permissions}

sharp thicket
#

i done think so

#

channels would always be included

tired nimbus
#
   const audio = connection.receiver.createStream(bot.users.cache("372511780494114818"), { mode: 'pcm' });

audio.pipe(fs.createWriteStream('user_audio'));

Why is the file empty? I was speaking the entire time. Discord.js v12

sharp thicket
#

uh what are you hosting on @tired nimbus ?

tired nimbus
#

This is a test project

sharp thicket
#

so on ur local pc?

tired nimbus
#

no on a free server

sharp thicket
#

the one promoted?

tired nimbus
#

all dependencies with opus has been installed

sharp thicket
#

sorry i have to go good night!

proven lantern
#

ticket is still open

earnest phoenix
#

What is guild Limit without verification

ionic dawn
#

none

waxen tinsel
#

100

ionic dawn
#

100 can be online forever without verify, 101 will need verification

earnest phoenix
#

My have 31 guild without verification

#

My bot approved accept

#

??

waxen tinsel
#

?

#

What

tired nimbus
#
   const audio = await connection.receiver.createStream("372511780494114818", { mode: 'pcm' , end: "manual"});
console.log("test")

How would you end the stream? I didnt see it in the docs?

solemn latch
#

ngl, i forget what you wanted help with its been so long @earnest phoenix

tired nimbus
#

Discord.js v12

ionic dawn
tame kestrel
#

i

waxen tinsel
#

Why not put bottom line at top

earnest phoenix
#

no that would be faster code smh

ionic dawn
#

meh..

solemn latch
tame kestrel
#

why not have an object... with each badge name as a key... and just loop through userBadges....

earnest phoenix
#

What is guild Limit without verification approval limit

waxen tinsel
#

100

tame kestrel
#

100 right

tired nimbus
#

oh yes thank you

earnest phoenix
#

Thank u

waxen tinsel
#

||People literally already answered that in 2 different channels KEKW KEKW ||

earnest phoenix
#

Lol

ionic dawn
#

why not have an object... with each badge name as a key... and just loop through userBadges....
@tame kestrel cuz... I didnt think of it?

waxen tinsel
tame kestrel
#

u wrote so much code sadbearcat

earnest phoenix
ionic dawn
#

but it works

sudden geyser
#

enums my dude

waxen tinsel
#

Move the bottom line immediately

#

To the top

ionic dawn
waxen tinsel
#

At least

reef carbon
#

does anyone know how to set a sub-domain with cloudflare? I have an A record in my DNS pointed to my VPS IP address which I have my apache web server on. But when I search up the subdomain, I get this:

viral plover
#

Anyone know how to get promises to work with loops in javascript?
I've tried but I just don't understand them. It doesn't seem to make the loop wait for its completion.

quartz kindle
#

you cant use array loops with await

#

but you can use for loops

viral plover
#

Oh hey Tim.
Yeah, it's the same loop as last time. A for loop as opposed to a forEach.

quartz kindle
#

what is your code?

viral plover
#

I tried a lot of different things to get promises to work but this is what my code is now:

earnest phoenix
quartz kindle
#

@viral plover resolve() should be inside the visit callback, you only want it to resolve once the callback finishes

#

the promise itself still needs to be awaited

viral plover
#

Where in the promise declaration do I stick the await?

quartz kindle
#

await new Promise()

#

or a = new Promise(); await a

viral plover
#

Okay, thanks.
I'll try those.

quartz kindle
#

generally this is how you promisify a callback:```js
let data = await new Promise((resolve,reject) => {
someFunction((data, error) => {
if(error) reject(error)
else resolve(data)
})
}).catch(console.error)

tired nimbus
#
   const audio = await connection.receiver.createStream(bot.users.cache.get("372511780494114818"), {end: "manual"});
      setTimeout(async function () {
        connection.play(audio, { type: 'opus' });
    }, 5000);

Does anyone know why the play doesnt play the stream?
Im trying to record audio and play it back.

reef carbon
viral plover
#

What language?

#

Are you having trouble showing it how you want or getting the highest role?

earnest phoenix
#

hi

lone wyvern
#

help pls Error: ENOENT: no such file or directory, open '././jsonlar/hereEngelle.json'

narrow oak
#

Is there something against doing a naming feature in my bot and people use slur stuff in the name?

faint prism
#

../

#

Not./

#

./ Is current directory
../ is up one level

arctic delta
#

I am making a command with discord.js. The idea is that whenever I do .dc <user> it will disconnect them from a voice channel. However when I use the command it just tells me the user is not in a vc. No error messages. cant figure out what is wrong

indigo flax
#

i get this error when i start my bot

#
For help, see: https://nodejs.org/en/docs/inspector
internal/modules/cjs/loader.js:490
  throw new ERR_PACKAGE_PATH_NOT_EXPORTED(basePath, mappingKey);
  ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/rest/RequestHandler' is not defined by "exports" in /home/container/node_modules/eris/package.json
    at applyExports (internal/modules/cjs/loader.js:490:9)
    at resolveExports (internal/modules/cjs/loader.js:506:23)
    at Function.Module._findPath (internal/modules/cjs/loader.js:634:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:27)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/container/bin/framework/RequestHandler.js:5:24)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}```
sudden geyser
#

Can you show your /home/container/bin/framework/RequestHandler.js file

#

Just from searching around, it has something to do with requiring.

strong tundra
#

seems to be something to do with eris?

#

try downgrading/upgrading eris

sonic lodge
#

@arctic delta member.voiceChannel doesn't exist

arctic delta
#

oh

#

what should i change it to

sonic lodge
arctic delta
#

I saw that yea

#

no clue how to put it together tho

sonic lodge
#

member.voice.channel

arctic delta
#

ty

#

it worked but only for the mention, not the ID

#

Is that the proper way to have the ID as an alternative

sonic lodge
#

looks right to me

earnest phoenix
#

Hey, how can I program an Avatar command?

sudden geyser
#

What library are you using

earnest phoenix
#

Discord.js

#

I program in Visual Studio Code

sudden geyser
#

It returns the image URL of the user's avatar.

earnest phoenix
#

Thanks

whole knot
#

Hello, has anyone here ever worked with time-based events? I want my bot to post a message of my choice on a new day (00:00) each time. (I'll settle for any other time at first too, can be every 10 seconds).
I'm aware that this has to be done with a @task.loop function, but all documents on the internet don't help me, because most of the time you work with @bot.event or the client, but meanwhile I only use the commands functions.
Right now I have this as an example of how I would start:

@tasks.loop(hours=24)
async def msg1():
    message_channel = bot.get_channel(705524214270132367)
    await message_channel.send("test 1")

but after that I'm at a loss, because get_channel is not found as a referrence in bot.py either.
Can someone help me here?

sudden geyser
#

because get_channel is not found as a referrence in bot.py either.
What do you mean? Was the channel not found? Did you get an error?

earnest phoenix
wicked sapphire
#

At least don't use it if you're gonna make a bot.

sonic lodge
#

java is not javascript

modest smelt
#

If I have a user id, how do i find their name?

#

in dpy

sudden geyser
#
  1. repl.it is not a good site if you want to run a Java bot.
  2. Java =/= JavaScript
  3. Do you have a good understanding of Java, because those are a lot of errors which most can be solved easily.
earnest phoenix
#

java is not javascript
@sonic lodge oh..... then what i use?

modest smelt
#

If I have a user id, how do i find their name?
in dpy

wicked sapphire
sonic lodge
#

whichever language you want

wicked sapphire
#

It'll show you their nickname as a ping.

modest smelt
#

i don't want to ping them @wicked sapphire

#

i want to find their name

#

like MisterBlob

#

like that

#

MisterBlob

earnest phoenix
modest smelt
#

@earnest phoenix i dont suggest u use repl.it

wicked sapphire
sonic lodge
modest smelt
#

how would i do that?

earnest phoenix
#

i use chromebook so... only that way i can doing code or i have to use discord bot and ghostbot togther

wicked sapphire
#

personal or school chromebook?

earnest phoenix
#

personal

modest smelt
#

then download an IDE

sonic lodge
#

you can install linux on it

wicked sapphire
#

You could install Windows or linux on it.

sonic lodge
#

windows on a chromebook?

modest smelt
#

If I have a json file, with bunch of items in a dictionary in the order like this: "id number": int(number of points), how can i order them and send it to the user?

earnest phoenix
#

chromebook not have windows lol

wicked sapphire
#

You can install it lol

earnest phoenix
#

..... really?

sonic lodge
#

you might as well get a windows laptop

modest smelt
#

bruh

earnest phoenix
#

oh

wicked sapphire
#

I built my PC

earnest phoenix
#

well i soon get PC

#

wait how i can build PC?

#

i want try it

modest smelt
#

If I have a json file, with bunch of items in a dictionary in the order like this: "id number": int(number of points), how can i order them and send it to the user?

earnest phoenix
#

i dunno

sonic lodge
#

dont answer if you dunnno

unborn perch
#

What are the rate limit on messages?

sonic lodge
#

iirc, 5 messages per 5 seconds per server

unborn perch
#

ok

sudden geyser
#

@modest smelt If you want to sort the values of the dictionary, you need to use sorted, get all items (keys & values), and judge from there. It's easier to explain how to do it with source code: https://stackoverflow.com/a/2258273

modest smelt
#

ok thanks

#

ill take a look

#

@sudden geyser so when you do sorted(d.values()) what does the list contain?

#

ok i see that

sudden geyser
#

An array of the values sorted.

#

But keep in mind that doesn't include the keys.

modest smelt
#

so if i get it sorted

#

how should i find the corresponding keys?

sudden geyser
#

You sort the items (both keys and values). You'll get an array of tuples where the first item is the key and the second one is the value.

#

The link I gave you shows you how.

modest smelt
#

ah ok

shy turret
#

is it possible to loop through every variable on an object that isnt an array

#

for example

#
{
  "foo": "bar",
  "variable": "value"
}
#

and it would output to

#
[
  {
    "name": "foo",
    "value": "bar"
  },
  {
    "name": "variable",
    "variable": "value"
  }
]
sonic lodge
#

you can loop through the object's keys using for in, and then pushing each key / value pair to an array

shy turret
#

yah i found

sudden geyser
#

tbh I think Object.entries is a better choice unless you explicitly need it in that format you showed

lone wyvern
#

help pls

pale vessel
#

yo we're not your slaves where you can just send a code and we fix it

#

tell us the problem

wicked sapphire
#

Make sure you defined what 'db' is near the top of your code. I think database?

tame kestrel
#

Hi! Is there a better way of doing this in typescript?

In example:

// Currently what I'm doing is initializing a variable that is either a desired object or undefined
const guild: Guild | undefined = <Message>.guild;
// Then right after I am just doing this:
if (!guild) return;

I could force it using the ? i.e msg.guild?.id but I don't know if that's the best option or if it works the way I have it above.

proven lantern
#

is there a better way to check the permission type that is missing?

    catch (error) {
        if (error.path.match(/\/guilds\/\d*\/channels/)) {
            msg.reply(`The bot is missing **Manage Channels** permissions. \n`).catch(console.log);
        } else if (error.path.match(/\/channels\/\d*\/permissions\/\d*/)) {
            msg.reply(`The bot is missing **Manage Roles** permissions. \n`).catch(console.log);
        } else if (error.path.match(/\/channels\/\d*\/invites/)) {
            msg.reply(`The bot is missing **Create Invite** permissions. \n`).catch(console.log);
        }
    }
quartz kindle
#

@tame kestrel im not a ts user, but i'd say const guild: Guild? = <Message>.guild

tame kestrel
#

Are you relying on an error to check permissions? I would take the time to check for permissions before you try doing anything rather than feeling the error after @proven lantern

#

@tame kestrel im not a ts user, but i'd say const guild: Guild? = <Message>.guild
@quartz kindle No that isn't a typescript feature. At least the compiler doesn't like that LOL

I think asking here may be a little futile, maybe I'll whip out the ts docs and do some research

quartz kindle
#

i forgot the syntax

#

basically make it nullable instead of oring an undefined

#

nevermind, i think im confusing it with type declarations

blissful coral
#

^

#

Donโ€™t remember exactly how lmaoooo

tame kestrel
#

maybe, from what I see online, I think I'll just stick with what I have

#

ty for the help @quartz kindle @blissful coral ,

for some stuff like if I don't need to return instantly if it doesn't work, I can use something like this:

let prefix = serverCache.get(guild.id)?.config?.prefix || ';';```
where if `serverCache` has `config`, or even `prefix` `undefined`, it will set `prefix` as `;`.

I think I'll keep looking for an even more elegant solution but it seems like the docs don't have anything at the moment
drifting wedge
#

does my bot need to be big to apply for higher / no ratelimits?

#

or is it on the bases on need?

#

like we have a feature that uses a ton of the ratelimit

pale vessel
#

if your bot isn't as big as dyno or mee6, then you i doubt you can apply for it

#

like we have a feature that uses a ton of the ratelimit
@drifting wedge then don't make such feature

#

it's risky

drifting wedge
#

ik we want to apply for it

#

but like is it on the basis of bot being big

#

or just as needed?

tame kestrel
#

big

#

they'll want u to try to do everything u can to use as little as possible

drifting wedge
#

they'll want u to try to do everything u can to use as little as possible
@tame kestrel o ok

#

how much is ratelimits usually?

#

ik its not specified

#

but like on avg?

tame kestrel
#

for normal bots? idk

#

I think like 5 times per second

#

idk tbh

sudden geyser
#

like we have a feature that uses a ton of the ratelimit
@drifting wedge they'll probably just tell you to optimize your bot. Big bots is like 100k+

drifting wedge
#

@drifting wedge they'll probably just tell you to optimize your bot. Big bots is like 100k+
@sudden geyser its not optimization

#

its like cuz we need to

#

its something we cant talk about yet

#

but like 100k?

#

ehh

#

thats acheivable

tame kestrel
#

usually if it goes against the ratelimit then they'd probably not want something like it on their platform

drifting wedge
#

well we can def make it slower

tame kestrel
#

stuff like dynamic role colors, etc

drifting wedge
#

oh

#

yea

#

not that but i get it

#

discord i think would love it tho

#

its really "their style"

sudden geyser
#

If your bot is where it needs to hit the API a ton and want higher rate limits as a result, it may be in your favor to try refactoring how you use it. I don't think you'll need to worry about it soon, especially since the max limit right now is 10,000 requests per 10 minutes.

carmine summit
#

How do I get the guild with most members???

#

i see .min()

tame kestrel
#
const guildCounts = client.guilds.cache.map((guild) => guild.memberCount);
console.log(Math.max(...guildCounts.values()));```
#

I tried it on my test bot... dunno if it works since it's in like 2 guilds

#

client is the Discord.Client object

opal plank
#

mine would be a bit bigger tbh

tame kestrel
#

wait crap that only returns the largest count huh

#

close enough

#

wait maybe u can make it smaller let me try poking it a bit more

opal plank
#
let biggest;
let count = 0;
for(let g of client.guilds.cache)
if(g.memberCount > count) { biggest = g; count = g.memberCount} 
#

biggest will now be your guild

#

reduce might've been a better call tbh

#

i just like to use for loops

carmine summit
#

wtf does ... do?

sudden geyser
#

spread operator

opal plank
#

actualy yeah i think i can use vars for this

sudden geyser
#

really the answers here are how efficient can you make this in Big O notation

#

but both methods work

blissful coral
#

@tame kestrel no problem

pale vessel
#

i made this: client.guilds.cache.reduce((x, y) => x = y.memberCount > x ? y.memberCount : x, 0);

opal plank
#

damn, good shit flaze

proven lantern
#

@pale vessel the x = y.memberCount isn't needed
client.guilds.cache.reduce((acc, guild) => guild.memberCount > acc ? guild.memberCount : acc, 0);

pale vessel
#

nice

sudden geyser
#

could get even shorter: js client.guilds.cache.reduce((max, guild) => { x = Math.max(x, guild.memberCount); }, 0);

#

and yeah what ben said

proven lantern
#

@sudden geyser combined
client.guilds.cache.reduce((acc, guild) => Math.max(guild.memberCount, acc), 0);

sudden geyser
#

yes

pale vessel
#

reduce is underrated ngl

glad charm
#

I hardly if ever use it

proven lantern
#

i never use the let keyword in javascript

glad charm
#

what

#

you probably use var

#

disgusting

proven lantern
#

only use const

glad charm
#

const > let> never var

#

LOL

#

only

pale vessel
#

how do you only use const

proven lantern
#

i failed if i use let

glad charm
#

a million functions

#

lmfao

proven lantern
#

map, reduce and filter

#

why do you need let with those functions?

modest smelt
#
dicname = {"1": 1, "2": 2, "3", 3}
for item in sorted(dicname.items(), key = lambda p: p[1]): 
  print("{0}: {1}".format(*item))

How can I order this so that it prints from greatest to highest

proven lantern
#

greatest to highest

#

yes

wicked sapphire
#

That just confused me.

slender thistle
#

Uhhhh

#

Uhhh

#

Dictionaries and sets aren't sorted

#

from greatest to highest

#

wha

modest smelt
#
@client.command()
async def leaderboard(ctx):
  with open('pointspotd.json', 'r') as json_file:
    lead = json.load(json_file)
  embed = discord.Embed(title = "Leaderboard", description = "This the leaderboard in The Calt Server.")
  for item in sorted(lead.items(), reverse=True, key = lambda p: p[1]): 
    idofuser = int("{0}".format(*item))
    points = int("{1}".format(*item))
    user = client.get_user(idofuser)
    embed.add_field(name = f"{user.mention}", value = f"Points: {points}", inline = False)
  await ctx.send(embed = embed)
```Do you know what is wrong with this?
#

Nothing is sending.

slender thistle
#

How do you even want to sort the dictionary

earnest phoenix
#

greatest to least by value

#

thatโ€™s correct

#

we tried in separate code

slender thistle
#

What does the dictionary consist of

drifting wedge
#

How does clustering work for dpy

#

Ping pls

tame kestrel
#

is there any way I can get the image above text in an embed

#

I suppose not

glad charm
#

?

pure lion
#

You could use thumbnail

#

It kind puts it to the top right

#

But otherwise no I don't think you can

tame kestrel
#

yeah I was hoping for something like

pure lion
#

Hmmm

#

I can't think of anything other than sending two embeds

abstract coyote
#

you could use the author property, but the image is rather small.

tame kestrel
#

just a little haha

abstract coyote
#

yea just like a litttle bit.... ...

#

its not like u barely see it or anything /shrug

#

BRUHH

tame kestrel
#

what I might do is upload the image as an attachment with the embed right below but in the same msg

abstract coyote
#

or yiu could use canvas nad make the entire thing an image

#

and then you can put the image on top of text

#

however its a pretty bad way and embeds are better all the time

tame kestrel
#

yes I agree

tribal dove
#

sup ppl

fluid widget
tribal dove
#

cause its in more than 75 servers and u have not verified it

compact oriole
#

no you are wrong @tribal dove

#

The bot uses gateway intents that it hasn't been verified for, but the bot is verified

#

so you need to re-verify it

small prairie
#

F

#

Anyone has any idea about ploxhost?

obtuse jolt
#

I dislike the guy that runs it

small prairie
#

I mean any reviews on their hosting?

#

Some original views not some paid ones or something

#

Also wtf is unlimited ram service lmao

rustic nova
#

Quick and best answer

#

Get a vps

pulsar bone
#

hey how can i store a message to use after 3 messages

old cliff
#

stupid question
How much memory do you think is enough for a bot in 100 servers ?

fluid basin
#

many factors, there isn't an accurate answer

#

depends on your code, if you're using crazy memory for whatever reasons then you might need more

#

but generally 1GB is more than enough

old cliff
#

Then my raspberry can handle it thanks

pale vessel
#

1gb is more than enough if you have a good memory management

old cliff
#

K

pulsar bone
#

hey how can i store a message to use after 3 messages

#

give me answere please

ionic dawn
#

Im running 4 bots at the same VPS and the use 1.5GB x_psstitsfree

earnest phoenix
#

store the message object in a database @pulsar bone

#

but generally 1GB is more than enough
@fluid basin *minecraft intensifies*