#development

1 messages ยท Page 821 of 1

modest maple
#

Badddd API spam

earnest phoenix
#

ws? (and btw this wont loop every second, just for testing rn)

modest maple
#

Web so ket

#

Socket*

earnest phoenix
#

o

modest maple
#

And that doesn't matter that will loop through each guild

earnest phoenix
#

tru

modest maple
#

Its a request to get the guilds

#

Then each guild another request

earnest phoenix
#

cuz i can use bot.guilds once i run await bot.fetch_guilds once right?

modest maple
#

That means hundreds if not thousands of calls

#

And I mean why don't you just use bot guilds anyway instead of fetching it

earnest phoenix
#

didnt realize it fetched automatically

#

but that doesnt explain the role being None

modest maple
#

It returns none if it can't find that role

#

Either the id it's getting isn't valid for that guild object

earnest phoenix
#

but its the valid id for the role tho?

modest maple
#

I say either but that's the only thing

earnest phoenix
#

im really confused

#

cuz

#
    @commands.command()
    @commands.check_any(
        commands.has_permissions(manage_roles=True, manage_guild=True),
        commands.is_owner(),
        commands.has_permissions(administrator=True)
    )
    async def setstreamrole(self, ctx: commands.Context, role: discord.Role):
        cfg: cogs.confighandler.ConfigHandler = self.bot.cfg
        cfg.data[ctx.guild.id]["streamer-role"] = role.id
        cfg.save()
        await ctx.send(embed=discord.Embed(title="Role set", description=f"Streamer role set to {role.mention}"))

    @commands.command()
    async def getstreamrole(self, ctx: commands.Context):
        cfg: cogs.confighandler.ConfigHandler = self.bot.cfg
        role = cfg.data[ctx.guild.id]["streamer-role"]
        await ctx.send(embed=discord.Embed(title="Role set", description=f"Streamer role is set to <@&{role}>"))
#

it sets (yaml data)[guild id]["streamer-role"] so i dont see why it wouldnt be valid

#

ok so

#

i put in a print g.roles and it gives nothing

#

but print await g.fetch_roles() works

#

so i'm assuming g.roles just isnt populating?

#

c o n f u s i o n

zenith terrace
#

ยฏ\_(ใƒ„)_/ยฏ

earnest phoenix
#

you said you dont know dpy.

#

im waiting on cf8 , or anyone else who does ;p

#

sighs the documentation leads me nowhere

grizzled raven
#

how do you know if your bot is like

#

uh

earnest phoenix
#

what.

grizzled raven
#

sigh

earnest phoenix
#

????

grizzled raven
#

nevermind

earnest phoenix
#

o..k

earnest phoenix
#

So I am currently getting this error:

So my bot's Shard isnt working? and how would I fix this, would I need to switch host if thats could be the issue?

abstract crow
#

is anyone here good with asp.net core

median ridge
#

Who else is experiencing an API shortage in discord.py?

regal saddle
#
m.clearReactions is not a function``` what should i use instead?
#

tag for answer

earnest phoenix
#

lib?

#

@regal saddle ?

#

does anyone else know dpy that can help xD

regal saddle
#

wdym?

#

tag for answer
๐Ÿ‘€

earnest phoenix
#

library

#

sighs

#

@regal saddle what. library. people cant help unless they know that

regal saddle
#

already fixed it by myself.

earnest phoenix
#

oki

regal saddle
#

its messageReactionRemoveAll

earnest phoenix
#

ye

regal saddle
#

๐Ÿ‘

earnest phoenix
#

see idk why they use that versioning scheme

regal saddle
#

they already work on v13

#

๐Ÿ‘€

earnest phoenix
#

okbut

#

like

#

i dont use djs ;p but i mean

#

v0.x.x was mostly backwards compatible

regal saddle
#

i learned py and js...

earnest phoenix
#

when the major breaking change happened, d.py made a v1.x.x

regal saddle
#

bruh moment

earnest phoenix
#

i mean im just saying djs versioning makes no sense

regal saddle
#

kinda yeah.

#

ill go sleep now, cya everyone

earnest phoenix
#

gn :3

sudden geyser
#

major.minor.patch

major - can break your code
minor - shouldn't, adds stuff.
patch - fixes a bug

earnest phoenix
#

yea but i doubt v10-v11 djs was breaking

#

and so on

#

no library has THAT many breaking changes

sudden geyser
#

I mean, discord.js can't make up their minds on what to name a method and how it does the same task (looking at you cache) so it probably does.

earnest phoenix
#

xD

copper cradle
#

lmao

#

so true

amber fractal
#

when you could message.guild.members.has() but now it's message.guild.members.cache.someOtherBullshit()

earnest phoenix
#

why bot is offline on dbm my bot is enabled on run script and mu bot is offline

#

And when I turn it on it is online short

lyric mountain
#

What

earnest phoenix
#

my offline bot, despite the fact that it is online when we use the command eg! work, it suddenly becomes offline

#

on dbm

#

can someone help me

copper cradle
#

d b m

#

yeah we don't do that here

earnest phoenix
#

solution: donโ€™t use dbm

lyric mountain
#

What's dbm?

copper cradle
#

discord bot maker ๐Ÿคฎ

lyric mountain
#

Ah

finite bough
#

@earnest phoenix check token

steel cloak
#

can you use svg images in an embed thumbnail? (ping me when you reply)

earnest phoenix
#

@steel cloak wait wdym by svg?

steel cloak
#

like the image format, at least i believe its an image format

earnest phoenix
#

Hmm lemme check that if it's possible real quick

#

@steel cloak which discord bot wrapper are you using?

steel cloak
#

JDA

earnest phoenix
#

Hmm... Sorry idk about that one... (I mean how's it's done...)

steel cloak
#

i mean i believe its all alike when it comes down to discord

earnest phoenix
#

But there's some noticable differences tho...
Have you checked some docs of that bot wrapper to check how is it possible or is it even possible?

steel cloak
#

it just mentions that .setThumbnail takes in a string in URL format lol
imma test more stuff and look around more. thanks for the help!

earnest phoenix
#

Np but you can set the thumbnail to the image you want with a link(just set the image as your pfp and use a bot that shows the URL of your avatar... Copy the link) and now paste it inside the .setThumbnail('URL')
If the svg format doesn't work... Change the image format to webp or png or jpng... That might work @steel cloak

steel cloak
#

oh yeah im aware of that. only thing is im using an API that returns images only in svg format and was just wondering if there was an easier way then having to convert them to png

earnest phoenix
#

You can convert the image format to anything you want with a online image format changer website or with a functional app...

#

This is a better and easier way

wide ruin
#

how do i stop this saying N/A servers?

digital ibex
#

hi

wide ruin
digital ibex
#

can someone help me make an eris command handler

cursive dagger
#

Use the library @wide ruin

true ravine
wide ruin
#

@true ravine

#

how long does it take to update?

restive furnace
#

0 secs

#

of u do it right

wide ruin
#

it still says na

restive furnace
#

then u dont do it right

wide ruin
#
class TopGG(commands.Cog):
    """Handles interactions with the top.gg API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = token[1] # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")

def setup(bot):
    bot.add_cog(TopGG(bot))```
restive furnace
#

did you put your api token and did you put that as your cog??

#

nope

#

make self.token = "ur api token on TOP.GG"

wide ruin
#

i did

#

line 1 is the actual token

#

line 2 is the dbl one

earnest phoenix
#

.....

#

Oh c

wide ruin
#

so what do i need to do

#

@restive furnace the code is open source

#

im not doing that

earnest phoenix
#

Did u define dbl?

wide ruin
#
import dbl

earnest phoenix
#

Ahh

#

BTW it takes about 3-5min for the results to be uploaded to the website

wide ruin
#

aah

#

thats probably why

#

0 secs

#

i mean it still hasnt updated

restive furnace
#

it doesnt

#

it depends on ur bot

#

maxium is like 2 mins

wide ruin
#

its been more than 2 mins

earnest phoenix
#

have you tried manually making a request to the api

#

via postman or curl or something

wide ruin
#

no

earnest phoenix
#

well try it

#
import discord
from discord.ext import commands


class TopGG(commands.Cog):
    """Handles interactions with the top.gg API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")

def setup(bot):
    bot.add_cog(TopGG(bot))```
#

Do as the examples says

#

Try that

#

Instead of putting token[1]

#

Put the actual token

wide ruin
#

@earnest phoenix i cant

#

youre not meant to share the dbl token

leaden gust
#

... so I'm looking into migrating to discord.js v12 but I'm confused about how to communicate between shards & master process:

earnest phoenix
#

Bruh @wide ruin

#

XD

wide ruin
#

what

earnest phoenix
#

In your code

wide ruin
#

yeah

earnest phoenix
#

Instead of token[1] directly put the token

wide ruin
#

but i cant share the token

earnest phoenix
#

........ But your not sharing the token

wide ruin
#

i would be

earnest phoenix
#

Oh dam

wide ruin
#

because its directly in main

earnest phoenix
#

I see

#

So ur putting it on github

#

Hmmnnn

wide ruin
#

yeah

#

atm token.txt is .gitignored

earnest phoenix
#

Did u mention the path to the token

wide ruin
#

the end says this

#
bot.run(token[0])```
#

so it does work

earnest phoenix
#

Hmmmm

#

What does the console say

wide ruin
#

nothing

#

unless this?

earnest phoenix
#

Hmmmm

wide ruin
#

idk if thats related

#

it just does that when i start the code

earnest phoenix
#

@tight plinth do u know how to fix that

tight plinth
#

fix what

#

ho

#

erm

#

idk

leaden gust
#

You're most likely not sending your token right

wide ruin
#

the bot is logging in

leaden gust
#

Try printing it before launching your client

#

Huh

wide ruin
#

oh

#

uuh

#

ok

#

people are playing games rn though

leaden gust
#

Ok if anyone has moved to discord.js v12 I seriously need some help understanding this. How the hell are you supposed to receive and respond to messages on a master process now?

They removed the message event from the manager and moved it to the Shard class, that's nice and all but the master process doesn't have a shard right? process.on('message') doesn't work and even if it did I still need to be able to reply to the specific shard who messaged me.

Except I know I should be able to do this because the ShardClientUtil class still has a send method that says "Sends a message to the master process.". Ok cool but how do I receive it? owoConfused

earnest phoenix
#

Ik 12v is so confusing

quartz kindle
#

try manager.on("message")

leaden gust
#

That's the old event

earnest phoenix
#

I am staying on 11v of now

leaden gust
#

it does not work now

quartz kindle
#

ah, it should be shard.on("message")

earnest phoenix
leaden gust
#

Yes but which shard?

#

My master process doesn't have a shard

#

It's a master process

quartz kindle
#

the shard returned by spawn

wide ruin
#

@earnest phoenix i printed the token list

quartz kindle
#

spawn returns a shard instance

leaden gust
#

Oh spawn returns a shard? wtf

#

I did not know this

wide ruin
#
['N.................._o', 'eyJ..................U']```
#

it works

leaden gust
#

And that shard acts as the master shard, is that right?

quartz kindle
#

spawn returns a collection of shards

#

createShard returns a shard

#

so each shard has its own message events

leaden gust
#

Wait ok, hang on a sec, i understand that but that's just to handle messages sent to shards

quartz kindle
#

also to receive

leaden gust
#

But how about the messages sent to the master process using ShardClientUtil.send ?

#

There's no shard to receive those

#

OH I got it

#

Ok so the shard.on message is a handler for the message sent by the shard

#

Sorry took me a while

quartz kindle
#
manager.spawn().then(shards => {
  shards.forEach(shard => {
    shard.on("message", message => {
      console.log(message)
    })
  })
})```
leaden gust
#

Yes I got you, my bad I totally misunderstood the meaning of that

#

I thought shard.on(message) would define what code would run on the shard upon receiving a message

#

But it's just moving the manager's handler to the shard object

earnest phoenix
#

@wide ruin try regenerating the dbl token

wide ruin
#

ok

leaden gust
#

That did it! Thanks @quartz kindle sorry for misunderstanding that change log really could have been more clear lol

#

v12 appears to be functional on my end yay

quartz kindle
#

๐Ÿ‘

stiff sedge
#

i found it nvm

slender thistle
#

CommandInvokeError

#

Doesn't sound familiar MeguDead

grizzled raven
#

@quartz kindle did you at some point write djs light in v11

#

like

#

nvm that doesnt make sense

#

im stupif

quartz kindle
#

nope

#

i tried looking into the v11 code, but a lot of it didnt make much sense

#

so i cba trying to find how its caching works

sudden geyser
#

eris gang

earnest phoenix
#

So I even switched host and changed some code but why am I still getting this error: "(node:9644) UnhandledPromiseRejectionWarning: Error: Shard 2's Client took too long to become ready."

quartz kindle
#

is your code trying to load something that takes a long time?

#

or your code might be trying to load something that cannot be accessed while in use by another shard

earnest phoenix
#

My command handler could where its loading all the commands ๐Ÿคทโ€โ™‚๏ธ

#

that is like the only thing that would take awhile

#

and somehow its now working

#

without me doing anything

#

I jinxed myself

tough relic
#

Hey guys! So basically I want the user to enter a command: !predic <sex> <age>

#

But how can I find the age and the sex in an input?

#

In python

modest maple
#

by splitting le message?

#

get content -> split -> select parts wanted -> yeet

tough relic
#

Alright I'll search about that!

#

Thx

modest maple
#

i mean its basics python :shurg:

tough relic
#

Yeah I don't code a lot

modest maple
glad leaf
#

how can i make a channel only accept 1 specific command?

#

like no chatting no other commands only 1 specific command all other messages get deleted

quartz kindle
#

define which channel that applies to: if(message.channel.id === "some id")

#

then check if the messages start with the command

#

````if(message.content.startsWith("yourcommand"))```

#

else delete the message

amber fractal
#

What version

#

you have to recategorize all the channels

copper cradle
#

ofc it won't

wide ruin
copper cradle
#

you gotta set them with Channel#setParent()

#

i mean

wide ruin
#

this isnt sending the guild amount to dbl correctly

copper cradle
#

it's kinda obvious

amber fractal
#

setParent doesnt exist in 11.4.2

wide ruin
#

the token was printed right, but it still saus n/a

amber fractal
#

wait

#

Im on guild

#

one se

copper cradle
#

@amber fractal wtf

amber fractal
#

I was on guild

modest maple
#
production = False
try:
  open("devmode", "r").close()
except FileNotFoundError:
  production = True``` waht the fuck is that
amber fractal
#

not TextChannel

#

setParent will work

wide ruin
#

@modest maple it checks if devmode is on

amber fractal
#

Why dont you have that in some config

copper cradle
#

@earnest phoenix I already told you

modest maple
#

why do you have that as a fucking file?

wide ruin
#

we have a devbot as well

amber fractal
#

like a json config

wide ruin
#

i didnt do it, no clue

copper cradle
#

TextChannel#setParent() @earnest phoenix

wide ruin
#

its just because we have 2 devs and its ignored on a git push

amber fractal
#
"devmode":true
}```
#

along with any other config stuff

wide ruin
#

so he always has the dev code, i always have current code

#

because i dont have the dev file

amber fractal
#

Could make 2 branches

modest maple
#

i dont see anywhere where youve called dbl

wide ruin
#

he overwrote it shit

modest maple
#

so so so much of that code is bad

#

no offense

#

but holy fuck

#

sort out how you two are working on this

#

because rn its messy as shit

copper cradle
#

yeah

wide ruin
#
class TopGG(commands.Cog):
    """Handles interactions with the top.gg API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = token[1] # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes

    async def on_guild_post():
        print("Server count posted successfully")

def setup(bot):
    bot.add_cog(TopGG(bot))```
#

does that print anything if its successful or not?

slender thistle
#

I smell dblpy

modest maple
#

you have a file to indicate being devmode of not, instead of just being a var
you get the token twice and only use the first one
you load tokens into a list using a one liner for loop even tho its only one line and just readlines(1) would work
you use context managers for everything other than what could actually benefit from it like open
your indentation in some places is 2 spaces others its 4
you override so much

slender thistle
#

Have you read the docs

modest maple
#

shiv

#

ree

#

this is my turn to blast them

#

xD

#

now for your actual issue:

slender thistle
#

Oh I thought you were yelling at someone else

modest maple
#

in no part of your code do you even call dbl
nor do you even set it up

wide ruin
#

i added the dbl stuff

modest maple
#

sigh

wide ruin
#

but the devmode file is .gitignored, so when i push, he still uses dev code

modest maple
#

so much is wrong

copper cradle
#

@wide ruin that is inefficient

#

you should know

modest maple
#
  1. Dont override your tokens
  2. Get better varbile names
  3. use context managers correctly
  4. dont use a fucking file as a var
  5. dont randomly slap in a class and remove self
  6. dont put a class randomly in some code and hope it works
  7. learn pep 8 please god
  8. actually put classes and functions where they want to be to work with varbles etc not randomly in what ever code to make it work
wide ruin
#

im going through your list rn

modest maple
#

thank you for comming to my ted talk

copper cradle
#

that list should be a -command

#

such as -notr

modest maple
#

what

#

-cf8's_guide_to_making_a_program_readable

slender thistle
#

Guide

copper cradle
#

^

modest maple
#

fuck

copper cradle
#

guilde

#

better

modest maple
#

you saw nothing

wide ruin
#
file = open('dbltoken.txt', 'r')
bot.dbltoken = file.readlines(1)
file.close()```
@modest maple
#

is that better?

modest maple
#

no

wide ruin
#

how should it be?

modest maple
#

๐Ÿ˜ข

#

you must know how to use with

copper cradle
#
with open('dbltoken.txt', 'r') as f:
    bot.dbltoken = f.readlines(1)
#

there

slender thistle
modest maple
#

you also must know what token is on which line

#

and what thing is what

#

๐Ÿ‘ learn ๐Ÿ‘ the ๐Ÿ‘ basics ๐Ÿ‘

copper cradle
#

I'm not even a python dev

amber fractal
#

json is good for configuration

modest maple
#

now im gonna go yeet myself off the edge of a cliff

wide ruin
#

im not even the one who did that section so dont blame me

sudden geyser
#

.env better

#

CF8 can I join you

modest maple
#

either work

#

@wide ruin so discuss it with ur other dev

#

and tell him to fucking learn pep 8 and basics

wide ruin
#

ok

modest maple
#

cuz you and him seem to have a major lack in communication

copper cradle
#

@earnest phoenix show the error

#

and show your code

#

I mean

#

it's the same logic

#

like not the samd but you get my point

#

show the error you're getting

#

alright

#

like

#

```js
code here

#

@earnest phoenix

#

that's a very inneficient way of doing it

#

you could have each channel name in an array

#

then loop through them and then create each channel

#
let names = ["name 1", "name 2", "name 3"];

for (let i = 0; i < names.length; i++) {
  server.createChannel(names[i], "text").then(c => c.setParent(/*ya know what to do*/));
}
#

like so

#

well

earnest phoenix
#

docs exist for that very reason

copper cradle
#

yes

#
#

there

earnest phoenix
#

learn how to keyword search

copper cradle
#

@earnest phoenix the category

#

holy cow

#

n-no

finite bough
#

message.channel.send(message.author.avatarURL)

earnest phoenix
#

What can I use for send an avatar when you use: !avatar Alessandroโšก#7960
use regex to extract the username and discriminator from your argument and then search a user with the exact username and discriminator in your client cache

#

and no, i may not give you any code

copper cradle
#

yes

earnest phoenix
#

what about it

finite bough
#

message.mentions.users.first()

#

or

#

search by name

#

args[0]

earnest phoenix
#

a mention doesn't exist there

finite bough
#

I thought he said mention at 1st

tight plinth
#

@finite bough search by username is just args.join(' ')

finite bough
tight plinth
#

Not args[0]

#

Coz space usernames

finite bough
#

tru

earnest phoenix
#

an inefficient but a functional lookup would be to map all members to a string in username#discriminator format and then find a match based on the input string

tight plinth
#

.split('#')

earnest phoenix
#

well

#

no

finite bough
#

names can have #

earnest phoenix
#

i'm pretty sure you can have hashtags in usernames

tight plinth
#

Ah

earnest phoenix
#

yeah

tight plinth
#

Well

copper cradle
#

no

#

you can't have #

#

I just tried

#

it won't let me

#

so .split('#'); should do it

tight plinth
#

let discriminator = args.split('#')
discrinimator[discriminator.length-1]

#

Or something like thag

elder moss
#

dm me if you can help me running my bot

copper cradle
#

lumap

earnest phoenix
#

split should do it then

copper cradle
#

discriminator[0]

quartz kindle
#

well, you can always fetch the member from discord. it allows for string searches

earnest phoenix
#

it doesn't

broken jay
#

When I make API for my bot communication with DB, will I get big win of performance or not?

zenith terrace
#

@elder moss just ask in here

elder moss
#

it says that i havent installed discord through cmd prompt when i have

tight plinth
#

@copper cradle usernames with #

elder moss
#

@zenith terrace ^^

quartz kindle
#

since when it doesnt?

copper cradle
#

why the fuck would you do Array[Array.length-1]

earnest phoenix
#

you can only fetch members via ids, anything else is a cache lookup

elder moss
#

i did

cursive dagger
#

library?

copper cradle
#

usernames ๐Ÿ‘ can't ๐Ÿ‘ have ๐Ÿ‘ #

broken jay
elder moss
#

Who uses Pycharm (text editor)

quartz kindle
elder moss
#

Thanks

quartz kindle
#

you can request guild members by name

earnest phoenix
#

wat

#

where tf does it say that

copper cradle
#

ยฏ_(ใƒ„)_/ยฏ

finite bough
#

tim comes in like Hitler

quartz kindle
#

query? string string that username starts with, or an empty string to return all members

earnest phoenix
#

im intrigued, hm i wonder how far you can go with that

pale vessel
#

cry: read the docs
also cry: where the fuck does it say that

tight plinth
#

message.guild.members.get(member => member.user.username === args)

#

I guess

finite bough
#

no

tight plinth
#

Oof

finite bough
#

multiple users with same name

quartz kindle
tight plinth
#

Use user id

pale vessel
#

basically a mention

tight plinth
#

Works too

earnest phoenix
#

@quartz kindle i don't think that's the gateway opcode

#

that might be a REST request

quartz kindle
#

it is

earnest phoenix
#

wait nvm

#

yeah

#

i just saw it in the src

quartz kindle
#

ye

#

you can also get presences with this

#

instead of using presence packets

#

but you need the presences priviledged intent

zenith terrace
#

Dont question or try to correct the Tim. He knows all

earnest phoenix
#

i wonder how far you can push it

zenith terrace
#

๐Ÿ‘€

quartz kindle
#

wdym how far?

pale vessel
#

no one is perfect

quartz kindle
#

max is 100 members if you dont have priviledged members intent

zenith terrace
#

Dont ruin the fun

#

:(

earnest phoenix
#

how many requests you can do before you get ratelimited/get kicked off the websocket

pale vessel
quartz kindle
#

isnt the ratelimit for the gateway 60/60?

#

per socket connection

earnest phoenix
#

that's IDENTIFY i think, not sure

quartz kindle
#

120/60 actually

#

indentify is 2/5

earnest phoenix
#

ah

quartz kindle
#

actually 1/5 for login, but 2/5 for getting recommended shard count

#

weird af

elder moss
#

i downloaded the discord py through command prompt

#

and it still doesnt work when i import it

#

someone please help

pale vessel
#

read guides

elder moss
#

I did

#

I even watch videos

pale vessel
#

usually it's user's fault

#

but

elder moss
#

?

pale vessel
#

what do you mean by "it doesn't work"?

#

does it throw an error, etc.

#

please give details

elder moss
pale vessel
#

p.s. he reset the token

elder moss
#

thats the problem

quartz kindle
#

dont you need to install it in your project?

#

you installed it in a different folder

elder moss
#

Oh

#

Thank you

#

i willtry it

#

how to do that

#

wait

#

nvm

quartz kindle
elder moss
#

ok

#

thanks

#

yes i use pycharm

finite bough
#

yes

#

what u trying to do

earnest phoenix
#

have you tried reading the docs

#

there's an example

quartz kindle
#

create the category first, then create the channels using the category as parent in the channel options

#

by reading the docs

#

also, you cant do so many async operations at once

#

you need to use an async function and properly await each request

#

else you will get rate limited

#

whats your current code?

#

use code blocks

#

``` code here ```

#

first remove the require("discord.js"), you're not using it anywhere

#

then make everything an async function: exports.run = async function(...)

finite bough
#

._.

quartz kindle
#

just add the async keyword to the function

finite bough
#

python dev should know that too

#

a

#

export run has nothing to do with DC bots

#

lmao

quartz kindle
#

then, you cannot delete channels like that, if you have 50 channels, your bot will try to delete them all at once, which will send 50 requests to discord at once, and will get you rate limited

#

you have to use a regular loop, and await each request

finite bough
#

in easy language

#

add await after every line

#

after the 1st request

#

xd

quartz kindle
#
for(let channel of message.guild.channels) {
  await channel.delete()
}```
finite bough
#

tim: stfu I am trying to help this guy and u r ruining the fun

quartz kindle
#

lmao

finite bough
#

good choice

quartz kindle
#

ยฏ_(ใƒ„)_/ยฏ

copper cradle
#

@earnest phoenix that has nothing to do with making dc bots lmao

#

python also has async/await

#

and it's the same logic

finite bough
slate oyster
#

oof wrong channel

valid holly
#

worst case you can time the delete()

slate oyster
#

oof

elder moss
#

Thanks guys its working and running my bot is

valid holly
#

๐Ÿค

finite bough
#

desu timing it is better than smashing all the requesting up together and shoving it up discord

valid holly
#

Yeah, thatโ€™s why I recommended, in worst case he canโ€™t wrap his head around async/await he can time it

finite bough
#

I think

#

timing is harder

#

than just putting all the stuff inside a async function and writing like 100 await

#

lmao

earnest phoenix
#

na ez

true ravine
#

How come channels become uncached when they no longer exist (aka bot left server) but users remain cached even if the bot has no common servers with them

#

(discord.js if that's relevant)

quartz kindle
#

ยฏ_(ใƒ„)_/ยฏ

#

i guess channels may get deleted/changed when the bot rejoins, while users will most likely still exists, except for maybe a username change

#

so channels would need to be fetched again regardless, while users not

true ravine
#

The user I'm testing with is an alt that is only in one server and when I kick the bot from that server it can't get the channel name but it can still get the alt's tag

quartz kindle
#

also, not sure about this one, but can users still dm the bot if they have no servers in common?

earnest phoenix
#

no

true ravine
#

Nah clyde goes sicko

quartz kindle
#

lmao

true ravine
#

I store channel, guild and user ID's in a db when a certain command is run but I want to delete them when the user isn't accessible, and yet it stays cached until I reboot

#

I don't want to have to reboot every 10 seconds that's boring

copper cradle
#

lmao

quartz kindle
#

well, just remove it from the cache yourself

copper cradle
#

use tim's lib

#

da-don

quartz kindle
#

lul

true ravine
#

rUlE 4

#

jk

#

How would I manually remove them from the cache?

quartz kindle
#

v11 or v12?

true ravine
#

v11 at the moment

copper cradle
#

hack the lib mmLol

quartz kindle
#

client.users.delete(id)

true ravine
#

Oh right thanks

quartz kindle
#

or client.users.sweep(user => user.id === id)

true ravine
#

But how is the bot gonna know whether to delete from the cache if it doesn't know if the user is actually accessible or not

quartz kindle
#

you mean how will it know if the user left all common servers?

true ravine
#

Yeah

quartz kindle
#

you'd need to try fetching it i guess

true ravine
#

And then catch?

quartz kindle
#

although i think you can still fetch users that dont share servers

true ravine
#

Hmmm

#

I'll just play around with stuff ig

quartz kindle
#

let me test real quick

true ravine
#

Oh okay thanks

finite bough
#

@quartz kindle nup

#

cant dm

quartz kindle
#

welp i can still fetch them

true ravine
#

Bruh

finite bough
#

well yea

#

cached they r

#

discord no care catched or !catched

quartz kindle
#

there doesnt seem to be a noticeable difference between a user who shares and doesnt shares servers with the bot

finite bough
#

tho

quartz kindle
#

unless the users i tested are actually in servers with my bot that i dont know about

#

lmao

finite bough
#

hmmm

true ravine
#

Does fetchUser check cache or send a http request?

finite bough
#

@buoyant smelt

#

dm this bot

#

nvm

#

can ya like invite me to a server with a bot which is not here

quartz kindle
#

it checks cache and then sends it if not cached

finite bough
#

and then I will leave and try to msg it

true ravine
#

But if the bot thinks it's cached it will just check cache ๐Ÿค”

#

Reeee

quartz kindle
#

the bot doesnt think, it checks lol

finite bough
#

bot smarter than us

#

๐Ÿ˜”

true ravine
#

They are going to take over

quartz kindle
#

anyway, i cant think about a reliable way to check when a user becomes unavailable to the bot

#

besides trying to fetch it in all guilds to see if hes still present in some of them

true ravine
#

Maybe I'll just have to pretend that everything is fine but then use catch blocks on stuff

quartz kindle
#

if you can, just leave it in your database, thats what i do

#

you can implement some sort of "last seen" field in your database

#

and delete it if he hasnt been seen for like 1 month or a year

true ravine
#

Nah I think I'm just gonna have to catch stuff

quartz kindle
#

wdym?

true ravine
#

It attempts to send a message to a channel (whose id is in db) and mention a user (whose id is in the db) but if it can't find that user and or channel then I just catch that and delete it from db

small prairie
#

how can i reverse a collection

#

d.js

#

11v

true ravine
#
user.send("test")
.catch(()=>{
  //delete from db
})

Like this

#

how can i reverse a collection
Put it in the opposite order you mean?

small prairie
#

yup

finite bough
#

well tim

small prairie
#

like i fetchmessages

#

i need to reverse those

true ravine
#

ig you could use sort

finite bough
#

if I leave this server and try to msg u after 1 second

#

pretty sure it will not work

#

so either try leaving ur bot server and msging ur bot

#

or ask someone else to join and leave and msg

#

thats pretty reliable I think

quartz kindle
#

but the idea is have the bot detect it, not the user

#

ah you mean to test if you can still dm the bot with no shared servers?

#

@true ravine if you're using an unmodified discord.js channels are always cached

#

so you can do js if(client.channels.get(id from db)) { ....send() }

finite bough
#

yea

quartz kindle
#

and in the send you can simply type <@user id from db>

true ravine
#

What about guilds?

quartz kindle
#

it will work

#

guilds are also always cached

true ravine
#

Hmmm

#

When I kick the bot from the server and do bot.guilds.get(id of server i just kicked it from) it can't find it

#

Which is what I want

#

But I want the user to behave the same way

quartz kindle
#

you cant have the user behave the same way

#

but you dont need it to

#

you can mention users even if they are not available

true ravine
#

That's not the only thing it does with the ids, it was just an example

quartz kindle
#

it will show the mention to people who have the user available, and just show <239847283740825> to those who dont

true ravine
#

Yeah I know that

quartz kindle
#

then what is it?

true ravine
#

It also needs to be able to DM them

#

Which is an issue

quartz kindle
#

then yeah, dm them and catch it

true ravine
#

Aight I'll do that

#

Cheers ๐Ÿ‘

finite bough
#

like

#

when an user leaves

#

u can still find them using @

pale vessel
#

a*

finite bough
#

for about 5-6 min

#

an*

pale vessel
#

a*

finite bough
#

an

pale vessel
#

why?

finite bough
#

u use an infront of words starting with a,e,i,o,u

pale vessel
#

we pronounce user as "yu-ser"

#

"y-"

#

a

#

got it?

finite bough
#

I pronounce user as FML

#

got it?

pale vessel
#

yes

finite bough
#

xD

pale vessel
#

mee too

tight plinth
#

We pronounce user as "utilisateur" in french

finite bough
#

._.

pale vessel
#

french is very interesting but too bad this is for development only ._.

tight plinth
#

Oof

pale vessel
#

is canadian french similar to french-french?

tight plinth
#

Yes

#

Some words are different, but it's almost the same language

finite bough
#

related to development 100% no sarcasm^

pale vessel
#

yeah fuck it

finite bough
#

xD

pale vessel
#

nobody needs help anyway

finite bough
#

XDD

tight plinth
#

I need help, I suck at js

#

Like

pale vessel
#

same

finite bough
#

pro tip

tight plinth
#

I type something, it crashes

finite bough
#

just use dots after every word

#

like.this.and.u.will.get.the.hang.of.it.in.no.time.lmao();

pale vessel
#

my . switch is broken because of that

tight plinth
#

Does.this.will.work

pale vessel
#

i need to change them constantly

finite bough
#

add ();

tight plinth
#

Xignotic.isStinky(true)

#

Like that?

pale vessel
#

$(".Xignotic").text() == "Stinky" ? "Yes." : "No."

tight plinth
#

Waa

quartz kindle
#

why jquery lul

tight plinth
#

Dafuk

quartz kindle
pale vessel
#

because i scrape websites a lot

tight plinth
#

No u tim

tough relic
#

Hey! Is there a way to time a message? (Like every hour the bot will send a message?)

#

I searched on stack overflow but couldn't find anything

pale vessel
#

Programming language?

tough relic
#

Python

pale vessel
#

Try set_interval

#

well make one

modest maple
#

generally a bad idea to automatically send messages

#

but make a coro and a while loop and create a task in a event loop

finite bough
#

hourly msgs r usefull

pale vessel
#

depends

modest maple
#

discord no likey them

pale vessel
#

they could be annoying

lyric mountain
#

Hey! Is there a way to time a message? (Like every hour the bot will send a message?)
@tough relic cronjob

tough relic
#

Thanks I will see what cronjob is!

lyric mountain
#

It's a thing designed specially for doing scheduled tasks, it's present in almost all languages as a library

restive furnace
#

or timeout

lyric mountain
restive furnace
#

on js setTimeout(() => function_here, time_in_ms)
on py while true: function & time.sleep(time_in_secs) (you need to import time)

#

easy

lyric mountain
#

Except that way you'll not run that code precisely each hour

#

Since everytime you restart the code the timer will go back

restive furnace
#

yes?

lyric mountain
#

He wants to send a message every hour

earnest phoenix
#
bot.users.get("686698479271280640").send

Why does bot.users.get() return undefined? The user ID is me btw.

pale vessel
#

djs version?

restive furnace
#

@lyric mountain yes? you can do it that way?

lyric mountain
#

Was that a question or an affirmation?

restive furnace
#

affirmation

tight plinth
#

@earnest phoenix bot.users.cache.get

#

Maybe

lyric mountain
#

timeout works wonders as delay, but not as precise scheduling of tasks

#

While cron is the inverse

restive furnace
#

okay

earnest phoenix
#

v11

#

and ill try it

finite bough
#

@earnest phoenix no

#

cache is not for 11v

earnest phoenix
#

a

quartz kindle
#

.cache is for v12 not v11

earnest phoenix
#

ok

quartz kindle
#

@earnest phoenix make sure you're using the correct client instance and that the client is ready

earnest phoenix
#

mhm

pale vessel
#

and that you defined client as bot

earnest phoenix
#

im sure

quartz kindle
#

show code

earnest phoenix
#

let me get back on my pc

#

might take a few more mind

#

mins

#

I may have defined a client twice

#

oops

finite bough
#

how ..--..

earnest phoenix
#

Don't ask lol

#
global.Discord = require('discord.js');
global.moment = require('moment');
global.fs = require('fs');
global.ms = require('ms');
global.request = require('request');
global.chalk = require('chalk');
global.bot = new Discord.Client();
global.config = require('./config.json');
global.result = require('./config.json');
global.client = new Discord.Client();
#

Still get the same error

finite bough
#

either use client or bot

earnest phoenix
#
bot.on("message", async (message) => {
    if (message.channel.type == "dm"){
        bot.users.get("686698479271280640").send(`${message.author.username}\n``${message.content}`` `);
        const collectorr = client.users.get("686698479271280640").dmChannel.createMessageCollector({ time: 1500000 });
        collectorr.on('collect', m => {
            message.author.send(`Reply from _:\n**${m}**`);
        })
        return;
    }
#

I used both

#

same emitted the same error.

#

still*

#
(node:14) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at Client.<anonymous> (/home/container/index.js:60:44)
at Client.emit (events.js:210:5)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:210:5)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:210:5)
(node:14) 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:14) [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.
finite bough
#

@earnest phoenix define a guild and try searching urself from thst guild

earnest phoenix
pale vessel
#

global.client.users?

earnest phoenix
#

oke

pale vessel
#

are you going to try it or you just wanted to say ok?

earnest phoenix
#

Still the same error.

#

I tried it

finite bough
#

code

earnest phoenix
#

Ok

pale vessel
#

the full one

earnest phoenix
#

Full code of my index?

pale vessel
#

sure

finite bough
#

nope

pale vessel
#

as a file

finite bough
#

:/

earnest phoenix
#

In that case I'll just experiment

#

I don't feel

#

eg

#

Thanks for the help.

finite bough
#

@earnest phoenix only. ode

pale vessel
#

yeah i wouldn't do that either

#

full error?

toxic jolt
#

help please

#

(node:4) UnhandledPromiseRejectionWarning: Error: Something took too long to do.

pale vessel
#

ok stop sending the same thing

toxic jolt
#

@pale vessel okay

pale vessel
#

it has something to do with setTimeout

#

do you use that somewhere in your code?

toxic jolt
#

hmm

#

wait

pale vessel
#

if so, please send a snippet of that code

toxic jolt
#

@pale vessel i dont using setTimeout

pale vessel
#

figures

toxic jolt
#

in bot.js

pale vessel
#

it was from the client manager

#

it might has something to do with your network

toxic jolt
#

no i using heroku and glitch

#

both are the same problem

pale vessel
#

and?

#

i see

#

find something that returns a promise

toxic jolt
pale vessel
#

it looks like the promise got rejected

toxic jolt
sudden geyser
#

What version of Discord.js are you using.

toxic jolt
#

the same problem

#

@sudden geyser hmm wait

sudden geyser
#

nevermind I see it in the screenshot

toxic jolt
#

1.0.0

pale vessel
#

nope

finite bough
#

.

sudden geyser
#

that's not discord.js version

#

you're using v11

toxic jolt
#

oh sorry

pale vessel
#

stop dotposting

toxic jolt
#

11.5.1

sudden geyser
#

on glitch, can you open your console and run curl -I https://discordapp.com/api/v7/gateway and see if it says 200 OK

toxic jolt
#

okay

pale vessel
#

damn there's 7 versions already

sudden geyser
#

I don't know, it just works

#

no v7 (still works though)

toxic jolt
#

@sudden geyser

pale vessel
#

200 OK

quartz kindle
#

@earnest phoenix you cant use two clients

toxic jolt
#

@quartz kindle tim help me pls

quartz kindle
#

unless you want to login twice and keep two bots logged in lol

pale vessel
#

lmao. bot and client

earnest phoenix
#

o

pale vessel
#

replace everything that uses "bot" to client and remove bot

quartz kindle
#

@toxic jolt show code

pale vessel
#

in programming, show code is equivalent to show bobs

copper cradle
#

vagene

pale vessel
#

don't criticize people

copper cradle
#

aight

pale vessel
#

jk

#

you can

copper cradle
#

ai

#

fucking

#

removed it

pale vessel
#

ass

copper cradle
#

deal with it

pale vessel
#

all right we'll just leave that there...

rose warren
#

Can I make a Discord bot with C++?

#

Is that possible??

tight plinth
#

Yes

lyric mountain
#

You can make a bot with whatever language you want, there's pretty much one lib for every one.

rose warren
#

Okay. Thanks.

restive furnace
#

but tip: theres no need to use so that low-level language, you can even use python (med/high-level).

earnest phoenix
#

good luck dealing with cpp because websockets are ass

wintry jungle
#

I'm assuming everybody is having problems connecting this morning right?

earnest phoenix
#

check the api status page and discords twitter

finite bough
#

imagine making a bot with html

tight plinth
#

Lol

lyric mountain
#

You can't lol, because....
i t ' s n o t a p r o g r a m m i n g l a n g u a g e

#

Rofl

restive furnace
#

it is

finite bough
#

it is angeryBOYE

tight plinth
#

It is

restive furnace
#

and theres even lib for php

#

Restcord

lyric mountain
#

Php != HTML

restive furnace
#

php and html almost same atleast for me so dont rage

finite bough
#

ok..

restive furnace
#

it is possible on html too

#

wait

finite bough
#

HTML 5

restive furnace
#

hold on

#
#

there

lyric mountain
#

That's for js lol

earnest phoenix
#

if (msg.channel.type=="dm") return msg.channel.send('You can use commands in DM\'s') guys why this isnt working?

finite bough
#

php = js

#

comfirmed

restive furnace
#

<script type="text/javascript" src="discord.11.1.0.min.js"></script> <script type="text/javascript"> const client = new Discord.Client(); client.on('message', msg => { const guildTag = msg.channel.type === 'text' ? `[${msg.guild.name}]` : '[DM]'; const channelTag = msg.channel.type === 'text' ? `[#${msg.channel.name}]` : ''; console.log(`${guildTag}${channelTag} ${msg.author.tag}: ${msg.content}`); }); client.login('some crazy token'); </script>

lyric mountain
earnest phoenix
#

What is it @restive furnace

restive furnace
#

html = js

finite bough
#

@earnest phoenix error?

earnest phoenix
#

@finite bough no

lyric mountain
#

Html = [js, php, css]

restive furnace
#

yes

lyric mountain
#

But html != js

#

Nor php and css

restive furnace
#

you literially said it

lyric mountain
#

I defined an array

restive furnace
#

Html = [js, php, css]

hoary elm
#

Usually for that stuff I use message.channel.type != 'text' @earnest phoenix

lyric mountain
#

An array of languages

hoary elm
#

!= Text

earnest phoenix
#

@hoary elm ty i will try now.

lyric mountain
#

Html wraps then all, but isn't a lang at all

#

Html is the outside of the pepperoni

restive furnace
#
console.log(html == html) // returns true ```
quartz kindle
#

php is no way near the same as html lol

restive furnace
#

yes

hoary elm
#

Lol why is this even an argument

lyric mountain
#

Idk, they try to compare a plastic bag with the stuff you bought

#

Lol

hoary elm
#

๐Ÿ˜‚๐Ÿ˜‚

restive furnace
earnest phoenix
#

@hoary elm same dude.

slender thistle
#

HTML is markup language

finite bough
#

@lyric mountain what if they bought plastic bags xd

restive furnace
#

Technically,ย HTMLย is aย programming language. In fact,ย HTMLย stands for Hypertext Markupย Language. ... WhileHTMLย and CSS are declarative, mostcodingย is computational - and it's what most otherย codingย languages are designed for.30.4.2019

finite bough
#

@earnest phoenix show full code

lyric mountain
#

If it was a programming language then it'd be PL, not HTML

#

Hypertext Markup Language

quartz kindle
#

html is a programming language

finite bough
#

YES!

hoary elm
#

It is but it's more for Web Browser related stuff

restive furnace
#

Finally

finite bough
#

TIM SAID IT

#

ARGUMENT ENDS THERE

quartz kindle
#

its a declarative programming language, as opposed to an imperative programming language

earnest phoenix
#

```if (message.channel.type !== "text" )return message.channel.send(You cant use commands in DM\'s.)

tight plinth
#

@earnest phoenix if !message.guild

lyric mountain
#

Lol I can't stand people denying the obvious

finite bough
#

@tight plinth that should work too

earnest phoenix
#

Oh, true i was forget it :/

tight plinth
#

It works

finite bough
#

I mean only message.channel

tight plinth
#

@finite bough message.channek always exist

finite bough
#

channek

tight plinth
#

Channel

finite bough
#

XD

tight plinth
#

Fuck my keyboard

finite bough
#

XDDD

earnest phoenix
#

TypeError: message.channel.permissionsFor is not a function

lol

tight plinth
#

True

restive furnace
#

thats different code

#

lol

tight plinth
#

It doesn't exist

hoary elm
#

Where is that error originating?

restive furnace
#

no its not function

#

message.channel.permissionsFor*()* <-- not function

finite bough
tight plinth
#

Not a function don't exist, so it's not a function

restive furnace
#

you code on phone + glitch

finite bough
#

like rlly

earnest phoenix
#

command.code

restive furnace
#

awful doubt

tight plinth
#

If message.author.bot

finite bough
#

@restive furnace neither on glitch nor on phone

restive furnace
#

then why u on phone and on glitch?

finite bough
#

that's just an example

#

coz I dont access to my files on phone

tight plinth
#

Vps is better

finite bough
#

REEEEEE

restive furnace
#

then buy me one

sudden geyser
#

please charge your phone

finite bough
#

no access!!!!!!

tight plinth
#

Lol

finite bough
#

@sudden geyser bully

restive furnace
#

@tight plinth buy me one if vps better

tight plinth
#

@restive furnace I don't buy my vps, I can't buy you one

#

Epic buys mine

restive furnace
#

jkjk i alr know

finite bough
#

I can buy u a vps

#

just u have to pay 5$ every month

#

deal?

restive furnace
#

wdym

#

so u buy me vps and i pay u it?