#development

1 messages · Page 718 of 1

cursive gale
#

oof

sick cloud
#

an error stack

valid frigate
#

people whomst listen for reaction events

earnest phoenix
#

having more then just yourself working on a project is so nice

valid frigate
#

but who does that anyway amirite

#

yes uber

earnest phoenix
#

we have like 8000-10000 lines of code in like a few weeks

#

like 1 or 2

#

lol

valid frigate
#

cries in 0 collaborators

#

jk

earnest phoenix
#

hey i offered if you wanted to help us

#

but NOoOOo

valid frigate
#

oh yeah about that shh

cursive gale
#

i'm the only developer of 5 projects at once

mossy vine
#

@earnest phoenix hire me and you will have 1000 extra lines of buggy code

#

/s

earnest phoenix
#

lol cyber

#

if your good we need more devs

mossy vine
#

im good yes

earnest phoenix
#

how good

cursive gale
#

i need a dev

mossy vine
#

very good

restive furnace
#

hire me and get 1000000 lines of code 100000 lines are in /**/

cursive gale
#

like really

valid frigate
#

he's stephen hawking

earnest phoenix
#

you being serious about working with us @mossy vine ?

#

cause ill straightup do it

#

rn

cursive gale
#

i have 1mil lines of fuck me

valid frigate
#

i mean just like at any startup hire anyone whos decent

mossy vine
#

@earnest phoenix fuck yeah

cursive gale
#

all written manually

earnest phoenix
#

@valid frigate ye we got the best of the best furcool

valid frigate
#

good

sick cloud
#

my library is probably about 2000 lines or something

valid frigate
#

maybe ill help you with your logo but luke is dead rn isnt he

earnest phoenix
#

yoinked a lot of cert devs etc out of here

#

ha

#

@mossy vine ill dm you

mossy vine
#

uber just yoink me already pls

cursive gale
#

work in progress

#

no copy paste

restive furnace
#

What library whats only 2k lines long, nice.

valid frigate
cursive gale
#

all written by me

valid frigate
#

im no mod but what the fuck man

cursive gale
#

me? @valid frigate

sick cloud
#

@restive furnace what

earnest phoenix
#

yoinked

cursive gale
#

i'm hiring devs dm me to apply i can give free premium web hosting costs $500/m for free just by being a dev

#

lol

#

really need one

earnest phoenix
#

imagine a whitename

cursive gale
#

anyone? lol

earnest phoenix
#

trying to yoink devs

#

lol

cursive gale
#

lol i can hear you typing @earnest phoenix

#

i can't speak rn @earnest phoenix

#

lol

#

you sound like as if you are drunk

#

ohh

#

do you see the screen shot above

#

the error screenshot

#

yes

#

there is no client.js file

#

ok

#

they keep resetting my token :((

#

no the actual thing has changed

#

i think

#

can my webhook token be the issue?

#

i'm using a webhook

#

and when i do that cmd

#

it's coming

#

that error comes when i do that cmd

#

n0o

#

yes

#

wait i'll screenshare

earnest phoenix
#

welp

#

this

#

is a problem

#

I'll ask again since my question got yeeted

#

Does anyone know which perm do bots need to fetch invites

cursive gale
#

lol

late hill
#

A user needs manage server to be able to see them

#

So probably that

weak ravine
#

cursive gale
#

see the discord.js docs for perms it's easier than asking @earnest phoenix

earnest phoenix
#

why am i getting pinged in here over and over aigan

#

lol

cursive gale
#

...

#

it better to give a bot administrator perm instead of giving each perm manually

shadow dust
#

Wrong.

cursive gale
#

huh?

shadow dust
#

If you give a bot administrator right you might have some perms you didn't actually need to give it

#

It's prone for errors and possibly abuses

#

While if you do each perm it's explicit

#

It's like saying 'you should use your root user instead of making a new user'

earnest phoenix
#

avoid giving admin if you don't need to

#

deleted message

mossy vine
#

its getting users with the ids from 0 to a.length-1

#

chances are, they are not valid ids

earnest phoenix
#

Can u give me correct code ?

mossy vine
#

no

earnest phoenix
#

Why

mossy vine
#

cuz idk the correct code

earnest phoenix
#

ok.

earnest phoenix
#

I am asking for admin perms currently if you want to know which invite was used since I can't for the sake of it find which perm is needed to fetch invites

#

My guess was manage guild but I wanted to confirm

late hill
#

That's your guess and that was also my guess, but did you actually try it..?

#

Doesn't seem like that much effort to try it out

slender thistle
#

MANAGE_GUILD, yup

ocean rampart
#

What does a DeprecationWarning mean?

earnest phoenix
#

what do you think it means

ocean rampart
#

It says pass a function instead

earnest phoenix
#

i asked you what you think it means but ok

#

whatever you're using is deprecated

ocean rampart
#

I know that, but how do I fix it

earnest phoenix
#

switch over to what's not deprecated

#

aka what the warning is telling you

ocean rampart
#

I changed it to a function

#

But now it’s saying what I changed is not a function

earnest phoenix
#

what are you doing even

#

what's your code

ocean rampart
#

A report command

earnest phoenix
#

that's not what i meant when i asked what you're doing i-

ocean rampart
#

you want my code?

earnest phoenix
#

yes

#

just don't copypaste it here

#

for fucks sake

ocean rampart
earnest phoenix
#

on which line does the warning occur

ocean rampart
#

Line 23

earnest phoenix
#

there's not even 23 lines in your hastebin

ocean rampart
#

Line 15

earnest phoenix
earnest phoenix
#

Hey guys , I was wondering if “selling bot currency is allowed”

slender thistle
#

You mean rewarding users with your bot's currency for donating?

earnest phoenix
#

Yeah

#

I want to set up a donation page with cards displaying how much they donate

slender thistle
#

k3llyShrug Haven't seen people get in troubles for that

earnest phoenix
#

So like €1 = 1000 Credits

slender thistle
#

As long as you give the product you claim to give, you're good

earnest phoenix
#

So that’s allowed ?

slender thistle
#

Should be

earnest phoenix
#

What about selling the currency if you get me

slender thistle
#

Huh?

earnest phoenix
#

Never mind thanks 🙂

slender thistle
#

You're welcome, I guess special_think

hybrid raptor
#

i thought u were not allowed to sell virtual currency

#

hm

slender thistle
#

Big, small bots do that and I haven't heard of cases where they get in troubles for that

hybrid raptor
#

so i could do the same basically , putting plans for like 2$ for premium or somewhat

#

damn

#

i guess ill do that then 😂

slender thistle
#

As long as you don't scam people

hybrid raptor
#

yeah i guess

slender thistle
#

Just don't go crazy there

hybrid raptor
#

i wont

#

lol

restive furnace
#

It is allowed many bots has premium feature and they are not in trouble.

lethal sun
#

Hello! Currently, I have this:

client.fetchUser("592716014588788736");```
and it's giving me this:
```js
Promise {
  User {
    id: '592716014588788736',
    username: 'Splash',
    discriminator: '1337',
    avatar: 'a_39f3d3470e7cd6aed3b966e408df0d6d',
    bot: false,
    lastMessageID: null,
    lastMessage: null } }```
How do I access the username?
quartz kindle
#

its a promise

#

do you know how promises and async works?

lethal sun
#

not really, no

mossy vine
#

use await client.fetchUser in an async function

quartz kindle
#

async code is code that is not synchronous, it doesnt give you an answer right away

#

a promise tells you that there is a result that will be returned later, but not now

#

so you have to tell the code what to do after the promise arrives

#

one way is to use await to tell your code to wait until the promise arrives

#

the other way is to use .then() to tell the code what to do after the promise arrives

lethal sun
#

ohh

#

that makes sense

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

jagged hollow
#

?

sage bobcat
#

One message removed from a suspended account.

jagged hollow
#

you bot is {prefix}!ping = 100 300 ms ?

sage bobcat
#

One message removed from a suspended account.

jagged hollow
#

ohk

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

jagged hollow
#

1 mins

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

manic basalt
#

Not sure why but my "on_guild_role_update" event for discord.py is always called twice when I edit a role, I checked and I don't have this event somewhere else in the project and I dont have two processes running

The console output after the following code is

@everyone
@everyone
Moderator
Testing
@commands.Cog.listener()
async def on_guild_role_update(self, before, after):
    print(before)
    print(after)
#

^ i fixed it by just returning after the code, but is there any fix to it without having to check for the [at]everyone role

quartz kindle
#

@sage bobcat the ping is the bot's websocket ping

#

its the latency between the bot's server and discord's servers

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

the websocket ping is always low

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

where do you live?

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

discord's gateway is in new york or something like that

earnest phoenix
#

yes

quartz kindle
#

34 seems like a normal ping between miami and new york

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

because bots usually measure REST ping and not websocket

sage bobcat
#

One message removed from a suspended account.

restive furnace
#

Does anyone know on discord.js how to correctly use aliases?
I did already make on end of command

exports.alias = (type == 'alias') => {
        alias = "aliashere"
}```
i did add on my command handler 
```js
let props = require('./command/${f}');
let aliasName = props.alias.alias;
client.alias.set(aliasName, props);

and on messahe handler

//as usual
const command = its from an idiots guide same;
const cmd = client.commands.get(command);
const alias = client.alias.get(command);
if(!cmd) {
if(alias) {
alias.run(command);
}
}
if (!alias) {
if (cmd) {
cmd.run(command);
}
}```
amber fractal
#

you should format that

quartz kindle
#

@restive furnace you're defining exports.alias as a function

#

so client.alias becomes function -> prop

#

which you cant .get() properly

restive furnace
#

ok thx for the info

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

does totalmem return in bytes?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

it's dividing first

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

perhaps this let mem = Math.ceil((os.totalmem() - os.freemem()) / 1024 / 1024 / 1024)

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

mmLol happens

sage bobcat
#

One message removed from a suspended account.

amber fractal
#

subtract first

#

parentheses

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

how many servers?

sage bobcat
#

One message removed from a suspended account.

amber fractal
#

Well that takes into account the other processes running too right?

sage bobcat
#

One message removed from a suspended account.

amber fractal
#

just looks at total and total free

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

I mean it's really hard to tell if it's actually right

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

restive furnace
#

10mb for discord is pretty real

#

mine is in 20 servers and it uses 30-40mb ram

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

It returns the memory in bytes doesn't it?

#

So by doing / 1024 3 times

#

Wouldn't that make it GB

#

Besides that

#

You are aware that you're checking the total memory usage on your entire operating system, right?

#

Not just the bot

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

What did you think os meant blobsweat

sage bobcat
#

One message removed from a suspended account.

late hill
#

soRrY

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

I believe process has some stuff you can use

sage bobcat
#

One message removed from a suspended account.

late hill
#

To get the memory usage for just that process

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

uhh

#

it's a method

#

memoryUsage()

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

By calling the method

#

add ()

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

..

#

That's gonna throw an exception

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

memoryUsage is the method

#

not rss

#

call 👏 it 👏

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

scenic kelp
#

wait it's returning an object right?

sage bobcat
#

One message removed from a suspended account.

scenic kelp
#

1 sec lemme test

late hill
#

yes

#

so you'd add .rss to it

scenic kelp
#

yeah you need to do process.memoryUsage().heapUsed or .total or something. I don't know what each value means and I'm too lazy to read docs

late hill
#

if that's what you're interested in

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

Well

#

Are you still using the os stuff

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

late hill
#

Show code

#

you are

#

..?

scenic kelp
#

Yes you are

sage bobcat
#

One message removed from a suspended account.

scenic kelp
#

o

knotty steeple
#

xd i found a good way to get the memory

#

that is being used

scenic kelp
#

Yeah you're using free ram

#

you get the total - the process' usage

knotty steeple
#

but cant spoonfeed mmulu

sage bobcat
#

One message removed from a suspended account.

late hill
#

process.memoryUsage().rss is the memory used by the process

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

no thats how much is free

late hill
#

You don't need to subtract it

scenic kelp
#

make mem = Math.ceil(process.memoryUsage().rss)

knotty steeple
#

all u have to do is math on mem alone

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

no this is what u did let mem = Math.ceil(os.totalmem() - (process.memoryUsage().rss))

scenic kelp
#

ye

knotty steeple
#

unless u already changed it

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

ok

scenic kelp
#

same output?

knotty steeple
#

then thats ur memory usage

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

scenic kelp
#

I got some slick code for uptime if ye want it

restive furnace
#

yees

#

I do want

#

xd

valid frigate
#

you could

  1. use momentjs but its fat
  2. copy paste from stack overflow since that's what we all do anyway
blissful scaffold
#

2b) copy paste from stack overflow but actually try to understand what the code means

mossy vine
#

2c) disregard 2b

sudden geyser
#

2ba) "But actually try to understand what the code means" We don't do that here

quartz kindle
#
  1. ignore 2 and actualy code it yourself
dusky marsh
#

^

grizzled jackal
#
  1. ignore 3 and pay someone else to do it for you
cunning goblet
#
  1. actually read the documentation instead of using stackoverflow
#

5b) give up

astral crown
cunning goblet
#

2 kinda sucks since you dont learn by spoon feeding

#

and alot of people there have a habit of that instead of just explaining the answer or whats wrong with the code

split hazel
#

Do I have to port forward the --inspect debugger on node to access it with devtools?

undone rose
#

Coding yourself is always best!

#

You will learn so much more and even for a small thing it becomes worth it

#

You can then apply what you learn to other areas and boom better coder

#

People who get into the stack overflow loop STAY in the stackoverflow loop

late hill
#

pay someone to convert milliseconds into a human readable format yes big brain

split hazel
#

lmao

undone rose
#

Agreed

grizzled jackal
#

A pro gamer move

amber fractal
split hazel
#

https://discordapp.com/api/oauth2/authorize?client_id=Your-Bots-ID&permissions=8&scope=bot would invite the bot with administrator

#

if thats what you mean

pliant needle
#

A bot can send two different embed messages to two different channela at the same time with no issues, right? Discord.js

blissful scaffold
#

Don't try to get your bot invited with admin powers, you almost never need it

undone rose
#

I always had admin perms on my bot

#

After a while people would always come to me with issues and a lot of the time it was bc the bot lacked a certain permission. I added a permission check for each command but still its better for the developer to just keep it at 8

earnest phoenix
#

no it's not

undone rose
#

If you keep it at 8, approx 83% of guild owners will keep it there

earnest phoenix
#

use permissions your bot needs

#

not all people are going to trust your bot with admin permissions

undone rose
#

Then they can invite with it unticked and edit the role

#

For those few people

blissful scaffold
#

Just check ALL the marks, so your bot still does almost everything if people don't give admin 😛

undone rose
#

Approx 17% of users that actually cared

#

I never see users actually care about the url/permissions granted, its always only other devs lol

#

Users generally blindly trust bots just like how devs blindly trust all the junk they npm i

#

Lol

earnest phoenix
#

people who lead ecomm guilds or just generally large guilds do care

#

trust me lol

#

used to work for a few owners

undone rose
#

I know, and they usually just untick and do a custom role anyways

#

All the super big guilds usually want custom bots entirely tho

#

And those bots are usually admin

blissful scaffold
#

You can give a bot admin powers as long as you know who to beat up IRL after the bot deleted the entire server

golden herald
#

This sounds like a stupid question, but was there a change within the Python API surrounding the status things?

@bot.event
async def on_ready():
    print("Connected to Discord Servers.")
    print("Ready for start up.")

    print("Running on v" + str(version) + " on the account " + bot.user.name)
    status = ["Tetradon Gen", ".help"] # Change the status here!

# Changes the status messages on the bot
    await bot.wait_until_ready()
    msgs = cycle(status)

    while not bot.is_closed:
        current_status = next(msgs)
        await bot.change_presence(game = discord.Game(name = current_status, type = 2))
        await asyncio.sleep(60)```

this is my code for it and Idk if there is something wrong with it because my bot won't start
scenic kelp
#

I always make sure to give my bots only the perms it needs, just helps alleviate some of the liability when someone gets their server deleted because they don't know how to configure stuff

slender thistle
#

There is no type, is_closed is a function

golden herald
#

wdym?

slender thistle
#

It's also activity now

golden herald
#

oh ok

slender thistle
#

change_presence(activity=

#

To get Listening and Watching, you'll need discord.Activity

golden herald
#

ok

#

wdym by the type and is_closed thing

slender thistle
#

I'm just blindly assuming you recently updated to the newest discord.py version

golden herald
#

yup

earnest phoenix
slender thistle
#

type will be within discord.Activity if you use it, discord.Game is only used for the "Playing" status

#

You'll need to call bot.is_closed since it's a function

#

You should read some changelogs on discord.py docs :p

golden herald
#

You are going to have to explain this to me a bit

#

I am a bit slow xd

earnest phoenix
#

I'm trying to make a backup bot but I can't save the role permissions

#

Librairie: discord.js

golden herald
#

@slender thistle

earnest phoenix
#

'-'

golden herald
#

ik

#

I need help tho

earnest phoenix
#

Oh okay

slender thistle
#

From discord.py 1.0.0 starting, discord.Activity was introduced. discord.Game and discord.Streaming were kept, but to get Listening and Watching statuses, you'd need to use an instance kf discord.Activity where a keyword argument type would be an Enum for your status (discord.ActivityType.<x>)

#

From basic Python, a function is called by adding () after the function name. To use bot.is_closed, you'd need to put parentheses after is_closed

golden herald
#
while not bot.is_closed()
        current_status = next(msgs)
        await bot.change_presence(activity = discord.Activity(name = current_status, type = 2))
        await asyncio.sleep(60)
#

What do I need to change about this?

slender thistle
#

Don't forget :

golden herald
#

ok

slender thistle
#

Do you want your bot to display Playing?

golden herald
#

Listening

slender thistle
#

discord.ActivityType.x where x is the status you want

#

What would you use for listening?

golden herald
#
status = ["Tetradon Gen", ".help"]```
#

which turns into current_status

slender thistle
#

Not that

#

I'm talking about the type argument you are using

golden herald
#

Hm?

#

What should I change in my code, sorry if I sound short, but I need to finish this quite soon

slender thistle
#

The argument type

#

You entered type=2

golden herald
#

Yeah

slender thistle
#

when the value of argument type needs to be an enum/class

#

discord.ActivityType.x where you replace x with either watching or listening

golden herald
#

so ```Python
await bot.change_presence(activity = discord.Activity(name = current_status, discord.ActivityType.listening))

slender thistle
#

Looks good

#

Now, TIAS!

golden herald
#

Thanks

#

there is an error with

while not *bot*.is_closed():
        current_status = next(msgs)
        await *bot*.change_presence(activity = *discord*.Activity(name = current_status, discord.ActivityType.listening))
        await asyncio.sleep(60)
#

The things w/ ** around them

slender thistle
#

What is cycle

#

What's the error

golden herald
slender thistle
golden herald
#

how'd you check?

slender thistle
#

cmd, pip sjow discord.py

#

I hope you know how to open a command prompt

golden herald
#

yes, I am smart xd

slender thistle
#

Ehhh

#

That's not "latest"

golden herald
#

thought it was xd

slender thistle
#

Latest is 1.3.0

golden herald
#

ooooooooooooooooooooooooooooooooooooooooooooof

#

I am behind

#

now how do you update your version lmao

slender thistle
#

-U or --update

late hill
#

If you keep it at 8, approx 83% of guild owners will keep it there

#

Because those are all stupids

#

It's nice to have your bot in some decent servers too

#

And people should rly learn not to give bots admin

#

Giving a bot admin is very much the same as giving the bot owner admin

slender thistle
#

@golden herald you have the choice to let your code stay like it was before I started giving you crap or migrate to the actually latest version now

golden herald
#

what happened?

late hill
#

If I invite a bot and see that it asks for admin, I assume it's due to one of the following reasons:

  • An actual scam/malicious bot
  • A lazy dev that couldn't figure what perms their bot needs
slender thistle
#

Eh never played with permissions

#

I always run the cmd from admin if shit doesn't work 02lul

earnest phoenix
#

@golden herald add: --user

#

:)

golden herald
#

ok thanks

slender thistle
#

Or that

golden herald
#

Right it is now at 1.2.4

#

not 1.3.0 for some reason

slender thistle
#

Ah whatever, 1.3.0 wasn't uploaded to pypi

#

1.2.4 is good

golden herald
#

Thanks so much!

earnest phoenix
#

Who can help me in discord.js v11.5.1?

golden herald
#

@slender thistle I have still got one error

undone rose
#

I only did it bc less users complain

golden herald
undone rose
#

And again, bot developers seem to be the ones that generally care

slender thistle
#

You can't do argument=value, value_to_another_argument

#

Put type= before the listening status thing

undone rose
#

Also > assuming they arent decent servers

golden herald
#

ooh ffs since I updated it I got 109 errors

undone rose
#

Theyre not stupids rlly, its just credibility from the bot being on so many servers

#

I mean today the sample size i had for the 83% figure isnt much, but back then it was decent

slender thistle
#

Well yeah as I said you'd have to take your time updating stuff

#

:^)

#

Migration docs ftw

golden herald
#

mhm

#

Btw, is bot.(whatever) still in use

#

cos all of my bots are highlighted

slender thistle
#

As long as your commands.Bot or discord.Client is under the variable bot, you are good

#

just make sure the attributes you use do actually exist mmulu

golden herald
slender thistle
#

Yep, you're good

#

Migration docs say all servers are guilds

golden herald
#

oh ok

#

thanks

slender thistle
golden herald
#

idk why

#

@slender thistle

slender thistle
#

There's a class Messageable which TextChannel, Member and User inherit

#

So you would need to use .send on a channel

golden herald
#

oh ok

earnest phoenix
#

Who can help me please?

golden herald
#

What is it w/?

#

Thanks so much btw, fixed it now @slender thistle

slender thistle
earnest phoenix
#

who can help me for roles permissions bitfield but in discord.js v11.5.1

amber fractal
#

wym

#

converting to or from a bitfield

#

or understanding them?

earnest phoenix
#

No, it's to store it in json.

amber fractal
earnest phoenix
#

No wait

#

When I want to save the guild everything is saved in the json file except the roles permissions

amber fractal
#

are you trying to clone a guild?

earnest phoenix
#

No i try to make a saver bot

#

like xenon but in js

#

Then it will probably be open-source.

golden herald
#

I have got an error with this code:

before = time.monotonic()
msg = await channel.send("Starting ping test")
ping = (time.monotonic() - before) * 1000
await channel.delete(msg)
#

I have only given 1 argument, but the python thinks I gave 2

earnest phoenix
#

...

golden herald
#

very helpful

unique nimbus
#

Are you on rewrite?

earnest phoenix
#

Me?

golden herald
#

don't think so?

unique nimbus
#

no Kiyan

#

because it would be await msg.delete()

golden herald
#

Thanks, fixed it somehow xd

unique nimbus
#

It is called Reading the docs

fickle anvil
#

Okay I am stupid and new and just don't get it...

const { file } = await fetch('https://'+login+':'+key+'@danbooru.donmai.us/posts.json?random=1&limit=1&tags=kanna_kamui%20rating:s').then(response => response.json());
        message.channel.send(file);

How do I get the object large_file_url out of that?

earnest phoenix
#

response.body.large_file_url

#

I think

fickle anvil
#

ReferenceError: response is not defined

#

sadly not

earnest phoenix
#

use snekfetch or axios for the request

fickle anvil
#

I rather not, as they are deprecated and you are highly advised to use node-fetch 😄

earnest phoenix
#

Okay

quartz kindle
#

@fickle anvil console.log(file)

fickle anvil
#

"undefined"

quartz kindle
#

That means there is no "file" field in the response

#

Youre trying to extract a "file" field from it

fickle anvil
#

I thought I specify "file" with the {file}...

quartz kindle
#

Yes, youre specifying a "file" field

#

And its telling you it doesnt exist

fickle anvil
#

but where is my error?

earnest phoenix
#

File doesn't exist

#

PAPI

fickle anvil
#

hmm if I take off the {} I get an object containing the json content

earnest phoenix
#

PAPI

#

PAPI

#

PAPI

#

PAPI

#

PAPI

#

PAPI

quartz kindle
#

@fickle anvil yes

earnest phoenix
#

PAPI

#

PAPI

#

PAPI

#

PAPI

#

PAPI

#

PAPI

#

PAPI

#

PAPI

#

@earnest phoenix stop

#

PAPI

quartz kindle
#

Someone call a mod

earnest phoenix
#

@modern sable

#

Kk

modern sable
#

ty

earnest phoenix
#

np

fickle anvil
#

how can I now "extract" e.g. large_file_url out of it? appending .large_file_url or the earlier mentioned .body.large_file_url won't do.

quartz kindle
#

If you dont use {}, you get the full object. Then you can simply fullobject.fieldyouwant.
If you use {}, you have to specify directly the field you want

fickle anvil
#

and how do I specify it?

#

I am playing around for like 6 hours with it now ._.

quartz kindle
#

Console log the full response

#

And you'll see what the structure looks like

fickle anvil
#

it looks exactly like this

golden herald
#

Does anyone know how to change the position of a category in discord.py?

quartz kindle
#

Well, notice the first character in the response

#

Its a [

#

That means its an array

#

So you cannot access it directly by a field, you need to specify the array index first

#

Fullresponse[index].field

#

If you only want the first item, use index 0

fickle anvil
#

console.log(file[0].large_file_url);

returns: TypeError: Cannot read property '0' of undefined

quartz kindle
#

How did you define file?

fickle anvil
#

It's just the bit of code you see, except that I define the login and token and include discord and node-fetch

quartz kindle
#

Because as i said before, if you use {file}, its not a full response, its an attenpt at getting a field called "file" from the response

#

{file} is the same as fullresponse.file

fickle anvil
#

ah ok, let me try something

#

It seems it works now

#

lemme check live

#

it works... finally.

#

on another json it worked the way I did it in my example

#

still a bit confused about some workflows

#

big thanks @quartz kindle !

quartz kindle
#

The other json might have had a file field

fickle anvil
#

it has and is not an array as I just see.

#

that stupid little [

#

so if it wouldn't be surrounded by that [] it would have worked as I tried?

quartz kindle
#

@earnest phoenix there is no permissions.bitfield

#

Permissions is already the bitfield

earnest phoenix
#

Oh

quartz kindle
#

@fickle anvil idealy yoi want to work with the full response, and not use {}, unless yoi know what youre doing

#

Using the full response, you can log it to see how it looks and navigate throigh it one step at a time

fickle anvil
#

it's my first time working with APIs via javascript ^^ only did that like 15 years ago on php. 😄

#

okay but if it is that easy now, it shouldn't be anymore problem

#

the solution is quite easy, if you know how to do it

quartz kindle
#

Yeah if you have php experience its mostly thr same thing

earnest phoenix
#

:/

quartz kindle
#

You didnt map them

earnest phoenix
#

Thank you i test this

#
"roles":[{"idOld":"367754140723445770","name":"Test1","hexColor":"#9e3838","hoist":false,"mentionable":false,"position":36,"defaultRole":false,"permBitfield":264}]```
#

Thank you

golden herald
#

Does anyone know how to change the position of a category in discord.py?

earnest phoenix
#

Idk

golden herald
#

Ok another question, does anyone know how to setup a vc in python

#

and put it in a category?

abstract oasis
#

anyone know how to set the bot's presence when using discord botkit?

golden herald
#

Nope sorry

earnest phoenix
#

Trying to make a ping command that gives the bots ms. I keep getting a error

start = time.time()
        msg = await self.safe_send_message(channel, "Pong!")        
        end = int((time.time() - start)*1000)
        return await self.edit_message(msg, "Pong! %sms" % end)    
#

I'm stuck

#

its 1am

golden herald
#

is this .py?

earnest phoenix
#

Yep

#

.py

golden herald
#

same here I need help too xd

#

um

#

one sec

#
@bot.command(pass_context = True)
async def ping(ctx):
    channel = ctx.channel
    before = time.monotonic()
    msg = await channel.send("Starting ping test")
    ping = (time.monotonic() - before) * 1000
    await channel.send(":ping_pong: Pong! **{}ms**".format(int(ping)))
    print(f'Ping {int(ping)}ms')
    await msg.delete()
#

This is my ping command

#

works pretty good!

#

gtg now

earnest phoenix
#

message.guild.owner.user.username says user is undefined when i do my serverinfo command here

#

but it works everywhere else

quartz kindle
#

Might not be cached

#

Try fetchUser(message.guild.owner)

earnest phoenix
#

I don't know how to setup a console like command. I tried storing the command params then using the variable they are stored in in a message. That does not work though.

cunning goblet
#

1.Args are strings

#

If you want it to send that then you need to eval the string

undone rose
#

You need to eval, also why type it like its a template literal?

earnest phoenix
#

Because that's the second try and I wanted to know if making it literal would owrk

cunning goblet
#

It wont

#

It will just treat it as a string

earnest phoenix
#

Ohh

cunning goblet
#

And JavaScript will escape your characters

#

So it won't ever work

earnest phoenix
#

Oh

#

How to save channels permissions bitfield ?

earnest phoenix
#

:/

tranquil drum
#

what do you mean lol

earnest phoenix
#

Hmmm

#

Save the categories roles permissions for restore later

#

In a json file

earnest phoenix
#
 async def on_message(message):
        if message.content.startswith(f'@Jam_'):
            await bot.send_message(message.channel, f"The prefix for Jam_ is `ja`, Use jahelp for more commands.")

Trying to @ mention the bot, just can't figure it out. I've tried, just i cant its 3am

#

Lol

#

Use

#

<@BOT-ID>

#

biggest of brains i am

#

i knew that

#

pfff

#

:)

earnest phoenix
#

Who is here?

wheat jolt
earnest phoenix
#

This is for comment like //

cunning goblet
#

this is for comment like

#

you do not know what jsdoc is

#

@wheat jolt it's for jsdoc and not a normal comment

earnest phoenix
#

nekomikoreimu can you help me?

#

Hmmm...

cunning goblet
#

yes

earnest phoenix
#

ping me if anyone is available

#

Oh

#

You can help me in discord.js?

cunning goblet
#

yea

earnest phoenix
#

Okay wait

#
async function send(channel) {
      try { var x = await channel.fetchMessages({limit: 10}) } catch (e) {} 
      x = x.array().reverse()
      for (let i = 0; i < x.length; i++) {  
      await newguild.channels.find(q => q.name == x[i].channel.name).createWebhook(x[i].author.username, x[i].author.avatarURL).then(async w => {       
      try { 
      await w.send(x[i].content) 
      await w.delete()
      } catch (e) {        
      await w.delete()
      } 
      })                          
      }
      await message.channel.send(`restore: ${x.length} messages from text channel ${channel}!`)   
      }```
I try to make a backup bot and i don't know why i have:
#
(node:17834) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'array' of undefined
cunning goblet
#

can you send me the line the error happended on

wheat jolt
#

this one

earnest phoenix
#

Yes

blissful scaffold
#

x is not defined

earnest phoenix
#

x is defined

blissful scaffold
#

x is defined

wheat jolt
#

yup

#

that's right

cunning goblet
#

at the start of your send function

#

try using var x; isntead i guess

blissful scaffold
#

x is defined inside the try/catch block and can't be used outside that block?

earnest phoenix
#

But i know fetchMessages in x

#

...

wheat jolt
#

It can be used @blissful scaffold

#

it doesn't matter

blissful scaffold
#

ah, i only know Java, in Java you can't use it outside a block if you define it inside a block

#

my bad

wheat jolt
#

np

earnest phoenix
#

How can I fix this?

wheat jolt
#

try removing the try/catch block

#

🤷

earnest phoenix
#

Okay

cunning goblet
#

that wont do anything?

#

the try catch block prevents the code from stopping on error

wheat jolt
#

ik

blissful scaffold
#

or maybe place a log in the catch, it could be that there is an error that you ignore

valid frigate
#

honestly a bunch of resources arent helping me on this but what is the difference between single & and double && in java (same with | and ||)? ik that & is bitwise but wtf does that mean lmao

wheat jolt
#

The collection might be empty

#

I mean, the channel might have no messages

#

or the bot doesn't have access to view it

earnest phoenix
#

@blissful scaffold the error: (node:17834) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'array' of undefined

wheat jolt
#

idk

earnest phoenix
#

Alex the bot is admin lol

valid frigate
#

lol you havent defined array

cunning goblet
#

@valid frigate i cant java but im pretty sure their aliases

blissful scaffold
#
try { var x = await channel.fetchMessages({limit: 10}) } catch (e) {}

you ignore any errors that might happen here

wheat jolt
earnest phoenix
#

@valid frigate explain

valid frigate
#

that's just the thing

#

like

#

they work the same ig

#

cant complain mmLol

#

also dany this means you've probably defined a variable somewhere and are trying to reference variable.array despite there being none

cunning goblet
#

then their probably just aliases

#

so people wont make too many mistakes

blissful scaffold
#

if there is also an error while fetching messages then you will never know that and x will not be defined

wheat jolt
#

@valid frigate x should be a collection and discord.js collection have a function, array()

#

@earnest phoenix try console.log(x)

valid frigate
#

shouldnt he be calling variable.array() then instead of trying to get a property

earnest phoenix
#
async function send(channel) {
      try { var x = await channel.fetchMessages({limit: 10}) } catch (e) {} 
      x = x.array().reverse()
      for (let i = 0; i < x.length; i++) {  
      await newguild.channels.find(q => q.name == x[i].channel.name).createWebhook(x[i].author.username, x[i].author.avatarURL).then(async w => {       
      try { 
      await w.send(x[i].content) 
      await w.delete()
      } catch (e) {        
      await w.delete()
      } 
      })                          
      }
      await message.channel.send(`restore: ${x.length} messages from text channel ${channel}!`)   
      }```

@valid frigate all is define
valid frigate
#

bruh

earnest phoenix
#

@wheat jolt okay

tranquil drum
#

@valid frigate bitwise & does and AND operation between 2 primitive data types

earnest phoenix
#
var x = await channel.fetchMessages({limit: 10})
      x = x.array().reverse()
      console.log(x)```
like this? @wheat jolt
valid frigate
#

is && for non primitive?

tranquil drum
#

example you can & 2 ints

wheat jolt
#

no

earnest phoenix
#

or before?

wheat jolt
#

before

earnest phoenix
#

Okay

wheat jolt
#

.array()

tranquil drum
#

& is a mathematic operator

wheat jolt
#

because it'll throw the error

tranquil drum
#

&& evaluates two booleans

wheat jolt
#

and it won't console.log

valid frigate
#

ah that makes sense

#

honestly i had no clue why & and && were working the same

earnest phoenix
#
var x = await channel.fetchMessages({limit: 10})
      console.log(x)``` like it?
wheat jolt
#

yes

#

run it

earnest phoenix
#

Okay

wheat jolt
#

show me the output

earnest phoenix
#

Yes wait the bot restore the save, i have a bad ping

tranquil drum
#

like

int x = 0;
int y = 1;
System.out.println(x & y); // prints 0
x = 1;
System.out.println(x & y); // prints 1
System.out.println(x && y); // pretty sure an error about && being used on ints
valid frigate
#

huh

blissful scaffold
#

& is for bitwise comparison

valid frigate
#

so obv this isnt js so yeah doing int && int where there's supposed to be boolean && boolean would throw an error

earnest phoenix
#

The console.log make an other error

#

For the emoji restore bruh

wheat jolt
#

give me the output ffs

#

doesn't matter if it's an error

earnest phoenix
#

Oh no wait i don't have any emojis

blissful scaffold
#

@earnest phoenix you ignored any possible error that might happen while fetching the messages in your earlier code

wheat jolt
blissful scaffold
#

just show alex the result

earnest phoenix
#

@blissful scaffold idk

#

Wait

#

I create a pastebin

#

(node:22659) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access

#

Bruh

#

RIP me

#

I'm going to add a condition

dull ember
#

i used to be able to change the entire page css inside the long description but it doesnt seem to work anymore

cinder patio
#
        console.log(roles);
        message.channel.send(`Successfully changed rolelist to:\n\`\`\`${roles.join("\n")}\`\`\` `)
#

Does anyone know why this is happening?

#

There should be two "Any" in the message

late hill
#

Because in codeblocks you put the language for the codeblock on the first line

#

Your first "any" is being put there and for that reason not being displayed

cinder patio
#

thanks that fixed it

safe pecan
#

How to make the bot execute the code that I will send to it?

shadow dust
#

Hey, does anyone know about a software that reduces your own internet speed ?

safe pecan
#

This can be done in the windows settings.

shadow dust
#

I cant find anything similar in the control panel, I have found how to set a data limit but thats not exactly what I want

safe pecan
#

why do you need this? to reduce the number of bot requests?

cinder patio
#

eval function if the bot is written in javascript

safe pecan
#

I already found a guide;)

earnest phoenix
#

hey

#

can someone help me

#

with api

near ether
#

@shadow dust look up net limiters

#

You can choose which application receives limited internet speed

shadow dust
#

Oh thanks a whole bunch

#

@safe pecan no, I have some code that executes only when something else is being requested, and its kinda hard to test with 35mb/s

quartz kindle
#

that shouldnt be a reason for why its hard to test. if your code doesnt work because a request is "too fast", then the code should be reworked

earnest phoenix
#
async def on_message(message):
        if message.content.startswith(f'@untold hull'):
            await bot.send_message(message.channel, f"The prefix for Jam_ is `ja`, Use jahelp for more commands.")

Trying to mention the bot for prefix?

west spoke
#

a s y n c

#

that should work.

#

@earnest phoenix are you re-calling on_message for every command?

earnest phoenix
#

yes

west spoke
#

@slender thistle you thought me using async was dumb

#

dont

#

only call it once

#

and use multiple if statements in it.

#
   if(x):
      pass
   if(y):
      pass```
#

replace x and y with your commands.

shadow dust
#

@quartz kindle yeah and all the calls im doing within that short amount of time have been tested independently, but I do want to see if at that specific point in application time it also works properly

quartz kindle
#

if the idea is implemented correctly, it should work regardless or that, ie: chain events correctly, use promises, no global variables, etc

fleet mason
#

Si there a way i can make this work? "trips" : {"loc": "stats.trips"}, and get the data from a object like js const p = { stats: { trips: 1}} let trips = p["stats.trip"]

dusky marsh
#

p['stats']['trip']

fleet mason
#

yea ik but the loc can be all sort of stuff so how can i make it the easiest way possible

twin kestrel
#

Hello everyone!
Recently one of my bot's shards has crashed without granting any error as such.

I only have this in the records (but I can't get anything clear).

ChildProcess {
  domain: null,
  _events: 
   { internalMessage: [Function],
     exit: [Function: bound _handleExit],
     message: [Function: bound _handleMessage] },
  _eventsCount: 3,
  _maxListeners: undefined,
  _closesNeeded: 2,
  _closesGot: 1,
  connected: false,
  signalCode: null,
  exitCode: 1,
  killed: false,
  spawnfile: '/usr/bin/node',
  _handle: null,
  spawnargs: [ '/usr/bin/node', '/Discord/Filo/index.js' ],
  pid: 29127,
  stdin: null,
  stdout: null,
  stderr: null,
  stdio: [ null, null, null, null ],
  channel: null,
  _channel: [Getter/Setter],
  _handleQueue: null,
  _pendingMessage: null,
  send: [Function],
  _send: [Function],
  disconnect: [Function],
  _disconnect: [Function] }

(I have to admit that this shard had been online for more than 4 weeks and I don't know if that can influence the crashing)

quartz kindle
#

thats just the childprocess object, you console.logged it somewhere for some reason

grim aspen
#

nice, just came up

quartz kindle
#

missing permissions

twin kestrel
#

Already but I don't get any reason why she crashed

grim aspen
#

figured

quartz kindle
#

@twin kestrel nothing you can do about it, except trying to set up better logging/error handling for the next time it happens

grim aspen
#

from what i've read through a forum, it has to do with roles

quartz kindle
#

@grim aspen its on the /messages endpoint, it has to do with a message

twin kestrel
#

It's pretty weird, but I'll see what to do

blissful scaffold
#

Creeper, what is the bot trying to do when it happens?

quartz kindle
#

you can use that ID to check in which channel/guild it happened

#

does the error show the method? GET/POST/PATCH/etc

grim aspen
#

post

#

with promise

quartz kindle
#

POST means its about sending a message

blissful scaffold
#

Maybe the bot has no permission to send messages in that channel

grim aspen
#

unless it's having to do with me putting slowmode in my support server

#

due to a previous raid

quartz kindle
#

its a possibility

blissful scaffold
#

That is possible I guess

quartz kindle
#

make a test, set up slow mode, and have the bot send two messages

grim aspen
#

was rich embed recently updated?

quartz kindle
#

dont think so

grim aspen
#

@quartz kindle likely solved; missing package

#

imma give it a few minutes to see if it will do it again

#

what was that

#

not solved nvm

#

oh i think i know now, one of the guilds must've muted it

split hazel
#

How would you ssh tunnel a --inspect node debug?

grim aspen
#

i was able to copy the error i'm getting

#
    at item.request.gen.end (/rbd/pnpm-volume/71b5ddd8-2a78-46fc-aba4-68049f14880d/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
    at then (/rbd/pnpm-volume/71b5ddd8-2a78-46fc-aba4-68049f14880d/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'DiscordAPIError',
  message: 'Missing Permissions',
  path: '/api/v7/channels/265156361791209475/messages',
  code: 50013,
  method: 'POST' } Promise {
  <rejected> { DiscordAPIError: Missing Permissions
      at item.request.gen.end (/rbd/pnpm-volume/71b5ddd8-2a78-46fc-aba4-68049f14880d/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
      at then (/rbd/pnpm-volume/71b5ddd8-2a78-46fc-aba4-68049f14880d/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
      at process._tickCallback (internal/process/next_tick.js:68:7)
    name: 'DiscordAPIError',
    message: 'Missing Permissions',
    path: '/api/v7/channels/265156361791209475/messages',
    code: 50013,
    method: 'POST' } }
blissful scaffold
#

My bot had errors in the past because people tried to send commands to the bot in a channel where he was muted.
I now always check for permission to send messages before sending a message and if there is no permission then nothing will be send.
Another option could be to DM the person who used the command and inform him/her that the bot has no permission to answer

#

But make sure that person has DM's open for bots

slim heart
#

So atm, for my dashboard, if someone doesnt have a token or token is invalid it sends a redirect back through express. However, i want to be able to detect when the OG (opengraph) is being used and send back proper OG meta tags. What, if any, is the best way to detect if something is just looking for og? My next best solution is to return an html page that just has the og metas and redirects through javascript. It seems improper however its all i can think of atm.

earnest phoenix
#

What, if any, is the best way to detect if something is just looking for og
there isn't

#

scrapers get the html on load and then they parse it themselves and look for the opengraph tags

#

i don't get what's your goal here

slim heart
#

rn i do res.redirect() if someone doesnt have a token. which means the og embed from the dashboard page pulls up the discord oauth login page embed.
I just made it so it redirects through javascript. However it feels like thats not the best way. Theoretically if you were able to identify what requests are from the opengraph protocol you could send something different, in this case being the og meta tags while actual people are actually redirected.
Right now this is what the html looks like

<!DOCTYPE html>
<html>
    <head>
        <meta property="og:title" content="Censor Bot Dashboard">
        <meta property="og:image" content="https://censorbot.jt3ch.net/censorbot.png">
        <meta property="og:description" content="Change and customize Censor Bot for your server(s)!">
        <meta name="theme-color" content="#ff3d00">
    </head>
    <body>
        <script>
            window.location = "<%= link %>"
        </script>
    </body>
</html>```
just seems inefficient but not sure 🤷
earnest phoenix
#

why do you not want to include meta tags?

slim heart
#

because it directly uses res.redirect instead

earnest phoenix
#

k

#

and?

slim heart
#

and obv i cant use meta tags in those

quartz kindle
#

opengraph is client side, you cannot send opengraph tags and redirect internally at the same time

#

either send both the redirect and the tags to the client, or send none

earnest phoenix
#

discord's scraper doesn't execute the javascript

slim heart
#

well theoretically if i were able to identify if it was an og request, i could send the meta tag html, while if its not redirect()

quartz kindle
#

there is no "og request"

#

a request is a request, its all the same

slim heart
#

i mean like if it has the intent of finding og or the intent of actually going to the page

quartz kindle
#

thats impossible to detect

#

the closest thing to what you want would be to parse user agent information from the headers to know what kind of client it is (ie, browser or not)

slim heart
#

mk

lofty hamlet
#

Hi

#

{"349667929559662595":{"NomDresseur":"enzo69007#4575","Points":0,"Grade":"Dresseur Débutant (0 - 350)","GradeG":"Joueur","BDDTitre":["Joueur"],"Team":"Aucune","Magma":false,"Rocket":false,"Aqua":false,"MachineF":false,"MégaCAP":false,"ActiveTeam":false,"Start":false,"Premium":false,"Cânne_A_Pêche":false,"NumDresseur":39,"Pokedollars":0,"Sac":["Marisson (Starter)"],"SSac":[],"LSSac":[],"LSac":[],"GSac":[],"LGSac":[],"NbPokemons":1,"Pokedex":[0],"TempsVote":0,"TempsBcrate":0,"Potion":0,"Famillier":"","XP":0,"Appât":0,"HawlloweenItem":1572275616978,"TempsCatch":0,"Niveau":0,"NiveauP":0,"TempsDailyPoke":0,"TempsInvest":0,"TempsHr":0,"TempsDy":0,"TempsPeche":0,"Quete1":1572275616978,"Quete2":0,"Quete3":0,"Quete4":false,"Quete5":false,"Quete6":false,"SoonC1":[],"SoonC2":[],"SoonN1":0,"SoonN2":0,"SoonN3":0,"SoonNA1":"","SoonNA2":"","SoonO":[0],"SoonFT1":false,"SoonFT2":false,"SoonFT3":true,"SoonFT4":true},"495855787374280734":{"NomDresseur":"Lucas.prcl#4963","Points":12,"Grade":"Dresseur Débutant (0 - 350)","GradeG":"Joueur","BDDTitre":["Joueur"],"Team":"Aucune","Magma":false,"Rocket":false,"Aqua":false,"MachineF":false,"MégaCAP":false,"ActiveTeam":false,"Start":false,"Premium":false,"Cânne_A_Pêche":false,"NumDresseur":6,"Pokedollars":0,"Sac":["Moustillon (Starter)","Héliatronc (Normal)"],"SSac":[],"LSSac":[],"LSac":[],"GSac":[],"LGSac":[],"NbPokemons":2,"Pokedex":[0],"TempsVote":0,"TempsBcrate":0,"Potion":0,"Famillier":"","XP":0,"Appât":0,"HawlloweenItem":1572279792314,"TempsCatch":1572279814403,"Niveau":0,"NiveauP":0,"TempsDailyPoke":0,"TempsInvest":0,"TempsHr":0,"TempsDy":0,"TempsPeche":0,"Quete1":1572279792314,"Quete2":0,"Quete3":0,"Quete4":false,"Quete5":false,"Quete6":false,"SoonC1":[],"SoonC2":[],"SoonN1":0,"SoonN2":0,"SoonN3":0,"SoonNA1":"","SoonNA2":"","SoonO":[0],"SoonFT1":false,"SoonFT2":false,"SoonFT3":true,"SoonFT4":true}}

#

With this how i can get the first "Points" ?

#

Dresseurs is the name of files so Dresseurs[1].Points ?

ornate shoal
#

What encoding does Discord use? So i can avoid getting usernames like this

quartz kindle
#

thats unicode

lofty hamlet
#

@quartz kindle no i want make loop for replace of the .Points of all "Dresseurs"

#

So how i can get the first ".Points" with number ?

#

Dresseurs[1].Points ? Does not work

quartz kindle
#

no

#

its an object, not an array

#

you need to use object keys

lofty hamlet
#

Mmmh

#

So ?

#

How i can get this ? 🙂

quartz kindle
#

if you dont know the keys, you need to get them, you can use Object.keys(file)

lofty hamlet
#

Mmmh

quartz kindle
#

that will give you an array of keys

lofty hamlet
#

So :

#

Object.keys(Dresseurs[1].Points)

quartz kindle
#

you can also use Object.values(file) if you dont need the keys

#

no

lofty hamlet
#

?

#

🤔

quartz kindle
#

Dresseurs[1] doesnt exist

lofty hamlet
#

Mmmh

#

How i can get the first .Points ?

quartz kindle
#

its a two-step thing

#

first transform the data into keys or values

#

then use those keys or values to get the data

#

example

#
let file = {"39728974892":data,"8272840":data,...}
let keys = Object.keys(file);
console.log(keys) // ["39728974892","8272840",...]
keys.forEach(key => {
    // do something with each key
})```
lofty hamlet
#

Mmmh

quartz kindle
#

another option is to use values directly:

lofty hamlet
#

Ok i explain

#

{"349667929559662595":{"NomDresseur":"enzo69007#4575","Points":0,"Grade":"Dresseur Débutant (0 - 350)","GradeG":"Joueur","BDDTitre":["Joueur"],"Team":"Aucune","Magma":false,"Rocket":false,"Aqua":false,"MachineF":false,"MégaCAP":false,"ActiveTeam":false,"Start":false,"Premium":false,"Cânne_A_Pêche":false,"NumDresseur":39,"Pokedollars":0,"Sac":["Marisson (Starter)"],"SSac":[],"LSSac":[],"LSac":[],"GSac":[],"LGSac":[],"NbPokemons":1,"Pokedex":[0],"TempsVote":0,"TempsBcrate":0,"Potion":0,"Famillier":"","XP":0,"Appât":0,"HawlloweenItem":1572275616978,"TempsCatch":0,"Niveau":0,"NiveauP":0,"TempsDailyPoke":0,"TempsInvest":0,"TempsHr":0,"TempsDy":0,"TempsPeche":0,"Quete1":1572275616978,"Quete2":0,"Quete3":0,"Quete4":false,"Quete5":false,"Quete6":false,"SoonC1":[],"SoonC2":[],"SoonN1":0,"SoonN2":0,"SoonN3":0,"SoonNA1":"","SoonNA2":"","SoonO":[0],"SoonFT1":false,"SoonFT2":false,"SoonFT3":true,"SoonFT4":true},"495855787374280734":{"NomDresseur":"Lucas.prcl#4963","Points":12,"Grade":"Dresseur Débutant (0 - 350)","GradeG":"Joueur","BDDTitre":["Joueur"],"Team":"Aucune","Magma":false,"Rocket":false,"Aqua":false,"MachineF":false,"MégaCAP":false,"ActiveTeam":false,"Start":false,"Premium":false,"Cânne_A_Pêche":false,"NumDresseur":6,"Pokedollars":0,"Sac":["Moustillon (Starter)","Héliatronc (Normal)"],"SSac":[],"LSSac":[],"LSac":[],"GSac":[],"LGSac":[],"NbPokemons":2,"Pokedex":[0],"TempsVote":0,"TempsBcrate":0,"Potion":0,"Famillier":"","XP":0,"Appât":0,"HawlloweenItem":1572279792314,"TempsCatch":1572279814403,"Niveau":0,"NiveauP":0,"TempsDailyPoke":0,"TempsInvest":0,"TempsHr":0,"TempsDy":0,"TempsPeche":0,"Quete1":1572279792314,"Quete2":0,"Quete3":0,"Quete4":false,"Quete5":false,"Quete6":false,"SoonC1":[],"SoonC2":[],"SoonN1":0,"SoonN2":0,"SoonN3":0,"SoonNA1":"","SoonNA2":"","SoonO":[0],"SoonFT1":false,"SoonFT2":false,"SoonFT3":true,"SoonFT4":true}}

#

This .json file have name :

#

Dresseurs

quartz kindle
#
let file = {"39728974892":data,"8272840":data,...}
let values = Object.values(file);
console.log(values) // [data,data,...]
values.forEach(value => {
    // do something with each value
})```
lofty hamlet
#

And i want make loop for have each .Points and replace them

quartz kindle
#

you already explained

#

and i told you what you need to do

lofty hamlet
#

Mmmh with this i can make loop for get all .Points with i ? let file = {"39728974892":data,"8272840":data,...} let values = Object.values(file); console.log(values) // [data,data,...] values.forEach(value => { // do something with each value })

quartz kindle
#

that was an example yes, there are many ways to do it

lofty hamlet
#

I don't understand

#

I don't see the files : Dresseurs

#

And the .Points

quartz kindle
#

what dont you understand? i already explained

#

you just need to think

#

and use your brain

lofty hamlet
#

Mmmh

lofty hamlet
#

I go test and truy this

#

Try

lofty hamlet
#

@quartz kindle so here i do replace what by .Points or Dresseurs ?

earnest phoenix
sudden geyser
#

do what part specifically

earnest phoenix
#

hello how to make sure that if 2 bots are connected to the same script and I type a command that bot 1 receives, but I want bot 2 to tell me in my private messages that this command has been executed even if it is not on the server where bot 1 received the command

amber fractal
#

You wouldnt need 2 bots for this and it's highly unrecommended.

earnest phoenix
#

even if it’s not recommended I’d still like to do it please

amber fractal
#

Well is there a reason you need to log it? And why not just use console

undone rose
#

Its pretty simple to do, but pointless as you could just do both with the first bot

quartz kindle
#

well, if you really wanna do it, its as easy as js bot1.on("message", message => { // do something with message bot2.channels.get(yourChannel).send(yourmessage) })

#

assuming discord.js

undone rose
#

Sounds shady to me

blissful scaffold
#

Why not just let bot1 DM you?

quartz kindle
#

maybe he just wants to test it, so he can use it later for something else

earnest phoenix
#

it wasn’t really that my idea but good no big deal thanks for helping me

#

Wait

golden herald
#

Does anyone know how to change the position of a category in discord.py?

modest maple
#

i think my friend had a couple issues with it not being very reliable in terms of actually positioning it properly, i cant remeber the exact command try the discord.py API docs

golden herald
#

That is what I did and found no answer from it

#

Alright this ridiculous, can anyone out of the 2028 members that have made a bot help me?

#

I have asked last night and today too

modest maple
#

mate ngl 1) discord.py isnt used for bots as much as others and 2) if you really need help i suggest going to a) the python Discord or B) going to the discord.py discord for help 3) last time i checked the discord.py category position Did not work

#

@golden herald

golden herald
#

Aight, could you dm the python discord link, cos I cannot find it xd

hoary bramble
#

quick question
how would i make it so that my bot sends the time that a user called a command?

#

in python

modest maple
#

@hoary bramble

from datetime import datetime

@client.event # or what ever you use.....

Time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') # the part that actually gets you the time

await message.channel.send(f"This time {Time}") # this would also work with a print statement or anything rlly

#

the Time var will like this when its out putted:

2019-10-28 21:56:28

slender thistle
#

str()-ing it could be enough

modest maple
#

that aswell yes xD

slender thistle
#

I suggest doing it under the command object itself if you use the commands extension

modest maple
#

yh

oblique gulch
#

Could someone help me on my Google Cloud? She decided to give error out of nowhere, does not open her SSH, thanks in advance!

quartz kindle
#

google cloud is female?

#

what is the error?