#development

1 messages ยท Page 731 of 1

earnest phoenix
#

Mmmh i take notes

spice trail
#

You can do / btw aswell

earnest phoenix
#

@west raptor let is an global definition that can be changed in {} and var can't be changed in {}:

(function () {
let letter = 'A'; 
if (letter.length) {
console.log(letter); // undefined
let letter = 'B';
console.log(letter); // B
}
console.log(letter); // A
})();
#
(function () {
var letter = 'A';
if (letter.length) {
console.log(letter); // A
var letter = 'B';
console.log(letter); // B
}
console.log(letter); // B
})();
lavish shuttle
#

@hoary elm try avoiding message.mentions

late hill
#

or like

#

wherever you check if they used a mention to prefix

lavish shuttle
#

Instead, get the arg string, run it under a regex

late hill
#

just remove the bot mention from the array

hoary elm
#

๐Ÿค” Alright. Thanks for the suggestions ๐Ÿ˜

quartz kindle
#

it would be easier if you showed you code =P

hoary elm
#

For which part @quartz kindle the handler or the command

#

That's why i didn't post it wasn't sure which one to post

quartz kindle
#

both

hoary elm
#

One sec

#

The message.js is where the @mention prefix is... It's still there but I have it currently reading it's normal prefix untill I work out the problem

quartz kindle
#

define these outside of the function ```js
const ninjaPrefix = (@solar pine);
const prefix = process.env.PREFIX;

else youre redefining them on every message.
also, those parenthesis are unneeded, in fact the entire ninjaPrefix is uneeded
#

you can remove it

zealous veldt
#

In express (js), if I set a value onto the request object using a middleware, can the next middleware access that value? I use two pieces of middleware on a route, and in the first one, I set req.user to an object, in the second piece of middleware, can I access req.user? I'll post more details if needed, please ping me with responses.
First middleware

//...
req.user = user // user is an object that I get from my db, I know this works
next()

Second middleware

//...
const { user } = req
//...
quartz kindle
#

i would actually replace both of those lines with the following: js const prefixes = [process.env.PREFIX,"<@YOURID>","<@!YOURID>"]

#

then inside the function you can do js if(prefixes.some(prefix => message.content.startsWith(prefix)))

#

that will test for all three prefixes, normal prefix, mention prefix, and mention prefix with custom nickname

#

@zealous veldt afaik yes

zealous veldt
#

Strange, because req.user is undefined in the second one

quartz kindle
#

do you need the next() at the end of the first middleware? i dont know much about express, but from what i remember, next() causes it to end the current request and continue to the next one. you might have to put the next() at the end of all middlewares

zealous veldt
#

I do have next at the end of all my middleware

quartz kindle
#

i mean, only at the end of the last one

zealous veldt
#

ah, so try removing it from the first one?

quartz kindle
#

yeah

#

scratch that actually, stackoverflow says to use res.locals

#

and im wrong about next() apparently

zealous veldt
#

yeah without next in the first one it never reaches the second

hoary elm
#

@quartz kindle thank you ๐Ÿ˜

#

Sorry forgot to say that

zealous veldt
#

So in the first one, I should be doing res.locals.user = user?

#

This middleware is also used by itself for other routes, so I'm not sure if changing it is the right call unless I have to

quartz kindle
#

supposedly yes

#

i cant test because i dont use express

zealous veldt
#

oh

#

turns out I had a typo lmfao

quartz kindle
#

oh lul

zealous veldt
#

My original code worked once I fixed it

quartz kindle
#

rip xD

#

@hoary elm in your ban command, you have to change this let user = message.mentions.users.first();

#

that gets the first mention, if you use bot mention, the first mention is always gonna be the bot

twilit rapids
#

Wouldn't it be better to use message.mentions.members.first(); since ban commands can only be used in a server

shy turret
#

instead of just using client.ping, how do you also get the api ping, ram usage, etc?

#

discord.js

#

I can't find anything online

quartz kindle
#

ram usage: process.memoryUsage()

shy turret
#

all i see is client.ping and Pong!

twilit rapids
#

isn't client.ping the web socket ping which is the API ping

quartz kindle
#

^

shy turret
#

oh then i was dumb for like eternity

twilit rapids
#

@quartz kindle I love your custom status

quartz kindle
#

uvuvwevwevwe onyetenyevwe ugwemubwem ossas

twilit rapids
#

I am 99,99% sure that's not an existing language

quartz kindle
#

you are correct lul

zealous veldt
#

What an inspiring status

quartz kindle
#

im known in several servers for randomly saying uvuvwevwevwe onyetenyevwe ugwemubwem ossas in chat

twilit rapids
shy turret
twilit rapids
#

It would save some milliseconds though

#

Uh

quartz kindle
#

yes, members is better, but it doesnt really matter, he should be checking for dms and returning before it reaches that point, and he should be checking if the first mention is the bot~

shy turret
#
        const embed = new Discord.MessageEmbed()
          .setAuthor('Ping')
          .setColor("RANDOM")
          .addField('API', Math.round(client.ping), true)
          .addField('Memory Usage', process.memoryUsage(), true)
        message.channel.send({embed});
#

did they remove client.ping on the master version of discord.js?... gotta read docs again

twilit rapids
#

they did iirc

zealous veldt
#

its client.ws.ping now I think

twilit rapids
#

and process.memoryUsage() returns rss, something, heapUsed and heapTotal

zealous veldt
#

I could be wrong though

digital sparrow
#

How to how to

zealous veldt
#

-moreinfo

gilded plankBOT
#

If you want people to be able to assist you, please provide more information, such as what library and language you're using, the code in question and what you are trying to do and/or what is causing the error.

quartz kindle
#

how to do

twilit rapids
#

So you want to do process.memoryUsage().rss

shy turret
#

what happened to client.ping... it worked for me a long time ago...

quartz kindle
#

and probably want / 1024 / 1024 toFixed(2) + "MB"

shy turret
#
Memory Usage
52592640

amazing

#

oh thanks

shy turret
#

thxs again ill try it

quartz kindle
#

pitty my message viewer cant be in this channel

shy turret
#

yah i really need math.round

earnest phoenix
#

hey guys? how should i make this look prettier

#
let announcementType = args[0];
if(announcementType == "urgent"){
    announcementType = "@everyone";
} else if(announcementType == "moderate"){
    announcementType = "@here";
} else {
    announcementType = "";
}
slender mountain
#

what is that code supposed to do pepesweat

tranquil drum
#
const typeMap = {
  'urgent': '@everyone',
  'moderate': '@here',
};
let announcementType = typeMap[args[0]] || '';
summer torrent
quartz kindle
#

where did you see that ms().minutes is a thing?

earnest phoenix
#

@slender mountain for an announcement command

floral stone
#
class Shop(commands.Cog):
    """Alice | Shop Module"""

    def __init__(self, bot):
        self.bot = bot
        self.bot.loop.create_task(self.update_shop())
        self.today = "2018-7-6"

    
    async def update_shop(self):
        now = datetime.now()
        day = "{}-{}-{}".format(now.year, now.day, now.month)
        if day != self.today:
            chars = await self.bot.get_cog("Alice").chars()
            shop_chars = []

            c = 1
            while c <= 12:
                x = choice(chars)
                p = await self.bot.get_cog("Alice").char_field(x, "price")
                if p == "":
                    continue
                elif p == 7341:
                    continue

                shop_chars.append(x)
                c += 1

            self.update_shop_file(shop_chars)
            self.today = day
        
        await asyncio.sleep(300)```
#

That is my code, however the code is not properly looping.

tacit stag
#

is there a way to detect if the number of fields pushed to an embed is too long in discord.js

floral stone
#

It runs once.

tacit stag
#

for example, im pushing ~105 items into "fields: []", and im trying to create multiple pages with it

quartz kindle
#

the limit is 25

#

so just check when it reaches that

slender mountain
#

Are you talking about the character limit?

quartz kindle
#

field limit

#

how many fields can you have in a single embed

tacit stag
#

got it

#

thanks

#

anclint no the field limit

floral stone
#

Nvm I figured out a fix.

earnest phoenix
#

Am I allowed to view the servers my bot is in and some of their info? This info would be private and only accessible by me.

sudden geyser
#

yes

earnest phoenix
#

Okay, thanks!

earnest phoenix
#

@coral trellis can i get total votes of month
and total votes of a user of a month
Or should i save these data myself ?

coral trellis
sick cloud
#
Building dependency tree
Reading state information... Done
Package qemu is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'qemu' has no installation candidate```
what's up here
unique nimbus
#

It doesn't have any url which has qemu however it is used in other sources

#

You might need to install from source however kdk

sick cloud
#

i am using the command from there

#

apt-get install qemu

#

so

unique nimbus
#

Try installing by source

sick cloud
#

can't

#

i'm using WSL and can't muck around with it much

earnest phoenix
#

haii quick question

~slap <userid> <more stuff>

How do I get <more stuff> more correctly on removing both ~slap and <userid>

slender mountain
#

wdym?

#

@earnest phoenix

earnest phoenix
#

pratically just get <more stuff> content

compact oriole
#

tf you mean

slender mountain
#
let args = message.content.split(" ").slice(1);
if (command === "slap") { // your command code
    let userid = args[0]; // grabs userid from message after prefix
    let moreStuff = args.splice(1).join(" "); // anything after userid from message
    // whatever you want to do with the user input
    console.log(userid);
    console.log(moreStuff);        
} 
valid frigate
#

where is command defined

slender mountain
#

idk im trying to help him

earnest phoenix
#

I see, i already have command defined dw. Thanks for the explanation

#

i need to get used to args

hollow granite
#

Anyone know why my bot is offline but only on some servers? Is it something to do with sharding?

valid frigate
#

well are you using sharding

hollow granite
#

yes

#

and i am very new to it

valid frigate
#

one of your shards probably died and never reconnected

hollow granite
#

so i should just restart the bot?

valid frigate
#

you could, but id also advise looking into why your shards arent reconnecting successfully

hollow granite
#

ok, thanks :)

valid frigate
#

np

#

also anyone know the best way to find the actual position of a role in a server that's more simple than abs(role.positionRaw - guild.roles.size)? i feel like i'm overcomplicating things

#

this is in jda

earnest phoenix
#

Hi i try to make an clear command
=> z!clear 99

#

Can someone help me? sad

slender mountain
#

Do you have any code?

earnest phoenix
#

Nope i have no idea how it works

slender mountain
#

hmm

#

That's what you can use to do it

#

It's discouraged to just give people the finished code, it prohibits the learning process.

#

Why don't you try to get it to work and ask for help again if what you've come up with still doesn't work?

split lantern
#

Only use fetchMessages when you want to do some filtering

#

Because bulkDelete() on stable pretty much calls fetchMessages() internally again

slender mountain
#

true

#

I put together a prune command years ago, so it might be a little outdated haHAA

split lantern
#

Well d.js master iirc, does not use fetchMessages again if you did outside of it

earnest phoenix
#

Oki and thanks

restive night
#

can i ask about algorithm?

vital lark
#

wha

rustic pond
#

Hey guys, Having some issue ,
my command pulls the name of from my .json file but in some json files i wanne include a space but if i do it it doesn't recognize the space

sudden geyser
#

your command name has a space in it, because you're splitting by every space and only grabbing the first part of it?

compact oriole
#

if its a josn file, you can

#
const json = require("path to file");
#

and then its lije js

rustic pond
#

OK gonna try that thanks!

#

Hmmmm I already have that affex but it still doesn't allow the space for some reason ๐Ÿค”

earnest phoenix
#

I was read the documentation, but isn't working

rustic pond
#

so @compact oriole wha i currently have is this :
const champ = require(`../datas/${champN}.json`);

compact oriole
#

should work

quartz kindle
#

@earnest phoenix it is working

rustic pond
#

yup but really doesn't allow the space for some reason

quartz kindle
rustic pond
#

might it be something todo with this ? :
const champN = args[0].toLowerCase();

compact oriole
#

what?

earnest phoenix
compact oriole
#

idk why that doesnt work

#

hmmm

rustic pond
#

so i got it currently like this on my command :

    await message.delete();

    if (!args[1]) return message.reply('no champion setted.').then(msg => msg.delete(8000));
    const champN = args[0].toLowerCase();

    fs.access(`./datas/${champN}.json`, fs.F_OK, (err) => {
        if (err) {
        return message.reply('unknown champion.').then(msg => msg.delete(8000));
        }```
#

if it is 1 word it works

#

for example my prefix is $stats charactername that works but $stats character name doesnt work

quartz kindle
#

@earnest phoenix show code

compact oriole
#

it should be args[1].toLowerCase();

rustic pond
#

Okey lets try that ๐Ÿ™‚

earnest phoenix
#

error : Error: ENOENT: no such file or directory, stat '/app/databaseBots/:id.json' @quartz kindle

#

?

quartz kindle
#

show code

compact oriole
#

Why you pinged me??

#

I was talking to Benn

earnest phoenix
#

Iam sorry

#

@quartz kindle


app.param("id", function(req,res,next,id){
req.id = id;
return next()
})

app.get("/api/bots/:id", function(req,res){
if (isNaN(req.id)) res.send("Error")
if (!__dirname + `/databaseBots/${req.id}.json`) res.send("404")

res.sendFile(__dirname + `/databaseBots/${req.id}.json`)
})```
quartz kindle
#

if you're using express, you should be able to do js app.get("/api/bots/:id", function(req,res){ let id = req.params.id })

#

no need for app.param()

late hill
#

@rustic pond that code allows the user to select a path at own will

#

They could make use of / & .'s to select files that you probably don't intend them to use

rustic pond
#

indeed that is what we need for example people want information from a specific champion they put in $stats championname

#

so thats alright

late hill
#

If you're still having issues with spaces in arguments you might want to take a moment to try and understand what exactly args is and what it'll look like when people use spaces

#

You're usually splitting it on a space

#

meaning the thing after the space will be the next argument

#

in your args array

#

indeed that is what we need for example people want information from a specific champion they put in $stats championname
Yes but they could do something like $stats ../../../config

#

and possibly access a config file you have somewhere

rustic pond
#

hmmm ok might look into it thanks !

earnest phoenix
#

@quartz kindle


app.get("/api/bots/:id", function(request,response){
let id = request.params.id;

if (!__dirname + `/databaseBots/${id}.json`) response.send("Error")

response.sendFile(__dirname + "/databaseBots/${id}.json`)
});```
#

?

quartz kindle
#

this line if (!__dirname + `/databaseBots/${id}.json`) response.send("Error") is not doing anything

#

you can remove it

#

and you forgot a ` on the last line

#

you have " `

#

instead of ` `

earnest phoenix
#

Thank you

#

if (id < 17) response.send("Invalid bot id")

#

This is work

#

but

#

my package get an data is SLOW

earnest phoenix
#

Can you help me please? I don't know what to do.

/Elo/node_modules/discord.js/src/structures/interfaces/Collector.js:203
  async *[Symbol.asyncIterator]() {
        ^

SyntaxError: Unexpected token *
#

does c have something equivalent to qsort but for shuffling?

#

No.

normal quail
#

hello guys

#
client.on('ready', ()=>{
  client.user.setGame('long live for pigs!!')
  client.user.setStatus("long live for pigs!!")
  setTimeout (updateOnStart, 1000, client.guild)
})

function updateOnStart (guildd) {
  for (var i = 0; i < guildd.channels.array().length; i++) {
    if (guildd.channels.array()[i].name.slice(0 , 15) == "Voice Online : ") {
      maked = true;
      break;

    } else if (guildd.channels.array()[i].name.slice(0 , 16) == "Members Count : ") {
      maked = true;
      break;
    };
  };
  if (maked == false) {
  setTimeout ( save, 1000, guildd);
} else {
  setTimeout ( save, 1000, guildd);
}
}

grim aspen
#

um

normal quail
#

so why i got error in this code

#

for (var i = 0; i < guildd.channels.array().length; i++) {
^

TypeError: Cannot read property 'channels' of undefined

grim aspen
#

guildd

twilit rapids
#

guildd is undefined

normal quail
#

chech the timeout code

#

setTimeout (updateOnStart, 1000, client.guild)

mossy vine
#

this code has so many issues i dont even know where to start

normal quail
#

i need just a way to get the guild at which the bot started on it

#

so i can get all channels and make my own stuf

#

f

#

and this is my problem i think

#

and this is the reason of error

twilit rapids
#

I would recommend to learn some more about JavaScript

#

Before you continue

normal quail
#

i will but just after fixing this

#

so if anybody have the solution will help me i will appreciate this too much

#

so ?>

#

no one know how to fix it ?

grizzled jackal
#

.

twilit rapids
#

-dotpost @grizzled jackal

gilded plankBOT
#

@grizzled jackal

Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.

normal quail
#

?

chrome verge
grim aspen
#

k n o w n i s s u e

earnest phoenix
#

I get this error, I know what it means but idk why it occurs.

/app/bot.js:82
    dbl.postStats(guildsSize, client.shards.Id, client.shards.total);
                                            ^
TypeError: Cannot read property 'Id' of undefined
at Timeout._onTimeout (/app/bot.js:82:45)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)
grim aspen
#

the I shouldn't be capitalized

#

@earnest phoenix

earnest phoenix
#

but it worked fine before...

amber fractal
#

client.shards is undefined

earnest phoenix
#

^

#

I know that, but why?

sudden geyser
#

I think you're looking for shard and not shards

#

also id's not capital

earnest phoenix
#

It first worked, and it's like that on top.gg API page

#

@bitter sundial update ur API, it has some errors like these which make it a bit annoying to work with.

#

and with first I mean about 23 hours ago

bitter sundial
earnest phoenix
#

yeah, I'm checking if it's fixed now. But it's literally copied from the API page and doesn't work since today.

bitter sundial
#

that's a problem with your code

earnest phoenix
#

yesterday it somehow did...

#

but it's copied literally from ur API page.

bitter sundial
#

it's an example

#

not a copy-paste solution

earnest phoenix
#

an example which doesn't work, idk why it doesn't now and did yesterday.

bitter sundial
#

your bot doesn't seem to be sharded so you can get rid of those

earnest phoenix
#

if I don't use shards... how do I post the servercount?

grim aspen
#

it should post it by the amount of guilds it's in

bitter sundial
#

if you'd read the documentation you'd notice shards are optional

earnest phoenix
#

...

#

k

south swallow
#

This is the code im trying to make workasync def _chem(self, ctx, arg): if arg.lower() in elements_number: file = discord.File(f'chemistry/{arg.lower()}.png',filename = f'{arg.lower()}.png') embed = discord.Embed(title='Information of : {}'.format(arg.capitalize()),description=(f'**Atomic Number: ** {(elements_number[arg])}\n**Atomic Mass: **{elements_mass[arg]}'), color=0x0000ff) embed.add_field(name=(f'**State at 20ยฐC :** {(elements_state[arg])}\n**Melting Point:** {(elements_melting[arg])}\n**Boiling Point: **{elements_boiling[arg]}'),value=f'**Description: **{elements_disc[arg]}',inline=False) embed.set_thumbnail(url=f"attachment://{arg}.png") await ctx.send(file=file,embed=embed) else: await ctx.send('Not a valid element.')

#

and the error im getting is this ```Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped
ret = await coro(*args, **kwargs)
File "/home/george/Documents/testing/cogs/chemistry.py", line 870, in _chem
file = discord.File(f'chemistry/{arg.lower()}.png',filename = f'{arg.lower()}.png')
File "/usr/lib/python3.7/site-packages/discord/file.py", line 68, in init
self.fp = open(fp, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'chemistry/hydrogen.png'

earnest phoenix
#

I see, what's the error?

south swallow
#

i am confused since the directory exists

#

an works with the directory given is a string

#

like "chemistry/hydrogen.png"

#

but with variables it doesnt

marble juniper
#

sorry if I am interrupting but how can I make a link box so only 1 link is affected in css and not every link on the page

vital lark
#

@south swallow it means the file or directory doesn't exist

earnest phoenix
#

the script for the bot is /home/george/Documents/testing/cogs/chemistry.py, then the png should be at /home/george/Documents/testing/cogs/chemistry/hydrogen.png

#

@marble juniper use classes

#

or ids

marble juniper
#

but im a noob in css

#

cuz I wanted to add a link button in my bot desc

south swallow
#

sorry still nothing

#

i thing discord py cant handle variables in the url?

#

bc chemistry/hydrogen.png works on its own

earnest phoenix
#

@south swallow are you sure the png is at /home/george/Documents/testing/cogs/chemistry/hydrogen.png?

south swallow
#

there is no need for the whole directory

#

yeah im preety sure

#

it works with a string provided

#

instead of embed.set_thumbnail(url=f"attachment://{arg}.png") --> embed.set_thumbnail(url="attachment://hydrogen.png")

earnest phoenix
#

that works?

south swallow
#

yeah

earnest phoenix
#

hmm

#

try using embed.set_thumbnail(url="chemistry/" + arg + ".png")

south swallow
#

still nothing

earnest phoenix
#

still same error?

south swallow
#

its weird , its like it doesn't want any arguments

#

just a raw string

#

even if the string with arg combined is still valid

#

i tried saving example = attachment://hydrogen.png in a variable

#

and it does not work

#

but if i put it alone

#

attachment://hydrogen.png

#

it works

earnest phoenix
#

hmmm

#

that's really weird

south swallow
#

ikr

earnest phoenix
#

wait

#

example = attachment://hydrogen.png

#

exactly that line?

#

or like example = "attachment://hydrogen.png"?

south swallow
#

2nd one

#

and then i put the example variable

#

to test it

earnest phoenix
#

still getting the same error?

south swallow
#

embed.set_thumbnail(url=example)

#

yeah lmao

#

it does not allowe me to use variables in the thingy

#

;-;

earnest phoenix
#

but like.... that's python logic, it should work.

south swallow
#

im lost aswell

#

i'll try to the discord rewrite "discord" to see if they have a solution or its a know bug

#

but i doubt it

#

i must be doing something wrong

earnest phoenix
#

idk, well actually yes, but idk what's wrong with that one part

south swallow
#

you want the full thing?

earnest phoenix
#

if it doesn't leak any tokens, sure

south swallow
#

no its a cog so

#

i think im covered

#

em

#

how do i go abou this

#

do i just send the .py

#

or

#

idk

earnest phoenix
#

and btw, block _chem if the argument has .. in it, otherwise I could just make it send over the bot's script by using ../chemistry.py as argument.

south swallow
#

?

#

what do you mean?

south swallow
#

nvm they are not really usefull, i'll try to tackle this another time. If you find anything please let me know

sterile minnow
#

have someone a cool CSS code for my Bot page?

earnest phoenix
#

display: none;

unique nimbus
#

I agree

#

I use it on my website and it makes stuff neat

earnest phoenix
#

Can agree with the people above

amber fractal
#

body{
display: none;
}
Yeah

#

I agree woth that too

earnest phoenix
#
html {
 display: none;
}```
#

Bruh....

#

moment...

amber fractal
#

<script>document.head.remove();document.body.remove();</script> no idea if this works would be great if it did

earnest phoenix
#

why does't discord use this?

#

It might work then

#

๐Ÿ˜

amber fractal
#

Yeah

earnest phoenix
#

What not

#

Why *

normal quail
#

guildIDs[guildIDs.length + 1] = client.guilds.array()[k].id;

#

ehats wrong here ?

#

whats*

earnest phoenix
#

What's "k"?

mossy vine
#

hopefully a number

earnest phoenix
#

Yep

#

naw k is a letter

#

Bruh but

#

k = ?

normal quail
#

k is counter in for loop

earnest phoenix
#

what error are you experiencing?

normal quail
#
for (var k = 0; k < client.guilds.array().length; k++){
    for (var i = 0; i < client.guilds.array()[k].channels.array().length; i++) {
      if (client.guilds.array()[k].channels.array()[i].name.slice(0 , 15) == "Voice Online : ") {
        client.guilds.array()[k].channels.array()[i].setName(`Voice Online : ${client.guilds.array()[k].members.filter(m => m.voiceChannel).size}`)
)

      } else if (client.guilds.array()[k].channels.array()[i].name.slice(0 , 16) == "Members Count : ") {
        client.guilds.array()[k].channels.array()[i].setName(`Members Count : ${client.guilds.array()[k].memberCount}`)
        if (guildss.length > 0){
          guildss[guildss.length + 1] = client.guilds.array()[k].id;
        }else if (guildss.length == 0){
          guildss[guildss.length + 1] = client.guilds.array()[k].id;
        }
        
     };
    };
#

the error is when calling my array

#

in htis way

#
for ( var i = 0; i < guildss.length; i++){

    console.log(guildss[i])
  }
mossy vine
#

how is guildss defined

normal quail
#

it gives my one element id and one undefined and one id and one undefined and so on

#

var guildss = [] ;

mossy vine
#

yeah thats why

#

its empty lmao

normal quail
#

you mena

#

mean

#

var guildss = [""];

#

this will remove the undefined error ?

#

this what i got in console


undefined
407226789912379422
undefined
633750086459064320

earnest phoenix
#

How to verify if a role is deletable?
discord.js@11.5.1

#

check Role#manageable

#

and check Role#position

#

and compare it to see if you have the permission to even edit that role

smoky spire
#

That's what manageable does

earnest phoenix
#

Ty :)

#

Oh

smoky spire
#

No need for both

earnest phoenix
#

lol

sick cloud
#

how do you use those strip indents thing

earnest phoenix
#

stripIndent(string)

sick cloud
#

no i'm using common-tags

#

and neither work

earnest phoenix
#

When i use dbl.postStats(client.guilds.size) its return's socket hang up wth?

vital lark
#

@sick cloud u need to do ```js
stripIndentSomething;

sick cloud
#

ohok

terse pier
#

is there any corountine function in discordpy to check if the user is bot owner?

#

or can it be somehow done with the @commands.has_permissions(...) corountine?

quartz kindle
#

check if the bot id equals the owner id

#

there is nothing connecting a discord user to a discord bot, you have to do that yourself and hardcode your id as the owner

spice trail
#

^^

#

U got to that before me f

quartz kindle
#

hue

earnest phoenix
#

there actually is ^^

#

there's a REST endpoint that's hittable by the bot which gives information about itself including the owner

shy turret
#

discord.js

#
TypeError: message.mentions.users.first(...).hasPermission is not a function
#
if (message.mentions.users.first().hasPermission(["ADMINISTRATOR"])) {
#

Is it possible to detect a permission from another user and how?

#

yes i tried searching stuff up, it is that there isnt much there about it or i phrased myself incorrectly

sudden geyser
#

you're checking if a user has permission, not a guild member

shy turret
#

how do you make it say it as a guild member

knotty steeple
#

msg.member

shy turret
#

*mentioned user

summer torrent
#

message.mentions.members

knotty steeple
#

^

shy turret
#

but isnt that every mentioned user?

knotty steeple
#

yes

sudden geyser
#

yes, so get the first one

knotty steeple
#

or the second one

#

do what u want

shy turret
#

first one

#

message.mentions.users.first() won't work, because it needs to be a mentioned member in the guild

summer torrent
shy turret
#

what's the difference between .members and .users

#

oh text channels only..

summer torrent
#

users means all of the discord users

twilit rapids
#

.members returns the guildMember object and .users returns the User object

knotty steeple
#

obviously

#

yes

shy turret
#

.members worked thanks!

summer torrent
#

๐Ÿ‘๐Ÿผ

shy turret
#

wait... it worked once... now it doesnt wtf

sudden geyser
#

did you mention anyone

shy turret
#

i didnt lol i just realized

#

fixed

shy turret
#
C:\Users\<username>\Desktop\Limiter>npm install discordjs/discord.js
npm ERR! code ENOGIT
npm ERR! Error while executing:
npm ERR! undefined ls-remote -h -t ssh://git@github.com/discordjs/discord.js.git
npm ERR!
npm ERR! undefined
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\<username>\AppData\Roaming\npm-cache\_logs\2019-11-18T22_50_50_816Z-debug.log
#

what does this mean?

twilit rapids
#

No git binary found in $PATH

#

Install git

shy turret
#

done

sick cloud
#

does anybody here know python & glooey specifically? if you do dm me please

earnest phoenix
#

does anyone know how i create a prototype for a typedef struct in c?

vital lark
#

wait

earnest phoenix
#

typedef struct x{

}x;

vital lark
#

C is a prototyped-based language

earnest phoenix
#

eh ?

#

i guess prototyping is only for functions

#

and not a definition like struct

#

but i think i need to prototype my typedef though

#

because i have function prototypes that has parameters with the typedef

shy turret
#

is it possible to detect when someone is using this permission: USE_VAD

#

(voice activity detection)

west raptor
#

Probably an event?

#

Not sure

#

I'll look through docs in a bit

shy turret
#

i cant find anything so im guessing u cant

#

guessing it is impossible

#

for now

summer torrent
#

list of events

shy turret
#
#

yep... no perms for vad

earnest phoenix
#

how do I connect my server count to top.gg

shy turret
#

oh I just realized... it is dbl.postStats(client.guilds.size) for posting

#

what if someone abuses it though? thinkspin

stray wasp
#

Then they get banned

#

/ punished

shy turret
#

does it to "1000000000000000000000000000" servers

#

I wonder if that would actually break something lol... but no... i dont want to be ban

#

if you shard, how would you get the total server count ๐Ÿค”

stray wasp
#

They probably have something in place to prevent those big numbers

shy turret
#

what if your bot is actually in...

#

those many servers

#

lol, i wonder what discord would be then... broken

stray wasp
#

I haven't messed around with sharing but you probably could achieve it using events

#

Bit like how micro processes work

shy turret
#

i never made a discord bot with sharding yet

#

why does sharding need to exist? can't all discord servers just have the discord bot on?

#

instead of this very complicated process?

earnest phoenix
#

sockets would not be able to handle the traffic

shy turret
#

oh

stray wasp
#

Yup

earnest phoenix
#

Would break discord and your bot

shy turret
#

so it is making 2 child processes im guessing or 2 would be the amount of shards there is

#

being in too many servers = rate limit reaches rip

#

I shouldn't worry about sharding rn atm

lavish shuttle
#

They probably have a system in place where they check the last stats posted and how long ago it was

loud salmon
#

niiikkyy wiiiicky what are youuUuuu dOiiing herree????

hushed berry
#

@shy turret sharding isnt actually all that complicated. it's just logging into a fraction of the bot

#

it needs to happen for a couple reasons

#

but discord's gateway stuff starts to chug with more servers on each connection

#

also, its nice to have some level of separation so that a minor connection error doesnt take down the entire bot

shy turret
#

...

hushed berry
#

its also essential for large bots

#

putting that much faith in one machine is kinda bad

#

for example, rythm has 9 machines that its split across

#

this is mostly so that the immense CPU load can be evenly split across the machines

#

(though this could be accoimpliushed without gateway shrding)

#

@loud salmon henwo spide

shy turret
#
message.guild.createRole({ name: message.guild.id + "-" + focuseduser + "-" + permission, permissions: [permission] });

i haven't test this yet, but how do you get the role id after it is created?

hushed berry
#

what does createRole return?

shy turret
#

idk

#

gonna read docs

#
// Create a new role with data
guild.createRole({
  name: 'Super Cool People',
  color: 'BLUE',
})
  .then(role => console.log(`Created new role with name ${role.name} and color ${role.color}`))
  .catch(console.error)
#

well docs..

hushed berry
#

๐Ÿ‘

shy turret
#

TypeError: message.guild.createRole is not a function

#

EPIC

#

TypeError: Cannot read property 'createRole' of undefined (if you do message.server.createRole)

sudden geyser
#

are you on stable or master

shy turret
#

master

#

@sudden geyser

#

ping me on answer

sudden geyser
#

check out message.guild.roles in docs

#

@shy turret

earnest phoenix
#

@shy turret

message.guild.roles.create({
  name: 'Super Cool People',
  color: 'BLUE',
})
#

message.guild.createRole = v11.5.1

tawny panther
#

Hello does anyone know how to set a command cooldown for this sort of code it is in discord.py

if message.content.find("o!daliy") > -1:  
    if (account > -999999999999):
        msg = '{0.author.mention} has been granted 2000'.format(message)
        await message.channel.send('you have gotten your daliy reward'.format(exotic_engram))
        account = account + 2000
    else:
        await message.channel.send("If you are seeing then something has gone wrong\nDM @tawny panther or @Somebot69#3857")

ping me if you do know

earnest phoenix
#

@tawny panther 0.author.mention?

tawny panther
#

oh it mentions the person who uses the command

earnest phoenix
#

Mmmh Okay...

slender thistle
#

a variable attached to Client object

earnest phoenix
#

it dont say it on my other bot but this one it does

slender thistle
#

@tawny panther do you want the command cooldown to be global

tawny panther
#

to a user yeah

slender thistle
#

so it's per-user cooldown?

tawny panther
#

yes

#

but it will go between servers

slender thistle
#

Eh, I'd say don't bother trying tl reinvent the wheel...

#

commands extension has cooldown system

#

But if you don't want to use it, store a bot variable (bot.x) that will be an instance of dict

#

key will be the user ID and value would be when the user executed the command

earnest phoenix
#

Hi, can anyone help with setting up a webhook for my bot, I really do not understand what I'm doing wrong

lament meteor
#

What are you running right now? Does it give an error or just returns nothing? give more information

earnest phoenix
#

this is the one i do

for some reason my second bot says undefined but server security doesnt and i dont seem to see where or why it would say that as its the exact same code that server security has

#

I using nodejs for my website, when i trying to test webhook, i got nothing (logs empty)

valid frigate
#

weird, does anyone know if sharding is associated with cloudflare load balancing? jda's close codes mention something about this but just curious fr

earnest phoenix
#

webhook listening 1030 port

lament meteor
#

so is the webhook running fine?

earnest phoenix
#
0|illyasviel  | Website now listening  1338
0|illyasviel  | Webhook running with path /dblwebhook
0|illyasviel  | Webhook now listening 1030
0|illyasviel  | illyasviel#2691 now online.
#

But

#

Nothing when voting

#

okay so i found the issue with the bot and the region with my bud

#

for some reason the bot doesnt register the Europe region but the other ones it does

i think discord has changed the regions around where as it used to have eu-central and eu-west they have now gone and its just under europe so i added this to the region list i had on the bot

"europe": ":flag_eu: Europe" and it works fine now

lament meteor
#

@earnest phoenix have u done the part in website(your bot's edit page on the bottom) where it says "Webhook"

earnest phoenix
modest schooner
#

my bot stopped working recently and ive gotten this error

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

Traceback (most recent call last):
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\shard.py", line 78, in poll
    await self.ws.poll_event()
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\gateway.py", line 476, in poll_event
    raise ConnectionClosed(exc, shard_id=self.shard_id) from exc
discord.errors.ConnectionClosed: WebSocket connection is closed: code = 1000 (OK), no reason
#

i can post the whole thing if needed

#
  File "C:\Users\soyou\Desktop\komaeda\bot.py", line 456, in <module>
    client.run("privatetoken")
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 598, in run
    return future.result()
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 579, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 543, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 457, in connect
    await self._connect()
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\shard.py", line 274, in _connect
    f.result()
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\shard.py", line 78, in poll
    await self.ws.poll_event()
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\gateway.py", line 469, in poll_event
    await self.received_message(msg)
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\gateway.py", line 423, in received_message
    func(data)
  File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 409, in parse_message_reaction_add
    emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
KeyError: 'animated'
slender thistle
#

Update your library

modest schooner
#

Yeah that didn't work and I'm pretty sure it was up to date.

Requirement already satisfied: discord in c:\users\soyou\appdata\local\programs\python\python37-32\lib\site-packages (1.0.1)``` thank you though
spice trail
#

No

#

@modest schooner you have to manually push 1.2.5

modest schooner
#

oh

spice trail
#

If you use pycharm you can manually select the latest update and do it that way

#

Otherwise the 1.2.5 update had been pushed for PyPi and just standard python you need to uninstall and reinstall manually 1.2.5

modest schooner
#

oh i see, thank you! That worked

slender thistle
#

Uhh

#

python -m pip install discord.py -U

earnest phoenix
#

how to create custom error, if no such file or directory found?

wheat jolt
#

Node.js? @earnest phoenix

#

Or what language

#

Tf are you writing @earnest phoenix

earnest phoenix
#

Hello! I use Discord py and today for some reason my script keeps failing with:

Traceback (most recent call last):
  File "C:\Users\{ME}}\Desktop\CCVPN\AeroTools\aerotools_vx.py", line 3342, in <module>
    client.run('MY_TOKEN')
  File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 598, in run
    return future.result()
  File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 579, in runner
    await self.start(*args, **kwargs)
  File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 543, in start
    await self.connect(reconnect=reconnect)
  File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 457, in connect
    await self._connect()
  File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 421, in _connect
    await self.ws.poll_event()
  File "C:\Program Files\Python37\lib\site-packages\discord\gateway.py", line 469, in poll_event
    await self.received_message(msg)
  File "C:\Program Files\Python37\lib\site-packages\discord\gateway.py", line 423, in received_message
    func(data)
  File "C:\Program Files\Python37\lib\site-packages\discord\state.py", line 407, in parse_message_reaction_add
    emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
KeyError: 'animated'
>>>

All was fine earlier, haven't changed anything, just have taken on a large load of users/guilds in that past few hours ๐Ÿค”

#

whoa! Turns out there was an update to the api a few hours back ๐Ÿค”

spice trail
#

Yup

#

You can get the patch (1.2.5) now

earnest phoenix
#

@wheat jolt yes

wheat jolt
#

use console.error('This is your error')

mossy vine
#

fs should give you the error

#

read docs and throw the error you get in the callback

compact oriole
#

Is it allowed to send a link to your help server if the user requests it?

blissful scaffold
#

You can put the link to your help server in the help command if you want

compact oriole
#

oh kk

blissful scaffold
#

The user already has the bot so it isn't advertising and the user requests help, so a link to the website or help server is accepted

compact oriole
#

true, true

blissful scaffold
#

I think your bot is allowed to return any link /server as long as someone requests it and it isn't NSFW

compact oriole
#

kk thanks!

earnest phoenix
#

!invite

compact oriole
#

-nicetry

modern sable
#

-botcommands

gilded plankBOT
#

Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.

bold rampart
#

I couldn't solve the error can you help me anyone ? throw err;
^
Error: Cannot find module 'discord.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)

grim aspen
#

you need to have discord.js installed

#

@static iris

#

@bold rampart

#

oops

bold rampart
#

I've done it many times

mossy vine
#

did you install it in the right place

bold rampart
#

Im guess

#

I don't think that there's actually a error in the code , suddenly started picking this error

vital lark
#

are you in the right directory

west spoke
#

@earnest phoenix update d.py

#

Api endpoint change

slender thistle
#

Why not turn @everyone mentions on for discord.py server

#

You know, there might actually be helpful mentions in that server unlike in community ones where you get pinged for useless shit

past pike
#

hi everyone,
if i change the icon from the bot, it doesn't change the icon in servers. Can someone help me?

sudden geyser
#

did you change the bot avatar and not the application icon?

past pike
#

oh yeah right. I changed the application icon

#

my bad

#

๐Ÿ˜…

past pike
#

Next question. I made a mute command but when i run the command the bot does not respond. It's a long script i found on the internet, but it won't work. Can someone help me? Here is the script as file:

earnest phoenix
past pike
slim heart
#

I mean it might be worth acknowledging the fact that u sent it as a txt file

earnest phoenix
#

stop copypasting code

#

you don't even know what this does

#

and you expect it to work

#

?????

past pike
#

i'm a beginner okay

earnest phoenix
#

being a beginner is not an excuse to copypaste (or even steal) code.

past pike
#

if the bot did sent a error, i could solve the problem, but no response so idk what's wrong then

storm nimbus
#

please ping me

twilit rapids
#

Your bot does not have the required permission to do whatever you were doing

storm nimbus
#

ฤฑ am not doing anything

#

@twilit rapids

twilit rapids
#

Then someone else is running commands

earnest phoenix
#

the error says otherwise

#

also handle your errors jfc

storm nimbus
#

so?

#

ฤฑ dont understand

#

can you explain it to me?

earnest phoenix
#

what is there to explain

twilit rapids
#

When your bot wants to do X then it needs permission X. Like, if you want to ban a user you need the BAN_MEMBERS permission

storm nimbus
#

but ฤฑ cant understand ฤฑ did not do anything with commands only a simple bot

earnest phoenix
#

every action you do requires a permission

#

you're not handling your errors like you should so it throws an error

#

e.g if you attempt to send a message but don't have a permission to send the message, it will error out

storm nimbus
#

thnx for help ฤฑ found it bot tries to change a room name every 5 seconds

#

and it is bannable and api doesnt allow it

#

๐Ÿ™‚

past pike
#

Idk guys but i still get ignored with my problem

earnest phoenix
#

don't copypaste code and try to do it yourself, is the solution

unique nimbus
#

Copypasting code won't teach you shit

#

Learn what each command does

#

Read the docs

#

Trial and Error

broken jay
#

my first bot was copypasted (I writed from tutorial) Hello World bot...

past pike
#

Okay i'll do it by myself. If nobody wants to help me. Idk what i should think about this but what a bad support here.

unique nimbus
#

Read the docs

#

thats the first step

dusky marsh
#

^

unique nimbus
#

Try yourself and make thousands of mistakes

#

that is life

#

that is coding

past pike
#

Idk why i am still making bots. Nobody invites them

unique nimbus
#

We all start from somewhere

earnest phoenix
#

:)

unique nimbus
#

My first bot was private and all which it done was earrape peoples ears randomly

#

Then I tried to make it have 8ball and recieved 500 errors

#

fixed it

#

felt proud

#

made another command

#

repeat

#

Also even if nobody invites your bots you gained experience in that language

#

I talked to someone who works in IBM they got in because they made a discord bot

earnest phoenix
#

Okay i'll do it by myself. If nobody wants to help me. Idk what i should think about this but what a bad support here.
you came in here with copypasted code and expected of us to fix it for you.

that's equivalent of breaking something you made, going to a workshop and asking them to fix it for you without knowing the structure, dimensions or anything.

past pike
#

And if i make a bot, people joins the server to say it's bad. It took 1 month to make a bot with a lot of command and then people are saying this is my support server. I havent studied javascript, Idk how it works and if i finnaly have a working bot people gives negative reactions. Then i am completely done

broken jay
#

with 2 months, when im developing bots, i can say i learned soooo much python. I remember when I tried to make command, that mention user, but now im making pokemon bot, that will be soon ready with duels...

earnest phoenix
#

this is not the channel to ask for pity

quartz kindle
#

there is always haters, just ignore/kick/ban/"ok boomer" them and move on

#

if they dont like your bot, tell them to get another one

slender thistle
#

Or take their words as possible feedback

unique nimbus
#

Yes

#

My first bot was shit

slender thistle
#

Also, amount of commands doesn't usually equal to the quality of the bot

unique nimbus
#

People told me what is bad about it

quartz kindle
#

yeah, you can ask them "what exactly is bad about it so i can improve"

unique nimbus
#

I redone it and made it better

#

Exactly

past pike
#

But okay i will try to make a mute command by myself

unique nimbus
#

Read the docs

#

They help a lot

#

Make the command and when errors come fix them

past pike
#

most errors doesn't show whats wrong. Only where

#

I had once an error which i couldn't solve so i removed the code

quartz kindle
#

they do show whats wrong

#

but you need a basic understanding of the programming language you're working on to understand it

past pike
#

Not everytime

quartz kindle
#

for example, one of the most common errors is cant read property X of undefined

#

it means that you're trying to access a property of an undefined object, for example accessing object.property when object is not defined, invalid, empty, null, etc..

#

(in javascript)

past pike
#

Once i had the error: x is not a function
But i have written a function to that command but still he was saying it

quartz kindle
#

that means it is not a function in the scope where it exists

past pike
#

And thats why i don't study coding. One letter or character wrong and the whole script doesnt work

quartz kindle
#

for example, you will get that error if you try to do this ```js
runFunction();
client.on("message", message => {
function runFunction() {
// do something
}
})

#

because its trying to run a function that doesnt yet exist

#

since it will only be created at a later point

#

(that example is super bad by the way, just for illustration purposes)

slender thistle
#

Coding might be interesting if you like it

#

There's nothing wrong if you do not like it

broken jay
#

Huh JS? I suggest python, this easier...

past pike
#

I like coding (only if it works)

earnest phoenix
#

How to do "[insert bot name] is typing..."?

slender thistle
#

It's matter of preferences

#

If you like coding without debugging, I'm sorry to disappoint you

quartz kindle
#

most libraries have a method to send a typing presence

loud salmon
#

@earnest phoenix you send a typing event. its in the channel object

quartz kindle
#

like channel.beginTyping()

loud salmon
#

iirc

#

yea

quartz kindle
#

or something like that

earnest phoenix
#

Oh ok

quartz kindle
#

check the docs for it

grim aspen
earnest phoenix
#

Thx

quartz kindle
#

yeah startTyping not beginTyping lul

earnest phoenix
#

But is 2 pings necessary?

slender thistle
#

Does it really matter that much when you're reading the channel already

quartz kindle
#

when there are multiple conversations going on, we usually use pings to tell who we are talking to

loud salmon
#

he used it twice

earnest phoenix
#

x mentions is still one ping per message

loud salmon
#

probably an accident lul

quartz kindle
#

oh i just noticed lul

slender thistle
#

someone didn't pay enough attention and Tim wasn't the only one to do that

grim aspen
#

the channel id matches that channel

marble juniper
#
if (!serverprefix.get(message.guild.id))
     var command = args.shift().toLowerCase(); 
    if (serverprefix.get(message.guild.id))
    var command = args.slice(serverprefix.get(message.guild.id).length).toLowerCase();
#

im trying to make it so it removes the prefix

#

so the command can get executed

#

but I can't get it to work since I am dumb

quartz kindle
#

if args is an array

#

slice will cut a number of items from it

#

can you show a usage example of both situations? with and without serverprefix?

earnest phoenix
#

It is possible to post shards with a +1 to avoid having a shard 0

late hill
#

post to what

#

dbl only displays the shardcount so it shouldn't matter for that?

earnest phoenix
#

https://top.gg/api/bots/:BOT_ID/stats

Yes, but in the API the shards ids are displayed

late hill
#

Why would you want to change that

#

You'd start counting at 1 for things that end users get to access

#

Because they'll get confused if it starts at 0

#

The API is used by developers that are expecting it to start at 0

earnest phoenix
#

Okay ty

#

weirdsip okay

#

Ty Wesley

grim aspen
earnest phoenix
#

no it isn't

#

you know, you have to look at the whole id, not just at the first few digits

spice trail
#

i gotta ask

#

why are paginators usually so freaking long?

earnest phoenix
#

people want to clutter as much information as they can on one page

#

but the point of a paginator is to split that cluttered information into multiple pages so it's easier to read

#

๐Ÿคทโ€โ™‚๏ธ

spice trail
#

not but like the code for a paginator

#

some examples are some freaking 500+ lines long

earnest phoenix
#

because you have to handle reactions, keep track of pages, keep track of the message

#

+- if you want to do checking the command executor is the one who is reacting

grim aspen
#

the one channel that gets muted that destroys my bot

#

should be fuxed

modern sable
earnest phoenix
#

what language is that

modern sable
#

that's C#

earnest phoenix
modern sable
#

I'm just asking in general (this project for example isn't a discord bot), i've been looking for a better solution for bots aswell though

earnest phoenix
#

there's a really nice command handling library that i personally love

quartz kindle
#

if C# has anything equivalent to in-memory key-value stores, and a way to loop over its keys

#

you can easily make a command handler

modern sable
#

That's actually a good idea

chrome verge
#

Why when i use my bot it the clien.run() returs future.resume() and an error
Dm me for help
as this server notifs are broken

vital lark
#

@chrome verge what

#

show the error and code

chrome verge
#

raceback (most recent call last):
File "C:/Users/dell/Desktop/CorHDI games/Yikes/main.py", line 2141, in <module>
client.loop.run_until_complete(client.start(TOKEN))
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\asyncio\base_events.py", line 466, in run_until_complete
return future.result()
File "C:\Users\dell\Yikes\lib\site-packages\discord\client.py", line 543, in start
await self.connect(reconnect=reconnect)
File "C:\Users\dell\Yikes\lib\site-packages\discord\client.py", line 457, in connect
await self._connect()
File "C:\Users\dell\Yikes\lib\site-packages\discord\client.py", line 421, in _connect
await self.ws.poll_event()
File "C:\Users\dell\Yikes\lib\site-packages\discord\gateway.py", line 469, in poll_event
await self.received_message(msg)
File "C:\Users\dell\Yikes\lib\site-packages\discord\gateway.py", line 423, in received_message
func(data)
File "C:\Users\dell\Yikes\lib\site-packages\discord\state.py", line 407, in parse_message_reaction_add
emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
KeyError: 'animated'

vital lark
#

update the library

#

breaking changes EmileSip

chrome verge
#

ok ty

thin jacinth
#

I'm here with the same question xd

loud salmon
#

@thin jacinth update to latest dpy version

past pike
#

I read the docs but i don't understand what await means. can someone explain what that means so i can use it in my mute command?

chrome verge
#

Nop still broken

slender thistle
#

How did you update

chrome verge
#

@past pike Await is a couroutine caller

#

async await

#

You call async functions with await

slender thistle
#

Read more on async functions

thin jacinth
#

@loud salmon ikr ty

chrome verge
#

async functions and async with and async for and async if

#

I have still issue

past pike
#

okay

#

my mute command does still not work, i need to search further i think then

#

the bot still does not respond

chrome verge
#

Mute is -- Add a muted role with no speaking perms to a member

#

use

#

member.add_roles

#

member.add_roles(*roles)

thin jacinth
#

@loud salmon I'm sorry for disturbance but what is the fastest way to update discord.py

chrome verge
#

pip install

slender thistle
#

Well how did you install it

thin jacinth
#

I tried pip3 install discord and nothing changed

slender thistle
#

I swear to God

chrome verge
#

nOrMALL pip

#

sorry caps

vital lark
#

do pip install -U discord.py

thin jacinth
#

okay

slender thistle
#

Most likely pip3

#

Because env vars

thin jacinth
#

pip install -U discord.py worked thank you very much

slender thistle
#

Is there some stupid fucking guide that tells people to install discord instead of discord.py

thin jacinth
#

Question is closed now, have a nice day

slender thistle
#

Oh well we're lucky somehow hoo ray

vital lark
#

Shivu, dont be hard on others

chrome verge
#

hard

vital lark
slender thistle
#

With the crap I'm gonna give I'd rather keep it to myself

#

I'm just curious

#

is it people just guessing randomly or is there an actual guide encouraging to install a stupid package

vital lark
#

who knows

loud salmon
#

@slender thistle question is closed have a nice day

past pike
#

finally my bot responds to my command

slender thistle
#

Got it

past pike
#

he gives an error but at least a respond

chrome verge
#

yay

past pike
#

oh i see the problem

#

i cannot mute myself

#

need to fix that

unique nimbus
#

Why do you want to mute yourself

past pike
#

as testing for now

#

it works now

#

finally

quartz kindle
#

whats on cmd_bot.js line 287?

past pike
#

never seen this error before

#

let me check

#

message.channel.send(:white_check_mark: <@${tomute}> has been muted for ${ms(ms(mutetime))});

quartz kindle
#

this is a good oportunity for you to learn how to read errors

valid frigate
#

why do you have nested ms calls

#

just curious

quartz kindle
#

the first part shows you what is the actual error, and a description of it. the following lines that start with at tell you exactly where the error happens

#

in your case, the first error comes from the ms package, you can see its a package because its located in the node_modules folder

#

the second line tells you where in your actual bot file does the error happen

past pike
#

okay glad to know

#

i fix that later

quartz kindle
#

whenever you get an error, look for the first line where your bot file is mentioned

#

and look the number right after, which is the line number in the file

past pike
#

oh okay

#

good to know

quartz kindle
#

so then you know where the error is, and you can post the relevant code for people to help you solve it

#

in your case, as Vysion mentioned, the problem is most likely that you have ms(ms(something))

#

so try removing the extra ms

past pike
#

okay i will try later, now i'm gaming with friends

split hazel
#

Is there a way to turn discord js message.member.displayColor into hex?

tranquil drum
sudden geyser
#

Nesting both ms(ms(value)) is actually valid. It convert it to as if you passed the value (ex: ->mute @Kinolite#0001 1h mean -> 3,600,000 ms -> 1h).

The problem might be what mutetime is.

shy turret
#
                      message.guild.roles.create({
                        name: permname,
                        permissions: [permission.toString()]
                      });

this still isn't setting the name and permissions...

#

let me try to debug

slender thistle
#

Is there a special way to working with REALLY HUGE numbers in C

slim heart
#

Depends on what youโ€™re gonna use em for

quartz kindle
#

there's long long int

#

and there's long double

smoky spire
#

@shy turret name and permissions are in the data parameter

grim aspen
#

yes

#

oops

#

wrong channel

shy turret
#

it isnt some long thing...

#

i just checked

#

645714324815347713-276497792526974996-KICK_MEMBERS

vital lark
#

what

shy turret
#

@smoky spire wdym? isn't it suppose to be like that?

smoky spire
#

Look at the example in the docs

#

And you'll see you did it wrong

shy turret
#

ok

slender thistle
#

@quartz kindle ty fam

earnest phoenix
#

Whats the best way to make this work on guilds with a lot of roles

 @commands.command(name="roles")
    async def roles_info(self, ctx: Context) -> None:
        """Returns a list of all roles and their corresponding IDs."""
        # Sort the roles by the order as shown in the client's Roles UI
        roles = sorted(ctx.guild.roles, key=lambda role: role.position, reverse=True)
        #roles = [role for role in roles if role.name != "@everyone"]

        # Build a string
        role_string = ""
        for role in roles:
            role_string += f"`{role.position}` - {role.mention} - `{role.id}`\n"

        # Build an embed
        if len(roles) < 10:
            embed = discord.Embed(title="Role information", colour=Colour.blurple())
            embed.add_field(name="Roles", value=role_string)
            embed.set_footer(text=f"Total roles: {len(roles)}")
            await ctx.send(embed=embed)
        else: 
            await ctx.send("`" + role_string + "`")
#

truncate your embed

#

don't make the format so long

#

mention and position is enough

shy turret
quartz kindle
#

@shy turret guild.roles.create

#

so head over to the guild docs

shy turret
#

ok

#

done

quartz kindle
#

follow the chain

#

click role

#

go into the role store

#

click create

earnest phoenix
#

message.guild.roles.create

shy turret
quartz kindle
#

yeah, now head over to create

#

and there's your example

shy turret
#

ikr...

quartz kindle
#

your answer is incorrect Dany

twilit rapids
#

@earnest phoenix your example was one way to do it, on the docs it's more explained

earnest phoenix
#

@quartz kindle for v12?

twilit rapids
#

And I think that was for v11, your example

earnest phoenix
#

@twilit rapids oh bruh

#

No

twilit rapids
#

You need

 data: {
}

too

earnest phoenix
#

V11.5.1 = message.guild.roleCreate

shy turret
#

making the role worked at least... thanks!

quartz kindle
#

v11 is guild.createRole()
v12 is guild.roles.create()

#

but the role data has to go into options.data

#

not just options

earnest phoenix
#

createRole* yeah

quartz kindle
earnest phoenix
#
message.guild.roles.create({
data:{
  name: 'Super Cool People',
  color: 'BLUE',
}})
quartz kindle
#

yup

earnest phoenix
shy turret
#

`permission: { [permission] }, how does something like this work...

#

permissions:[permission.toString()] gonna try this

#

no error... didn't work

#

rip

quartz kindle
#

what is permission?

shy turret
#

permission.toString() = "KICK_MEMBERS"

#

(ofc i didnt write it like that in the code)

#

let me try it without the variable once

still wing
#

I have a question about changing my bots status to DoNotDisturb but to be honest I don't remember how because before I used normal Discord.NET api and now I'm trying to use .NET Core 3.1 but I just can't find the right command to run it

shy turret
#

didn't work

earnest phoenix
#

what are you trying to do

quartz kindle
#

show the full code

shy turret
#

huge command

#

not even the full command

#
        let argstart = "edit ";
        let args = cmd.slice(argstart.length).split(" ");

how args are defined

#

not in an async function

quartz kindle
#

everything except reason goes into data

shy turret
#

ok

quartz kindle
shy turret
#

wait... im actually... blind wtf

#
  data: {
    name: permname
    permissions: [permission.toString()]
  },
#
    permissions: [permission.toString()]
    ^^^^^^^^^^^

SyntaxError: Unexpected identifier
#

wait ikr

#

,

#

done fixed

#

Thanks! it worked

quartz kindle
#

by the way, instead of checking if permission is a valid permission one by one

#

you can use this

shy turret
#

ikr

#

i was reading a docs

#

i think i read it for a hour already lmao

#

i'm working on

focuseduser.roles.add(role).catch(console.error);

rn

earnest phoenix
#

Exactly

shy turret
#
Supplied roles is not an Array or Collection of Roles or Snowflakes.
#

well, that sometimes happens...

#

well, no error again after 10000000 times restarting

earnest phoenix
#

what is role ?

#

You're use var role = client.roles.get("1234") ?

shy turret
#

i think i know why

earnest phoenix
#

Bruh you can just use focuseduser.roles.add("1234").catch(console.log.error);

#

I think

shy turret
#

fixed

#

@earnest phoenix no, what i was doing was:

#
  • create role
  • find role by name
  • give the role to the user
    without an async function
earnest phoenix
#

Oh Custom Roles Command ??

shy turret
#

which sometimes it went by too fast so it runs that find role by name first (no async)

earnest phoenix
shy turret
#

different

#

but lol

#

now i did:

earnest phoenix
#

Mmmh

shy turret
#
  • create role
  • then, give role
  • error, log error
earnest phoenix
#

Okay

shy turret
#

im not making a custom role cmd

earnest phoenix
#

Okay

shy turret
#

im making some type of discord bot that i never saw before

#

so im guessing im inventing it

earnest phoenix
#

Lol

smoky spire
shy turret
#
client.on("guildBanAdd", function(guild, user){
  console.log(`a member is banned from a guild`);
});
#

well i got that from somewhere else

#

what would user be?