#development

1 messages · Page 837 of 1

digital ibex
#

it logs now, ty, but client isn't a thing even when i define it

quartz kindle
#

you're only passing a message object

#

either pass the client as well, or get it from the message

digital ibex
#

wdym get it from the message?

#

like message.client?

pale vessel
#

check the docs and see if eris supports that

digital ibex
#

it doesn't

pale vessel
#

then pass the client directly

earnest phoenix
#

Works perfectly

quartz kindle
#

does Eris not have client attached to a message?

digital ibex
#

ok

modest maple
#

i think it is only d.js

pale vessel
#

@earnest phoenix not bad

digital ibex
#

i passed it directly and i get this error (node:15388) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized on POST /channels/686997585541726264/messages

quartz kindle
#

how did you pass it?

sudden geyser
#

does Eris not have client attached to a message?
It does, but starts with an underscore (<Message>._client)

#

Try to send the message to that user. If you can't, you can't DM the user.

slate oyster
pale vessel
#

ask staff

zenith terrace
#

what have you tried doing

finite bough
#

check if the channel is nsfw

slate oyster
#

@bitter sundial Somebody said to ask staff

#

So I also have a giphy commabd

#

but even if I try to force it to produce nsfw content
it does not

finite bough
#

can u explain in details

slate oyster
#

So I assume the lib I'm using has the filter set to pg

bitter sundial
#

and why are you asking me

robust moth
slate oyster
#

Somebody said to ask

digital ibex
#

@quartz kindle like this:

const Eris = require('eris');
const { token } = require('..//../config.json');
const client = new Eris.CommandClient(token);```
zenith terrace
#

@robust moth version?

digital ibex
#

sorry i took ling

finite bough
#

@robust moth show code

robust moth
#

@zenith terrace 12

zenith terrace
#

MessageEmbed for v12

digital ibex
#

@robust moth its Discord.MessageEmbed()

#

o

#

yeah

#

ok

quartz kindle
#

@digital ibex in your command file?

pale vessel
#

well it could potentially send an nsfw gif

robust moth
#

@digital ibex i know it

digital ibex
#

and in the file im trying use it

#

yeah mr who

quartz kindle
#

thats not passing

#

thats creating a new client

digital ibex
#

oh

pale vessel
#

.execute(message, client)

#

like that?

finite bough
#

@slate oyster can u explain what is it u need help with

pale vessel
#

he has a giphy command that he allegedly disabled nsfw but bot still got declined

digital ibex
#

i dont have client, i have args instead of client

quartz kindle
#

passing is this: ```js

// main file
client = new Client()
execute(client)

// command file
execute: client => {

}

digital ibex
#

oh

zenith terrace
#

Tim tim

pale vessel
#

how did you disable nsfw, is it an option available on the api?

#

(is there even an api)

slate oyster
#

Somebody else's bot was declined

pale vessel
#

o h

slate oyster
#

So I was checking

pale vessel
#

minimodding?

slate oyster
#

I read the giphy docs

pale vessel
#

well don't bother

#

leave it

slate oyster
#

There is a pg option

digital ibex
#

@quartz kindle like this?

    try {
        command.execute(message, args, client);
    } catch (e) {
        console.log(e);
        client.createMessage('689557849214418972', e);
        client.createMessage(message.channel.id, 'An error occured.');
    }```
pale vessel
#

it's not yours

digital ibex
#

?

slate oyster
#

So for my bot

#

I also have a giphy command

#

And I dunno wether my api uses the pg field

digital ibex
#
module.exports = {
    name: 'ww',

    execute: (message, client) => {
        console.log('e');

        

    }
};``` and in the command file
pale vessel
#

you said you checked the docs

slate oyster
#

Yes
there is a field for it

pale vessel
#

then make it pg

earnest phoenix
slate oyster
#

But I'm using an API

pale vessel
#

nice emoji

slate oyster
#

A library

robust moth
#

@quartz kindle client.commands = new discord.Collection(); client.commands.get(command).execute(message, args);

slate oyster
#

I dunno if my library sets it to pg by default
But I assumed it did

zenith terrace
#

Do anyone know how to check if a role is higher than another?

e.g. I will use Subject A and Subject B

Both Subject A and B has the kick perm, but subject A has a role higher than Subject B but Subject B can still kick Subject A with the bot. So how do you check if a role is higher than the other so that Subject B cannot kick a higher role?

Is that possible?

slender thistle
#

role.position? special_think

digital ibex
#

if u r using d.js u can just use <member>.bannable

#

btw

pale vessel
#

highest role maybe

quartz kindle
pale vessel
#

highest role position

slate oyster
#

Maybe I'll just read the libraey

zenith terrace
#

I tried looking at docs but cannot find it

slate oyster
#

spource

pale vessel
#

a r g s

digital ibex
#

tim im confused on what thats supposed to mean

quartz kindle
#

arguments are passed in order

#

not by name

#

you pass message as the first argument, so the first argument in the command file is message

#

you pass args as the second argument

#

so in the command file, your client is actually args

slate oyster
quartz kindle
#

not client

digital ibex
#

Oh

#

My bad

quartz kindle
#

and you pass client as the third, and you have no third

earnest phoenix
#

rating is optional btw

#

if you're using the giphy api

#

or am i getting something wrong

slate oyster
#

So it looks like the default is 'g'
So I dunno how the one person's got marked as producing nsfw images

digital ibex
#

ok client still isn't a thing

#

like

slate oyster
#

oh nm

#

default is all

earnest phoenix
slate oyster
#

But I dunno if my library is setting the rating
I'm assuming it is

zenith terrace
#

role.position? :special_think:
@slender thistle is that what it is or you suggesting

#

?

pale vessel
#

what it is

slender thistle
#

I was assuming your library had position property for roles

digital ibex
pale vessel
#

perhaps the highest role would do

quartz kindle
#

@earnest phoenix the only way is to try sending a message, and catch the error

pale vessel
#

member.roles.highest.position >= me.roles.highest.position

zenith terrace
#

Ah ok, I'll try that

pale vessel
#

that's v12

#

if you're on v11 it would be highestRole

digital ibex
#

doesn't bannable cover that?

zenith terrace
#

Kk

pale vessel
#

removing roles would be a problem

zenith terrace
#

So v11 would be member.highestRole.position > me.highestRole.position

earnest phoenix
#

guys, superagent not working

pale vessel
#

yes

zenith terrace
#

Aight

pale vessel
#

console.log it first

zenith terrace
#

Ok

quartz kindle
#

@earnest phoenix thats not how you catch the error

pale vessel
#

.catch is for asynchronous functions only

quartz kindle
#

and thats not how you dm people

pale vessel
#

you would need catch(error) { }

#

wait

#

no

digital ibex
#
try {
smthing 
} catch (error) {
smthing
}
#

like that

pale vessel
#

well yes

quartz kindle
#

^ only works if you await

pale vessel
#

on his case it would be after message.channel.send => message.channel.send("ok boomer").catch(e => { });

earnest phoenix
#

Hi?

digital ibex
#

and do message a person its just <member>.send

earnest phoenix
#

What can i use alternative of superagent? Any1?

slate oyster
#

@flat pelican
Since you were the moderating user on the other person's bot
I wanted to ask you
So my bot has a giphy command too.
I'm using a library, and I'm not 100% certain if it is using the filter option, but I believe it is
So to test I had tested it with multiple sensitive (aka nsfw) searches
And it consistently produced Safe content
So I was wondering if that would pass probably?

earnest phoenix
slender thistle
#

DMs preferably

digital ibex
#

sigh

pale vessel
#

no.

#

that is not how you do it

flat pelican
#

well it sent content that I judge that are not safe for public channels - you can DM me for more information

pale vessel
#

and what is dm?

#

yes

digital ibex
#

i-

flat pelican
#

Direct Message

digital ibex
#

ok

pale vessel
#

me too when i was a beginner

quartz kindle
#

@earnest phoenix there are many alternatives, such as node-fetch, axios, got, bent

digital ibex
#

w-

pale vessel
#

oh

#

it's not what we think

summer torrent
#

axios is best

pale vessel
#

that ain't dm

digital ibex
#

just catch the error

pale vessel
#

use .catch after message.member.send

quartz kindle
#

http is best

digital ibex
#

and send it

pale vessel
#

also, make sure that it tells you who the recipient is

#

otherwise it could be used maliciously

zenith terrace
#
if (target.highestRole.position > member.highestRole.position)```

So I did it this way since I have defined target and member. 
`TypeError: Cannot read property 'position' of undefined`
pale vessel
#

roles.highestRole

zenith terrace
#

oo

slate oyster
#

@flat pelican ok. I'll dm you. I'm probebly using a different lib then the other person, so mine might apply the filter flags while their's does not

pale vessel
#

wait no

#

member.highestRole.position should work

earnest phoenix
#

@quartz kindle so which is best?

pale vessel
#

any of them would do

#

omg

#

what did you do

zenith terrace
#

member.highestRole.position should work
@pale vessel Nope it didnt

pale vessel
zenith terrace
#

Ok

quartz kindle
#

@earnest phoenix there is no best, check their npm/github pages and see which one you like more

digital ibex
#
if(dm) {
    member.send(dm);
    message.channel.send(':white_check_mark: **DM sent** :e_mail:')
} else {
message.channel.send('error')
}
#

lmk if there are any errors @earnest phoenix

#

probably is

#

wait

#

ok

pale vessel
#

that code is just...

digital ibex
#

yah

pale vessel
#

i'm still wondering how it worked

summer torrent
earnest phoenix
#

@summer torrent nevermind, im now using "got".

summer torrent
#

axios blobOKHand

earnest phoenix
#

why this dont work?

package Juego;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;

import javax.swing.JFrame;

public class Juego extends Canvas {

    private static final long serialVersionUID = 1L;

    private static final int ANCHO = 800;
    private static final int ALTO = 600;
    private static final String NOMBRE = "Juego";
    private static JFrame ventana;

    private Juego() {

        setPreferredSize(new Dimension(ANCHO, ALTO));

        ventana = new JFrame(NOMBRE);
        ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ventana.setResizable(false);
        ventana.setLayout(new BorderLayout());
        ventana.add(this, BorderLayout.CENTER);
        ventana.pack();
        ventana.setLocationRelativeTo(null);
        ventana.setVisible(true);

    }

    public static void main(String[] args) {

    }
}
digital ibex
#

flazepe i edited it to how i would've doneit

earnest phoenix
#

java

#

;u

zenith terrace
#

Thats not even for a bot...

pale vessel
#

i would do```js
if (dm) {
member.send(dm).catch(e => { return message.channel.send('error'); });
message.channel.send(':white_check_mark: DM sent :e_mail:');
} else { whatever }

tight plinth
#

useless request : how to make a bot online but with mobile indicator

pale vessel
#

not possible

tight plinth
#

I mean like this

zenith terrace
#

oof

tight plinth
#

Presence#clientStatus

The new presence.clientStatus property returns an object with three keys: web, mobile and desktop; their values are a PresenceStatus string. This property allows you to check which client the member or user is using to access Discord.

finite bough
#

can someone give me some idea how i can set up a log of channelUpdate event

tight plinth
#

hm

#

@finite bough client.on('channelupdate', (channel) => {
guild = channel.guild
...
});

finite bough
#

i mean i have to check every thing which can be updated seperately

zenith terrace
#

✅ | Congratulations Lumap!. You have reached level 1

(Please dont ban me I promise am not a self bot)

#

😂

tight plinth
#

nani

finite bough
#

no

#

like

pale vessel
#

like?

finite bough
#

i have to compare every value?

pale vessel
#

yes

finite bough
#

between the old channel and new channel

pale vessel
#

yes

finite bough
#

ok thats gonna take some time to make

pale vessel
#

addfield if it has a difference

#

ezx

tight plinth
#
client.user.presence.clientStatus = 'mobile'``` dont work
earnest phoenix
#

why do people keep doing that shit

#

whenever you want to change something on discord

#

you have to use a method

#

because you need to make a request

twilit rapids
#

You can't just change the variable like that lol

tight plinth
#

I mean, the only time I see this documented online is on the "upgrading from v11 to v12" guide from discordjs

modest maple
#

because you're not rlly ment to be on mobile for bots

earnest phoenix
#

it doesn't matter

modest maple
#

discord just dont rlly care if you trick the api

pale vessel
#

i even sent what cry said

finite bough
#

i mean it looks cool

pale vessel
#

so

earnest phoenix
#

i'm pretty sure you can't have a mobile indicator with d.js

pale vessel
#

nope

earnest phoenix
#

it is possible for bots to have it though

late hill
#

technically, within js, code like that is possible

pale vessel
#

dad bot is eris

late hill
#

using the js setters

twilit rapids
#

It is

earnest phoenix
#

it is possible, it won't work

twilit rapids
#

But it's not documented

earnest phoenix
#

you need to make a request to update your presence

#

which, simply setting a variable to a value, doesn't do

late hill
#

yes

#

a setter in javascript is a function that'll be executed when simply changing the variable

cinder patio
#

or just like edit the d.js library to include that in the socket handshake

late hill
#

so behind the scenes that could totally work

#

it wouldn't make sense, and it's not the way it is

twilit rapids
#

What?

earnest phoenix
#

huh?

tight plinth
#

what

#

they can

earnest phoenix
#

tfw you try to sound smart but you end up looking dumb

twilit rapids
#

Let's keep it a little more friendlier here @earnest phoenix

modest maple
golden condor
#

Can anyone help me with updating to v12?

pale vessel
#

haha it was a pain innit

golden condor
#

Yes

pale vessel
#

bet you reverted back

golden condor
#

It was so hard

#

Then it didn't even work

#

k

cinder patio
#

The .addField to .addFields change made be go crazy 😳

tight plinth
#

.addField still works

zenith terrace
#

I still use .addField

pale vessel
#

same

golden condor
#

But now I got nothing better to do in lockdown7

#

So

tight plinth
#

I use .addFields coz y not

#

maybe one day they will remove .addField

pale vessel
#

just like how they removed overwritePermissions

cinder patio
#

it does? I used v12 before they made it stable and there was only addFields 😦

pale vessel
#

nah

golden condor
#

That's master

#

Thimhs

#

Things change

#

I could do with some help going to v12

earnest phoenix
#

i mean it's major versioning for a reason

quartz kindle
#

they removed addField then they added it back again

pale vessel
#

devs in dilemma

golden condor
#

Oops

restive furnace
#

i have old master, the master what was before stable v12

golden condor
#

Does anyone have time to help me with the move with any chance?

outer niche
#
    class crona(commands.Cog):
NameError: name 'commands' is not defined``` ```from discord.ext import commands
import discord

class crona(commands.Cog):
    
    def __init__(self, bot):
        self.bot = bot

    @command.command()
    async def donkey1(self, ctx):
        await ctx.send("https://imgur.com/MAz9bXR")

def setup(bot: commands.Bot) -> None:
    bot.add_cog(crona(bot))```
golden condor
#

crona

coarse vapor
#

is it against the rules to make the ads smaller rather than allowing them to take up half of the screen?

modest maple
#

yes

#

you CANNOT touch the Ads css etc...

#

@outer niche that is not how that works

slender thistle
#

@command.command()
👀

coarse vapor
#

so if the ads take up half of the screen i cannot make them smaller at all

modest maple
#

@slender thistle thats what u notice?

slender thistle
#

I got fairly rusty at discord.py after going through my fucking online learning, give me a break 🤣

earnest phoenix
#

thats why i dont put my bots on dbl, priz

#

lmao

outer niche
#

So what do I need to do to fix it

#

I know I fixed it

#

But how do I fix my issue though

restive furnace
#

command.command() look you rdifferent files

outer niche
#

It's commands.command () I know I fixed it

sterile minnow
earnest phoenix
#

have you tried debugging your code

sterile minnow
#

I tried everything

#

no error, no output nothin

earnest phoenix
#

have you tried debugging your code

sterile minnow
#

I tried everything
@sterile minnow .

earnest phoenix
#

if you had debugged your code, you would've found where the issue relied

#

so no, you haven't, proceed to doing so

sterile minnow
#

I tried EVERYTHING

#

Nothing

earnest phoenix
#

debugging includes logging your checks, logging your blocks, logging where the code hits and inspecting your variables

pale vessel
#

obviously you haven't, you'd fine the issue otherwise

earnest phoenix
#

which i'm guessing, you did none of that

sterile minnow
#

I TRIED IT!

#

But none of that gave me sth

earnest phoenix
#

How many ways do we have to tell you to debug

#

if you're going to keep on lying about doing it when you don't want to do it, you don't have to be in this channel

sterile minnow
#

I TRIED THE FUCK

#

Man

copper cradle
#

you're not getting an user bc args [0] is just this <@id> you gotta fetch an user using that

#

there

earnest phoenix
#

...which would mean you hadn't inspected your variables at all

#

🙄

uneven wyvern
#

how can i make something like a file handler in js?

restive furnace
#

fs is your answer

uneven wyvern
#

well idk how

restive furnace
#

its basic js.

#

fs.readDir smh

uneven wyvern
#

i havnt coded in js for 2 months.

restive furnace
#

try google?

uneven wyvern
#

i dont find something regarding to this there

restive furnace
#

"node.js filehandler"

#

cause if you search js, most of the results are for angular js.

sudden geyser
#

Search on Google, "Node.js fs module"

pale vessel
#

it's built-in too

#

which is cool

mental furnace
#

(Idk wich channel is most fitting for this)
@tulip wave
Can I ask if my bot has been kicked from this server? Because it’s not here and (afaik) this is the case of him not showing if it’s online or offline on the website. (Also please say wich channel is the most fitting for these questions)

pale vessel
#

#general and you can try pinging the bot and we'll see if it has been kicked or not

earnest phoenix
#

guildKickAdd is avaible in v11? Any1 ??

mental furnace
#

Well it’s not here

#

That’s why

sudden geyser
#

Take your bot's user ID and try searching it in #mod-logs

mental furnace
#

@cinder valveggestON

#

Oops

#

Didn’t see anyone with that name

#

Sorry

earnest phoenix
#

"Do not @mention people randomly."

sudden geyser
#

They were trying to mention their bot.

mental furnace
#

Look I wasn’t trying to

#

Yes

earnest phoenix
#

I just kidding....

mental furnace
#

Thank you

#

Anyway

#

It’s gone so.... if it has been kicked I would like to know why cause it followed all rules

pale vessel
#

what's your bot id?

mental furnace
#

Gimme 5 sec

pale vessel
#

no guildkick

mental furnace
#

676849305646268417

zenith terrace
#

@candid nova

#

Not here

mental furnace
#

Ik

#

So it didn’t send join messages and the only direct message is if your suggestion gets accepted and you didn’t turn it off

zenith terrace
#

theres no mod-log of it 🤔

sudden geyser
#

DM a mod about your bot.

mental furnace
#

Also it shouldn’t even send anything as it’s not configured on this server

#

.....

#

I mean

#

I could ping him again

#

But that doesn’t seem helpful

pale vessel
#

Eri, help

zenith terrace
#

@flat pelican

mental furnace
#

I mean, idk why but this dc server did spam my logs so I disabled the bot for this server... but that shouldn’t have been the reason to kick the bot right?

flat pelican
#

?

mental furnace
#

Oh hi

#

Please read from there

#

Then you’ll understand

solar kraken
#

this is the code for the reposting
help?

pale vessel
#

because image files don't have content

#

make if (!reaction.message.content) return

flat pelican
mental furnace
#

Ok

flat pelican
#

This channel is only for code/dev talking

earnest phoenix
#
const entry1 = entry.executor
console.log(entry1.id)```

Why this isnt working?
summer torrent
#

any error?

earnest phoenix
#

id of undefined

#

:/

solar kraken
#

@pale vessel it gives me an error because of the "if"

sudden geyser
#

Kyoya entry is a promise.

#

You need to await it.

pale vessel
#

.then ?

earnest phoenix
#

oh, i will try.

pale vessel
#

ah

#

@solar kraken full error?

solar kraken
#

title: if (!reaction.message.content) return,
^^

SyntaxError: Unexpected token if
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3

pale vessel
#

oh.

mossy vine
#

oh boy

quartz kindle
#

you cant use an if like that lol

pale vessel
#

thank you tim for handling that pain

solar kraken
#

im still learning js

pale vessel
#

it's okay, we understand

solar kraken
#

so how do i type it?

earnest phoenix
#

@sudden geyser Thanks its worked :D

pale vessel
#

before channel.send, i guess

quartz kindle
#

if you want to do a conditional operation when assigning, for example title: if something, assign something, else assign something else you can use a ternary operator

#

like this: title: condition ? value1 : value2

pale vessel
#

<condition> ? <if true> : <if false>

#

sometimes you need to cover it with brackets

#

depends on the situation

quartz kindle
#

otherwise if you want to do an if(something) return then you should do it somewhere else, not during value assignment

solar kraken
#

alright it works, but it isnt sending anything when an image is trying to be reposted

pale vessel
#

how did you detect same image?

solar kraken
#

no i meant pinned*

quartz kindle
#

images and embeds are not part of a message content

finite bough
#

tim

solar kraken
#

how do i return the image then

quartz kindle
#

images are found in message.attachments

finite bough
#

in channelUpdate event(11v) do i have to compare all the stuff between old channel and new channel

quartz kindle
#

and embeds are found in message.embeds

#

to repost images, you need to put the original attachment in a files option, outside of the embed

#

to put an attached file in an embed, you use a special attachment:// url

solar kraken
#

how do i find the url of the image sent

#

i can only get the message content

#

and the message link

quartz kindle
#

message.attachments

#

it holds a collection of attachments, each with url and data

#

@finite bough yes

finite bough
#

can u tell me an easy way to do so

quartz kindle
#

what do you want to compare?

finite bough
#

everything

#

between the old channel and new channel

pale vessel
#

you could probably make a function to do it for you

finite bough
#
client.on('channelUpdate', (oldchannel, newchannel) =>{ 
  prefixes.findOne({
    serverID: newchannel.guild.id
  
  }, (err, res) => {
    if(err) console.log(err);
    
    if(!res.logchannel){
      return console.log('no log channel')
    } else {
      
      if(oldchannel.name !== newchannel.name){
        
        let embed = new Discord.RichEmbed()
    .setTitle("**A channel has been updated**")
    .setColor("#fc3c3c")
    .addField('***channel.id***')    
    .addField('old channel Name', oldchannel.name, true)
    .addField('new channel Name', newchannel.name, true)
        
        newchannel.guild.channels.get(res.logchannel).send(embed)
      } else 
      
      
      
      
    }
});
});
#

my progress

#

lel

pale vessel
#

make an embed first and then if a condition is true, add a field with corresponding information (like old and new name if they're different)

quartz kindle
#

i mean, there isnt much that can change about a channel, you only need title, description, position... what else? permission overwrites? parent category?

pale vessel
#

that would be overkill

#

nsfw too

finite bough
#

hmm

pale vessel
#

but i guess that's it

finite bough
#

i can try fletching them from audit

earnest phoenix
#

How can i learn a kick reason?? is that possible?

pale vessel
#

audit logs

finite bough
#

aufit

pale vessel
#

yes

earnest phoenix
#

i just getting tag and id

#

idk how to get reason

#

or just entry1.reason :D

pale vessel
#

just console log entry and see

#

and it depends if the user provided a reason or not

finite bough
#

wait how do u fetch that

earnest phoenix
#

i cant see any reason

#

just user shows infos

#

its not showing reason.

#

i specified a reason but same....

#

Ok, i fixed....

#

How To make in one embed addfield if a condition is true ???

pale vessel
#

embed.addField()

earnest phoenix
#

Ooooh

#

Ty

pale vessel
#

embed is the embed object

earnest phoenix
#

Yeah

#

This is a good way

#

Ty

finite bough
#

[object object]

earnest phoenix
#

Oof

#

Good luck...weirdsip

restive furnace
#

simple fix: use debug mode or toArray(); ez

earnest phoenix
#

Ez for every good programmer

#

But not for me personnaly

finite bough
#

ok i give up on trying

#
client.on('channelUpdate', (oldchannel, newchannel) =>{ 
  prefixes.findOne({
    serverID: newchannel.guild.id
  
  }, async (err, res) => {
    if(err) console.log(err);
    
    
   const GuildAuditLogsEntry = {
  targetType: 'CHANNEL',
  actionType: 'UPDATE',
  action: 'CHANNEL_UPDATE',
  reason: null,
  executor: [Object],
  changes: [Object],
  id: oldchannel.id,
  extra: [Object],
  target: [Object] 
   }
   
   const entry = await oldchannel.guild.fetchAuditLogs({type: 'CHANNEL_UPDATE'}).then(audit => audit.entries.first())
   
   
   
  
    if(!res.logchannel){
      return console.log('no log channel')
    } else {
      
      if(oldchannel.name !== newchannel.name){
        
        let embed = new Discord.RichEmbed()
    .setTitle("**A channel has been updated**")
    .setColor("#fc3c3c")
    .addField('***channel.id***')    
    .addField('old channel Name', oldchannel.name, true)
    .addField('new channel Name', newchannel.name, true)
        
        newchannel.guild.channels.get(res.logchannel).send(embed)
      } else  newchannel.guild.channels.get(res.logchannel).send(entry.changes)
      
      
    }
});
});
pale vessel
#

ouch

#

nice pile of code

finite bough
#

pile of shit xD

pale vessel
#

haha

#

do you need help?

finite bough
#

yes

earnest phoenix
#

The const GuildAuditLogsEntry isn't needed

#

And after ur else u've been Forget }

#

{*

finite bough
#

wdym

sudden geyser
#

The {} is optional for single-line code. <GuildAuditLogsEntry>.entry is an array of changes (Array<AuditLogChange>). The docs point it out: https://discord.js.org/#/docs/main/stable/typedef/AuditLogChange

What exactly do you give up on trying.

finite bough
#

OH

#

THAT MAKES IT SO MUCH EASIER!

zenith terrace
#

If a server has over 1K members, which makes offline people hidden. Can bots still detect them or not

quartz kindle
#

the default "large" threshold is 250 members

#

meaning guilds with more than 250 members will not have their entire member list cached

#

it will only cache online/active users

#

in order to get offline/uncached users, you need to fetch them

#

@earnest phoenix stop please

zenith terrace
#

Someone sent a link

#

O

quartz kindle
#

banned lol

zenith terrace
#

Nice

#

Anyway, back to the code

#

So

#

Yea I was wondering cause I keep seeing the users logged on my botinto command go up n down and was curious

#

@quartz kindle also Tim. Im wondering if you know the reason of this

if (target.highestRole.position > member.highestRole.position)```

So I did it this way since I have defined target and member. 
`TypeError: Cannot read property 'position' of undefined`
quartz kindle
#

what is target?

zenith terrace
#

let target = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));

#

The user

#

Want me to resend what this is about?

digital ibex
#

hi

zenith terrace
#

👀

digital ibex
#

how would i define something with a type?

#

js

#

i've tried googling it but im a bit confused, i need to use a class or smthing which im not good at

quartz kindle
#

@zenith terrace well, you dont need to do that, you can simply do target = message.mentions.members.first() || message.guild.members.get(args[0])

#

but that isnt the cause of the issue

#

did you log both target and member?

zenith terrace
#

Log as in?

#

@quartz kindle

quartz kindle
#

console.log

zenith terrace
#

O that log. Uh no

snow urchin
#

So I noticed one of my bots was not working properly, so I logged "client" on ready event, and it is missing, MANY things, even client.user is null

zenith terrace
#

v12?

snow urchin
#

11.6.2

shy rose
#

anyone know a plugin (or eslint) extension in vscode to catch things like

new Promise((resolve)=>{
if(something){
resolve("done")
}else{
//oops i forogt
}
})
subtle river
#

Hi I think I accidentally changed my account into a bot. could someone help?

zenith terrace
#

We cant really help you with that <_<

subtle river
#

could someone change it back?

modest maple
#

erm no?

zenith terrace
#

We. Cant. Do. That

subtle river
#

cries

zenith terrace
#

CF8prefix

earnest phoenix
#

Wtf

#

selfbot?

#

'-'

modest maple
#

@zenith terrace pong!
API Latency: 50000ms
Heart Beat: 100ms

#

tl:dr not a self bot

earnest phoenix
#

A snowflake is a string right?

zenith terrace
#

I think the devs got the command wrong. I said prefix instead of ping +_+

#

Butt jeez that ping

#

<_<

#

Butt

#

xD

astral yoke
#

I'm trying to make a new bot that checks my main bots presence, and if it comes offline, it's supposed to dm me.

#

However, a few minutes after starting it, I get this error.

#
    at Timeout._onTimeout (C:\Users\Cools\statusbot\src\index.js:22:16)
    at listOnTimeout (internal/timers.js:536:17)
    at processTimers (internal/timers.js:480:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fyre@1.0.0 start: `node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fyre@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Cools\AppData\Roaming\npm-cache\_logs\2020-03-25T22_39_02_089Z-debug.log

C:\Users\Cools\statusbot>```
#

Code:

#
const logger = require("../utils/logger"); //better console logging
const { Client, Collection } = require("discord.js");
const bot = new Client(); //creates the Discord Client
const data = require("./loaders/reader"); //this returns data user entered in botconfig file
const Discord = require('discord.js');
const client = new Discord.Client();



["aliases", "commands"].forEach(x => bot[x] = new Collection()); //bot.aliases, bot.commands = Discord Collections
["console", "command", "event"].forEach(x => require(`../handlers/${x}`)(bot)); //run all of these files with param bot

logger.log("Successfully loaded other files.");
bot.login(data.token); //login with the bot token defined in botconfig file


const owner = client.users.get("279116778246766593"); // Your user ID
const dogbot = client.users.get("679211740202008596"); // Your bot's ID

setInterval(function(){
    if (dogbot.presence.status != "online") owner.send("DogBot has crashed or is offline."); // If DogBot is not online, send the owner this message
}, 60000); // Checks every minute```
#

how would I define it? It should already be due to it being associated with the stuff.

quartz kindle
#

@astral yoke your bot might not be cached, make sure the id is correct, and use fetch instead if its not cached

#

in v11 would be await client.users.fetchUser(id) but requires an async function

astral yoke
#

So sorta like this?

#
const dogbot = client.users.fetchUser(679211740202008596); // Your bot's ID```
#

?

summer torrent
#

await

astral yoke
#

how would I make an async function into that? @quartz kindle

rustic axle
#

I checked the Discord.js v11 to v12 guide and it doesn't mention anything related to this. I decided to update to v12.0.2 on one of my bots. In v11, my bot was working perfectly fine. Now, it seems as if the message event only fires once during the bot's lifetime. I verified the issue on a server of mine. I created another bot using the sample code provided and found the same issue, even on another computer. I tried this in different servers. It seems as if the issue is on v12. I am on Node.js runtime version v12. Is this an actual issue? Can anyone else replicate or observe it?

astral yoke
#

revert back to v11

#

i havent updated to v12 yet

rustic axle
#

Oh sorry I was talking about my issue

astral yoke
#

well, if you really think v12 is best for the error you didn't have in v11 then go with it

#

not my decision for sure

rustic axle
#

true but I still want to know as I will eventually have to upgrade to 12

#

and if it is an actual issue I want to actually put something on their repo about it

astral yoke
#

yeah

summer torrent
#

@astral yoke await client.fetchUser

astral yoke
#

So I should take out the users between that?

summer torrent
#

in v11 would be await client.users.fetchUser(id) but requires an async function
@quartz kindle client.users.fetchUser() LUL

astral yoke
#

Cause I have client.users.fetchUsers();

summer torrent
#

just type await for make it async function

astral yoke
#

Im confused

quartz kindle
#

i mixed up v12 and v11 lmao

astral yoke
#

how would i make it one tho? it's error is that it's only valid in async function

quartz kindle
#

v12 is client.users.fetch
v11 is client.fetchUser

earnest phoenix
#

make your function async

quartz kindle
#

@astral yoke you have two options

earnest phoenix
#

or use .then

quartz kindle
#

either make your timeout async, and fetch the user inside it

#

or fetch the user first and use .then()

astral yoke
#

So fetch the user,

quartz kindle
#

making your timeout async would be better

astral yoke
#

then put .then(),

#

then put my code?

#

the rest of the code*

quartz kindle
#
setTimeout(async () => {
  let user = await client.fetchUser(id);
  // continue
},60000)```
astral yoke
#

am I able two put to there?

#

like,

#
  let user = await client.fetchUser(id);
  let user = await client.fetchUser(id);
  // continue
},60000)```
earnest phoenix
#

yeah

#

but

astral yoke
#

wait

earnest phoenix
#

different variable names

astral yoke
#

i already have someone that tho

#

cause with the second part of the code

#

i have it there

#
    if (dogbot.presence.status != "online") owner.send("DogBot has crashed or is offline."); // If DogBot is not online, send the owner this message
}, 60000); // Checks every minute```
#

am I able to just put the setInterval(function(){ higher above the fetchUser?

quartz kindle
#

just put everything inside a single interval

#

the code i showed uses a timeout, but just change it to interval instead

#

i works the same

snow urchin
#
const
    express = require("express"),
    discord = require("discord.js"),
    bodyParser = require("body-parser"),
    nice_json = require("json-beautify"),
    chalk = require("chalk"),
    fetch = require("node-fetch"),
    pretty = require('express-prettify');
    cors = require("cors"),
    url = require("url"),
    db = require("quick.db"),
    app = express(),
    client = new discord.Client();
    require("dotenv").config();

// LOAD OF EXPRESS CODE

    client.on("ready", () => {
        console.log(client)
    })
    client.login(process.env.TOKEN);

D.js 11.6.3
When client is logged, client.user is null, and readyAt is also null, along with few others things

astral yoke
#

I have another error.

#
    at APIRequest.getAuth (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\APIRequest.js:33:11)
    at APIRequest.gen (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\APIRequest.js:39:54)
    at C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:59:20
    at new Promise (<anonymous>)
    at SequentialRequestHandler.execute (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:58:12)
    at SequentialRequestHandler.handle (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:125:10)
    at SequentialRequestHandler.push (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:48:10)
    at C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RESTManager.js:27:15
    at new Promise (<anonymous>)
    at RESTManager.push (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RESTManager.js:26:12)
(node:7072) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:7072) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
quartz kindle
#

you need to wait for the ready event

#

@snow urchin is that the console.log from your ready event?

snow urchin
#

yes

quartz kindle
#

you dont have any other console.log anywhere?

snow urchin
#

nop

quartz kindle
#

do you use client anywhere in your express code?

snow urchin
#

yup, but I tried removing all other code, except for wat you see above ^, still did not work

quartz kindle
#

weird

#

do you get any error? try catching the login function

#

client.login().catch(console.log)

snow urchin
#

-.-

quartz kindle
#

is that all your code?

snow urchin
#

that hastebin?

quartz kindle
#

the code you posted before

snow urchin
#

bit of a mess :/

quartz kindle
#

i have no idea why that would be happening, but the client you are logging is indeed a non-logged-in client

snow urchin
#

makes no sense :/

zenith terrace
#

@snow urchin any error?

snow urchin
#

I only get errors in the express code for things like client.users.get... etc

quartz kindle
#

you can try logging raw events

#
client.on("raw", r => console.log(r)) // this will massively flood your console lol```
snow urchin
#

i will have it go into a haste so my console dont be like HELLLOOO

astral yoke
#

Okay, So I cleared up everything. But how would you properly @ a role? I attempt to do @radiant compass but it dosen't actualy ping it. I also tried @Role name, and it dosen't work. What would I do to have the bot ping a role when I use a command?

quartz kindle
#

afaik role pings are like this <@&id>

astral yoke
#

So like,

#

Ahh

#

I see.

#

Thanks!

snow urchin
#

may take a bit to load :/

#

love how each guild is "unavailable"

zenith terrace
#

this one laggy hastebin

quartz kindle
#

how about js client.on("debug", console.log)

zenith terrace
#

its that laggy I can barely scroll

snow urchin
#
Authenticated using token TOKEN
The API is listening on port 3000
The API is listening on port 3001
Using gateway wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Connecting to wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Connected to gateway wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Identifying as a new session
[ws] [connection] Setting a heartbeat interval for 41250ms
[ws] [connection] Sending a heartbeat
READY 46771e61bda5af5c701e9d9f8949c24f
[ws] [connection] Heartbeat acknowledged, latency of 297ms
quartz kindle
#

these all look fine

#

how about this js setTimeout(() => { console.log(client.user) },10000)

astral yoke
#
    at load (C:\Users\Cools\statusbot\handlers\command.js:15:36)
    at C:\Users\Cools\statusbot\handlers\command.js:29:27
    at Array.forEach (<anonymous>)
    at C:\Users\Cools\statusbot\handlers\command.js:29:14
    at FSReqCallback.oncomplete (fs.js:152:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fyre@1.0.0 start: `node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fyre@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Cools\AppData\Roaming\npm-cache\_logs\2020-03-25T23_59_38_205Z-debug.log

C:\Users\Cools\statusbot>```
#

If you want a specific code shown in the bot, I'll show it.

#

I believe it's due to this one so I'm going to put it.

#
const { ownerid } = require("../../loaders/reader"); //get ownerid from botconfig file
const { RichEmbed } = require("discord.js"); 
const errors = require("../../../utils/errors.js"); //better errors
const usage = require("../../../utils/usage.js"); //better help-messages
const { prefix } = require("../../loaders/reader") //get prefix from botconfig
const { Client, Collection } = require("discord.js");
const bot = new Client();

bot.on("ready", () => {
  module.exports = {
    config: {
        name: "botstatus",
        aliases: ["status", "dogbotstatus"],
        usage: "sb!botstatus",
        description: "Put the status.",
    },
    run: async (bot, message, args) => {
        if (message.author.id !== ownerid) return;
        message.delete()
        if (message.author.id === ownerid) {
            let args = message.content.split(" ").slice(1).join(" ");
         let split = args.split("-");
         let url = args[2];
         const channel = member.guild.channels.find(channel => channel.name === "status");
        if(channel) channel.send("<@&692499448089280552>", {
               embed: {
                 color: 0xFFFF00,
                 author: {
                   name: message.author.username,
                   icon_url: message.author.avatarURL
                 },
                 title: ":information_source: :Dogbot: Bot Status",
                 description: split[0],
                 timestamp: new Date(),
                 footer: {
                   icon_url: message.author.avatarURL,
                   text: message.author.username
                 }
               }
           });
         }
       }
}
})```
snow urchin
#

null @quartz kindle

sudden geyser
#

@astral yoke is that perhaps one of your command files

#

are you making a new client

agile orchid
#

yes he is

#

module.exports

quartz kindle
#

that makes no sense

#

module.exports inside a listener

agile orchid
#

ye

#

why would you need an on ready event

#

in a seperate command file

snow urchin
#

@quartz kindle Any other ideas of what I could do, it is important that I get this fixed -.-

quartz kindle
#

no idea

#

try reinstalling discord.js

#

try testing a new file with only the basic discord.js code

#

then slowly add your code back in

snow urchin
#

omg, this whole time... it was a typo

quartz kindle
#

where? lol

snow urchin
#
const
    express = require("express"),
    discord = require("discord.js"),
    bodyParser = require("body-parser"),
    chalk = require("chalk"),
    fetch = require("node-fetch"),
    pretty = require('express-prettify');  // <<<<<<
    cors = require("cors"),
    url = require("url"),
    db = require("quick.db"),
    app = express(),
    client = new discord.Client();
amber fractal
#

ah yes

quartz kindle
#

oh lmao

snow urchin
#

very annoying HAH

copper cradle
#

sometimes cleaner looks make it harder to find those things

wide ridge
#

anyone know how to get rid of this permissions issue?

0|index  | 25-03 20:19:23.718:     at RequestHandler.execute (/root
/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
0|index  | 25-03 20:19:23.718:     at runMicrotasks (<anonymous>)
0|index  | 25-03 20:19:23.718:     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
0|index  | 25-03 20:19:23.718:   name: 'DiscordAPIError',
0|index  | 25-03 20:19:23.718:   message: 'Missing Permissions',
0|index  | 25-03 20:19:23.718:   method: 'post',
0|index  | 25-03 20:19:23.718:   path: '/channels/692488724008927333/messages',
0|index  | 25-03 20:19:23.718:   code: 50013,
0|index  | 25-03 20:19:23.718:   httpStatus: 403
0|index  | 25-03 20:19:23.718: }
#

I already do a check for send messages permissions, but for some reason it still keeps returning that

#
        client.users.cache.get(msg.author.id).send(`:no_entry_sign: [**Missing Permissions**]: I don\'t have the **Send Messages** permission!\n`);
        return;
    }```
quartz kindle
#

check for embed/image/links permissions

zenith terrace
#

I get the Missing Permissions thing as well

#

But I stopped caring about it

#

Lmao

wide ridge
#

check for embed/image/links permissions
@quartz kindle That did it. I didn't have the "ATTACH FILES" permissions. Thanks!

gaunt arrow
#

Ok

heavy anchor
#

How to make a command different for each server the bot is in for example !twitter sends A different link for each server?

slender mountain
#

what language / library are you using for your bot

#

@heavy anchor

heavy anchor
#

@anclint#9255 JavaScript and discord.js

#

Discord.js is the library from npm

slender mountain
#

you could make an object, something like:

let links = {
  "SERVER_ID", "LINK",
  "SERVER_ID", "LINK",
  ...
};

and then do

if (command == "twitter") {
  if (links[message.guild.id]) {
    message.channel.send(links[message.guild.id])
  }
}
heavy anchor
#

Thanks for your help and sorry for the dumb questions but would it be harder to make it so the server can program the command themselves and I don’t have to do it?

blissful scaffold
#

You would need a database to do that

heavy anchor
#

Okay is there like A video tutorial you recommend?

blissful scaffold
#

im not a JS dev so I can't really help you with any details

heavy anchor
#

I’ve done a lot of HTML/CSS and not much JavaScript

grizzled raven
#

can your bot use an emoji from another shard?

summer torrent
#

yes

earnest phoenix
slender thistle
#

They're strings most of the time to support languages like JavaScript etc that don't exactly work well with integers like snowflakes

earnest phoenix
#

how about for user property in the vote event of the webhook?

slender thistle
#

Try outputting it somewhere and see if it's actually accessing it properly

#

I don't speak d.js

earnest phoenix
#

alr thx

grizzled raven
#

do you speak dblapi.js though?

prime cliff
#

I speak typescript

willow sparrow
#

Is there a way in discord.js that I can make it so only I can run a certain command in any server but the server staff can’t?

earnest phoenix
willow sparrow
#

Thanks!

#

It did I keep getting error

#

S

copper cradle
#

what's the error

#

we're not fucking wizards to know everything

#

ffs

valid frigate
#

i'm still kinda new to c++ but can anyone tell me the best use case for std::int_fast16_t?

#

been readin docs and i am confusion

copper cradle
#
std::cout << "silence peruvian" << std::endln;
restive furnace
#

i'm still kinda new to c++ but can anyone tell me the best use case for std::int_fast16_t?
probably int that is written and read faster than just normal std::int_16_t

astral yoke
#

Hello.

#

Trying to make a seperate status bot where I can announce the status of my main bot for when I restart it or something like that.

#

I have this announcement command.

#
const errors = require("../../../utils/errors.js"); //better errors
const usage = require("../../../utils/usage.js"); //better help-messages
const { prefix } = require("../../loaders/reader") //get prefix from botconfig

module.exports = {
    config: {
        name: "status",
        usage: "db!status",
        description: "Announce about the status of DogBot."
    },
    run: async (bot, message, args) => {
        message.delete()
        if (message.member.hasPermission("ADMINISTRATOR")) {
            let args = message.content.split(" ").slice(1).join(" ");
         let split = args.split("-");
         let url = args[2];
             message.channel.send("<@&692499448089280552>", {
               embed: {
                 color: 0xFFFF00,
                 author: {
                   name: message.author.username,
                   icon_url: message.author.avatarURL
                 },
                 title: ":information_source: Announcement",
                 description: split[0],
                 timestamp: new Date(),
                 footer: {
                   icon_url: message.author.avatarURL,
                   text: message.author.username
                 }
               }
           });
         }
       }
}```
#

How would I make it so it would find a channel, named "bot-status", then send it?

#

I've tried something but I got an error so I removed it.

restive furnace
#

guild#channels#cache.find

astral yoke
#

Then?

restive furnace
#

the function can be c => c.name === "bot-status"

pale vessel
#

then use .send

astral yoke
#

Okay okay

pale vessel
#

by the way, it's guild#channels.find

#

since you're on v11

restive furnace
#

didn't notice that :v

wheat jolt
#

how

valid frigate
#

how what

wheat jolt
#

why it's -1

#

indexOf works fine

pale vessel
#

then use that?

wheat jolt
#

i need the last index

#

not the first one

#

nvm

reef edge
spice pier
reef edge
#

isn't this?

scenic kelp
#

that's an awful lot of dependencies

pale vessel
#

why do you still have that

#

why do you have eris

#

you're using discord.js

opaque kite
#

xd

reef edge
#

I used to do it now I had the opportunity to look

#

I couldn't make this mistake

restive furnace
#

npm i

pale vessel
#

npm i am so sorry for what this guy have done

reef edge
#

can it heal

#

@pale vessel

pale vessel
#

vague

reef edge
#

ok thankyou

neat gazelle
#
    at IncomingMessage.<anonymous> (C:\Users\solan\Desktop\bots\cad bot\node_modules\dblapi.js\src\index.js:118:25)
    at IncomingMessage.emit (events.js:228:7)
    at endReadableNT (_stream_readable.js:1185:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:16992) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16992) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
``` can someone help me with this?
#

with the discord bot list api

spice pier
#

if you could show where the code where the error is happening it would help ngl

neat gazelle
#
const DBL = require("dblapi.js");
const dbl = new DBL('token', bot);

dbl.on('posted', () => {
    console.log('Server count posted!');
  });
  
bot.on('ready', () => {
    setInterval(() => {
        dbl.postStats(bot.guilds.size);
    }, 3600000);
});
#

i updated to the new discord.js v 12 and this happens

pale vessel
summer torrent
#

why do you have eris
@pale vessel because her bot is copycat

edgy heron
#

hlw

#

how to get number of total members

#

${bot.users.size} ?

#

javascript

twilit rapids
#

That returns the amount cached users on v11 yes

earnest phoenix
#

anyone d.py online? or just python in general?

twilit rapids
#

Just ask your question and if people can help they will

earnest phoenix
#

eh tru

#
async def ping(url: str):
    ping_var = "-n" if platform.system() == "Windows" else "-c"
    try:
        proc = await asyncio.create_subprocess_shell(
            f"ping {url} {ping_var} 1",
            stdout=asyncio.subprocess.PIPE,
            stderr=asyncio.subprocess.PIPE
        )
        stdout, stderr = await proc.communicate()
        print(stdout.decode())
        print(stderr.decode())
        s = stdout.decode()
        try:
            #s = str(subprocess.check_output(["ping", url, "-c", "2"]), "utf-8")
            if platform.system() != "Windows":
                ar = s.strip("\n\r").split("\r\n")[-1].split(" ")[-2].split("/")
                return f"{ar[0]} ms", f"{ar[2]} ms"
            else:
            #s = str(subprocess.check_output(["ping", url, "-n", "2"]), "utf-8")
                ar = s.strip("\n\r").split("\r\n")[-1].split(" ")
                return ar[-7].strip(","), ar[-4].strip(",")
        except Exception as e:
            print(e)
    except Exception as e:
        print(e)
        return "ERR", "ERR"
#

this

#

doesnt work

#

no output

#

it was working fine before i added the asyncio but it was blocking so no bueno

#
    @commands.command()
    async def lolping(self, ctx: discord.ext.commands.Context):
        embed = discord.Embed()
        lol_ips = {
            "North America (NA)": "104.160.131.3",
            "Europe (EUW)": "104.160.141.3",
            "Europe (EUNE)": "104.160.142.3",
            "Australia (OCE)": "104.160.156.1",
            "Latin America (LAN)": "104.160.136.3"
        }
        m: discord.Message = await ctx.send("Pinging...")
        c = 1
        embed.description = "Note: These pings are from Canada, yours may vary"
        for i in lol_ips.keys():
            p = await ping(lol_ips[i])
            embed.add_field(
                name=i,
                value=f"{p[0]}, {p[1]}",
                inline=False
            )
            await m.edit(content=f"Pinging {c} of 5...", embed=embed)
            c += 1
        await m.edit(content="", embed=embed)
#

and there's how it's used

edgy heron
#

@twilit rapids but it says undefined in statuse

#

bot.users.size

#

allso i am full new with js

twilit rapids
#

What version of d.js are you using

edgy heron
#

^12.0.2

twilit rapids
#

If you're on v12, use bot.users.cache.size

edgy heron
#

thanks

pallid vector
#

is making a db call every time something occurs (e.g. .daily gives you economy) super inefficient after?

#

it is recommended to store it in a cache and then update db every once in awhile

slender thistle
#

If your bot is big I'd suggest going with the latter

pallid vector
#

how big is considered big to do that

blissful scaffold
#

It depends

pallid vector
#

the thing I'm worried abt is the bot sometimes cutting off, and it wouldn't update the db

#

if it's just in the cache

earnest phoenix
#

i mean update every min or so

pallid vector
#

I also have to check if the user updated it's info don't I?

#

its

#

since I don't want to update every single user every minute

earnest phoenix
#

true

dusky marsh
#

You can do a combination of both, prioritize certain queries, and run cached updates in a seperate process or something

pallid vector
#

hm alright, ill c then

#

thanks for the inputs

edgy heron
#
bot.guilds.cache.forEach(guild => {
    message.channel.send(`${guild.name}`);
   
  message.channel.send(`Total ${bot.users.cache.size} members, Total ${bot.guilds.cache.size} Servers `)

  })
  
})```
pale vessel
#

don't leak it

zenith terrace
#

ok?

pale vessel
#

delete the screenshot

edgy heron
#

its sending that total mems, total servers message in every mssgh

#

i want that

#

it should send this total mssg once

#

not with all server names

pale vessel
#

guild.members.cache.size

edgy heron
#

u didnt get it

pale vessel
#

nope

edgy heron
#

message.channel.send(`Total ${bot.users.cache.size} members, Total ${bot.guilds.cache.size} Servers `)```
pale vessel
#

then put it outside forEach smh

edgy heron
#

i am new bruh

wooden bear
#

hey anyone can explain how can we get a list of users reacted on a particular message? [im using discord.py async :/ kinda outdated]

pale vessel
#

try upgrading

earnest phoenix
#

^

wooden bear
#

:c

modest maple
#

update yh

#

async is fucking miles out of date

earnest phoenix
#

heyyyy you're a python peep

slender thistle
#

message.reactions? special_think

modest maple
#

@slender thistle Thats not async branch

earnest phoenix
#

and i'm pretty sure that's what you're looking for, but you're much better off updating

modest maple
#

I mean an easier way todo a ping command is to use run_in_executor() and the Python Ping module

#

or

#

use Sub process in the threadpool rather than a future cuz im pretty sure that might be whats fucking you

wooden bear
#

thanks, it helped!

earnest phoenix
#

how?

#

like - threads and stuff is all new to me

#
import asyncio

async def run(cmd):
    proc = await asyncio.create_subprocess_shell(
        cmd,
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE)

    stdout, stderr = await proc.communicate()

    print(f'[{cmd!r} exited with {proc.returncode}]')
    if stdout:
        print(f'[stdout]\n{stdout.decode()}')
    if stderr:
        print(f'[stderr]\n{stderr.decode()}')

asyncio.run(run('ls /zzz'))
#

and this is right from asyncio's docs

modest maple
#
import concurrent.futures

with concurrent.futures.Threadpoolexecutor() as pool:
  result = await loop.run_in_executor(pool, func, args1, arg2, etc...)
#

also im pretty sure you're pings will be invalid as it'll bounce of the DNS

earnest phoenix
#

wym? they used to give valid pings when they were blocking

modest maple
#

alot of times pinging stuff without any other cookies / headers will just mean it gets Pinged off a DNS but meh if it works it works ig

earnest phoenix
#

o

#

WAIT

#

*wait

#

you didnt mean pool instead of loop did you?

modest maple
#

if you mean did i forget to pass pool in the first param yes

#

but no loop is the event loop

earnest phoenix
#

so where do you get loop?

modest maple
#

easy way to get it if you havent got client / bot object is asyncio.get_event_loop()

earnest phoenix
#

what if we already have a bot

#

or does that not matter

modest maple
#

if you have the bot object getting passed just use bot.loop.run_in...

earnest phoenix
#

oh

#

dur

#

but i COULD use asyncio. right?

#

like - they're the same event loop?

modest maple
#

yh

earnest phoenix
#

oki

edgy heron
#
bot.on("guildCreate", guild => {
   guild.owner.send(`Thanks for adding me in ${guild.name}! You can use .help to discover commands. here is our support server link: \n h  `);
const logChannel = bot.channels.resolve("692393527908368394")
logChannel.send(`Bot was added in ${guild.name}`);
});```
#

will it dm if the owner adds the bot?

#

i think yes

earnest phoenix
#
        with concurrent.futures.Threadpoolexecutor() as pool:
            result = await asyncio.get_event_loop().run_in_executor(pool, "ping", url, ping_var, "1")
        print(result)
``` prints nothing
modest maple
#

you didnt give it the function

#
import concurrent.futures

with concurrent.futures.Threadpoolexecutor() as pool:
  result = await loop.run_in_executor(pool, func, args1, arg2, etc...)```
earnest phoenix
#

OH

#

i read that as

#

yea

#

ok

edgy heron
#

and what if the owner dont add the bot? if his admins add it. still owner gets this dm?

earnest phoenix
#

so..what would i put for func?

modest maple
#

also remove it being async if you're running threadpool

earnest phoenix
#

oki

modest maple
#

just function_name

#

dont call it with ()

earnest phoenix
#

but then so i'd use the blocking subprocess creation?

#

as func?

modest maple
#

yes

earnest phoenix
#

oki

flat pelican
#

@edgy heron Please refrain posting invites eyeshake3

edgy heron
#

@flat pelican sorry, it was in my code

#

didnt want to do that

earnest phoenix
#

ok so

#
async def ping(url: str):
    ping_var = "-n" if platform.system() == "Windows" else "-c"
    def pshell(url: str):
        return str(subprocess.check_output(["ping", url, "-c", "2"]), "utf-8")
    try:
        with concurrent.futures.ThreadPoolExecutor as pool:
            s = await asyncio.get_event_loop().run_in_executor(pool, pshell, url)
        print(s)
        try:
            #s = str(subprocess.check_output(["ping", url, "-c", "2"]), "utf-8")
            if platform.system() != "Windows":
                ar = s.strip("\n\r").split("\r\n")[-1].split(" ")[-2].split("/")
                return f"{ar[0]} ms", f"{ar[2]} ms"
            else:
            #s = str(subprocess.check_output(["ping", url, "-n", "2"]), "utf-8")
                ar = s.strip("\n\r").split("\r\n")[-1].split(" ")
                return ar[-7].strip(","), ar[-4].strip(",")
        except Exception as e:
            print(e)
    except Exception as e:
        print(e)
        return "ERR", "ERR"
#

this is my code

#

and one of the excepts is printing __enter__

#

nvm

#

forgot the () on ThreadPoolExecutor

modest maple
#

oh xD

earnest phoenix
#

EYYYY

#

it works!

#

ty <3

modest maple
#

np

raven urchin
#

I need some help, on glitch there's an error. Can't seem to find it. Any way I can find it?

summer torrent
#

show error

earnest phoenix
#

i think a better question would be

#

what's happening

#

:p

#

anyone know how to upload a file in node js using the http module and formidable?
or can link me to an article?
i can't find any tutorials that aren't using express.js

raven urchin
#

@earnest phoenix every code is fine.

earnest phoenix
#

no

#

i mean

#

what is happening

#

that you say theres an error

#

why do you think there's an error

earnest phoenix
#

like.

raven urchin
#

It says it also can't find ("discord.js")

earnest phoenix
#

the full stack trace maybe?

#

did you to npm install discord.js?

#

and show full stack trace

raven urchin
#

Yes

earnest phoenix
#

show. the. entire. stack. trace. tho

raven urchin
#

How.

earnest phoenix
#

copy and paste?

#

no.

#

not your code

#

the stack trace

#

your error

#

also when you paste code

do this
raven urchin
#

The stack Trace is the logs right?

earnest phoenix
#

no. its the error you just showed me

slender thistle
#

Basically yes

raven urchin
#

It just basically says that it also can't find discord.js tho

charred jetty
#

Can't find module discord.js

earnest phoenix
#

why are so many people using glitch. on. mobile

charred jetty
#

XD

earnest phoenix
#

GAH

raven urchin
#

Mine can't either @charred jetty

charred jetty
#

@raven urchin ok

earnest phoenix
#

glitch bad mobile bad xD

charred jetty
#

It's Glitch problem

raven urchin
#

My bot has been down for a couple of days

charred jetty
#

It will be fixed automatically

#

@raven urchin oh

#

But mine just happened

earnest phoenix
#

honestly, if it's a glitch problem, then thats an instance of "you get what you pay for"

raven urchin
#

Mine Happened 3-4 days ago :/ idk if it's the code or glitch

#

Not everyone can afford a pc.

earnest phoenix
#

what does that have to do with glitch?

#

and try uninstalling and reinstalling djs?

quartz kindle
#

if you have issues with "cannot find X" on glitch, run enable-pnpm in the console

charred jetty
#

@quartz kindle how to run that

pale vessel
#

he literally said in the console

earnest phoenix
#

yup..

#

that'd be console

pale vessel
#

try running your bot again

zenith terrace
#

why on phone

earnest phoenix
#

thats what i asked.

zenith terrace
#

Oop

#

Glitch is the worst to use on phone, if you need to make one lil adjustment then sure, understandable..but a whole bot together

earnest phoenix
#

people are sometimes just morons

solemn quartz
#

Guys

#

If you need to warn someone..

#

What permissions should u have?

earnest phoenix
#

well

#

depends

solemn quartz
#

Im making a warn cmd rn

earnest phoenix
#

if you have autopunish

solemn quartz
#

Nope

earnest phoenix
#

ok

solemn quartz
#

lol

earnest phoenix
#

then maybe manage messages?

#

or kick?

solemn quartz
#

But

#

Like

#

If there's a trainee mod role in that server

earnest phoenix
#

manage messages is a perm about any staff would have

zenith terrace
#

manage messages would be best

#

for a warn

solemn quartz
#

okay

#

Ty guys

zenith terrace
#

Np

earnest phoenix
#

for warns i personally require manage messages yeah

#

i just know nadeko requires ban , cuz autopupnish

opaque kite
#

Is glitch secure ?

solemn quartz
#

Yea

#

Probably

zenith terrace
#

If you put your project on private then yes

solemn quartz
#

But probably VSC is the best (in my opinion)

earnest phoenix
opaque kite
#

Then who's better heroku vs glitch?