#development

1 messages · Page 613 of 1

robust acorn
#

i tried {0}

wraith cipher
#

.name returns the username of the user

robust acorn
#

but its like you are missing 0.name

wraith cipher
#

wait

slender thistle
#

Hell

#

Do you think that works

robust acorn
#
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 367, in invoke
    yield from self.prepare(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 345, in prepare
    yield from self._parse_arguments(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 304, in _parse_arguments
    transformed = yield from self.transform(ctx, param)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 212, in transform
    raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param))
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.```
wraith cipher
#

lol it doesn;t even return the username

robust acorn
#

when I do not put .name

#
async def votecheck(ctx):
   url = 'https://discordbots.org/api/bots/514146427186839552/check?userId={0}'.format(ctx.author.id)
   async with aiohttp.ClientSession() as session:
        raw_response = await session.get(url)
        response = await raw_response.text()
        response = json.loads(response)

   if response['voted'] == 1:
     await client.say("You voted")
   else:
     await client.say("You did not vote")```
slender thistle
#

Is that command in a class

robust acorn
#

nope

#

it is not in a class

#

this is discord.py==0.16.12

#

I had trouble converting everything to rewrite

slender thistle
#

pass_context=True in command decorator

robust acorn
#

yeah right

#

in rewrite pass_context was not required

slender thistle
#

Correct

robust acorn
#

same error

slender thistle
broken elm
#

uhh srr

#

but

#

tried to format that lol

slender thistle
#

Looks like a JSON inside an array inside a JSON

robust acorn
#

It never runs the script, it does not print

broken elm
#
{ data:
   [ { type: 'gif',
       id: 'uLnPIWsqIz2aA',
       slug: 'pokemon-look-pikachu-uLnPIWsqIz2aA',
       url: 'https://giphy.com/gifs/pokemon-look-pikachu-uLnPIWsqIz2aA',
       bitly_gif_url: 'https://gph.is/1dAWL60',
       bitly_url: 'https://gph.is/1dAWL60',
       embed_url: 'https://giphy.com/embed/uLnPIWsqIz2aA',
       username: '',
       source: 'https://gif-database.tumblr.com/post/18010720856',
       rating: 'g',
       content_url: '',
       source_tld: 'gif-database.tumblr.com',
       source_post_url: 'https://gif-database.tumblr.com/post/18010720856',
       is_sticker: 0,
       import_datetime: '2013-07-15 20:26:08',
       trending_datetime: '1970-01-01 00:00:00',
       images: [Object],
       title: 'searching look around GIF',
       analytics: [Object] },
     { type: 'gif',
       id: '7T200DTPdx31e',
       slug: 'pokemon-videogame-7T200DTPdx31e',
       url: 'https://giphy.com/gifs/pokemon-videogame-7T200DTPdx31e',
       bitly_gif_url: 'https://gph.is/XHDQDN',
       bitly_url: 'https://gph.is/XHDQDN',
       embed_url: 'https://giphy.com/embed/7T200DTPdx31e',
       username: '',
       source: 'https://gifloop.tumblr.com/post/2748179648',
       rating: 'g',
       content_url: '',
       source_tld: 'gifloop.tumblr.com',
       source_post_url: 'https://gifloop.tumblr.com/post/2748179648',
       is_sticker: 0,
       import_datetime: '2013-03-25 07:50:00',
       trending_datetime: '1970-01-01 00:00:00',
       images: [Object],
       title: 'pokemon videogame GIF',
       analytics: [Object] },
#

ok

#

so

#

how do i use the url objects

#

i tried using res.data.url

#

but

#

that didnt work

slender thistle
#

Because that JSON is in an array

broken elm
#

i dont really know how to use this

#

how do i use it ?

slender thistle
#

How do you get a first element from an array

mossy vine
#

@lofty hamlet yeah that actually seems like a fair offer

slender thistle
#

@robust acorn What's up with the command

broken elm
#

use JSON.parse() ?

#

to do something else

robust acorn
#

my command does not run

broken elm
#

not get the first object

robust acorn
#

i tried printing

slender thistle
#

req.data was fine

#

The rest is not

broken elm
#

hmm

#

so

slender thistle
#

DankTech, literally nothing printed? No errors?

broken elm
#

how do i get the rest.... i wouldn't know jow to get the SECOND type: object also

#

never used a json response before

slender thistle
#

req.data is an array

#

Google 'get first element from array js'

broken elm
#

yeah

#

JSON.parse

robust acorn
#

nothing printed

#

error is

#

anyways, I can use this to check who votes if the person wants to use the command to check

#

but

#

I cannot really give rewards because

#

people would just spam p votecheck and spam rewards

wraith cipher
#

use a command cooldown

robust acorn
#

Im not sure how to do that

#

and I like it automatic detecting

#

I do not know how to target individual peopel

#
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 367, in invoke
    yield from self.prepare(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 345, in prepare
    yield from self._parse_arguments(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 304, in _parse_arguments
    transformed = yield from self.transform(ctx, param)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 212, in transform
    raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param))
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.```
#

error currently

lofty hamlet
#

You have a good heberger for a discord bot ? Or OVH

slender thistle
#

Hell, I'm not even sure if 1.0.0 would apply here since I don't remember using cmd extension much in async

wraith cipher
#

did you pass ctx ?

lofty hamlet
#

My heberger stop activity

robust acorn
#
async def votecheck(ctx, pass_contect = True):
   url = 'https://discordbots.org/api/bots/514146427186839552/check?userId={0}'.format(ctx.author.id)
   async with aiohttp.ClientSession() as session:
        raw_response = await session.get(url)
        response = await raw_response.text()
        response = json.loads(response)
   if response['voted'] == 1:
     await client.say("You voted")
   else:
     await client.say("You did not vote")```
#

this is my code....

slender thistle
#

Oh

#

Wrong thing

wraith cipher
#

pass_context should be in the decorator

slender thistle
#

Decorator, not the function

robust acorn
#

whats that?

wraith cipher
#

and its not contect

slender thistle
#

@client.command(...)

#

That's a decorator

robust acorn
#

oh yeah

#

I forgot

#

Im stupid

#

I have it like that for like all my other commands

#
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'author'``` I think I am getting closer
#

I might just import userid

slender thistle
#

Riight

#

Async

robust acorn
#

and just format the user id

wraith cipher
#

wait it's async right

slender thistle
#

ctx.message

#

Yes

robust acorn
#

it is async

slender thistle
#

You don't have a shortcut, so use ctx.message.author

robust acorn
#

3.6.1 python

slender thistle
#

Yep

#

Btw Google "f-strings python" later, quite useful

wraith cipher
#

can we use f strings in py 3.6.1 ?

robust acorn
#

yes you can use fstrings

#

btw what exactly do fstrings do?

#
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'voted'```
#

an error i had before

slender thistle
#

Any 3.6+ version

#

Yep, I expected that

#

You are not using the Auth header

robust acorn
#

heeaader = token

slender thistle
#

Nope

robust acorn
#

my keyboard is terrible

slender thistle
#

It's a dict where Authorization is the key and your bot's DBL token is the value

robust acorn
#

this site?

slender thistle
#

Yep

robust acorn
#

the api key...

slender thistle
#

Copy the API key, put it as a value for Authorization key inside a dict

robust acorn
#

umm, can you help me?

slender thistle
#

What's up

robust acorn
#

Im not sure what you mean

#

by putting value for authen key inside a dict

#

do I have to make a dict?

slender thistle
#

Yep

robust acorn
#

and how do I do that?

slender thistle
#

{}

robust acorn
#

strings?

#

oh

slender thistle
#

That's a dict

#

You should reset it

#

Also, you forgot a quote in the end of the key, but other than that, you are fine

robust acorn
#

yeah I just did

slender thistle
#

Except it's Authorization

#

Not authorization

#

Oh nevermind, there was an apostrophe already, my bad

robust acorn
#

yeah, I still had an extra space though lol

slender thistle
#

Easily fixable

robust acorn
#
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'dict' object has no attribute 'decode'```
#

umm

broken elm
#
{ type: 'gif',
  id: 'iBANmdIlMNJVC',
  slug: 'pokemon-pixel-iBANmdIlMNJVC',
  url: 'https://giphy.com/gifs/pokemon-pixel-iBANmdIlMNJVC',
  bitly_gif_url: 'https://gph.is/1UPIJm7',
  bitly_url: 'https://gph.is/1UPIJm7',
  embed_url: 'https://giphy.com/embed/iBANmdIlMNJVC',
  username: '',
  source: 'https://funnycutegifs.com/post/32507950027/moar-gifs-here',
  rating: 'g',
  content_url: '',
  source_tld: 'funnycutegifs.com',
  source_post_url: 'https://funnycutegifs.com/post/32507950027/moar-gifs-here',
  is_sticker: 0,
  import_datetime: '2016-06-14 01:40:55',
  trending_datetime: '1970-01-01 00:00:00',
  images:
#

did the thing

#

got this

#

now would i add another . to it

#

and get the url?

#

or one of the images below

#

so that basically just got the json format of the response correct?

slender thistle
#

Yep

broken elm
#

ok

slender thistle
#

You can now use the json

broken elm
#

so

#

still

slender thistle
#

@robust acorn Can you send me the full code of your command in DM

#

Or remove the API key and post it here, whichever one you are fine with

broken elm
#

just res.data[3].url

slender thistle
#

Should be good, if you are taking fourth element from your array

broken elm
#

yes!

#

thank you!

#

i've been wanting to learn how to do this for months, i was just lazy lmao

slender thistle
#

kek

broken elm
#

and if i wanted to use the images array

#

i would do the same thing I did for data?

slender thistle
#

I bet images is an array too so yeah

broken elm
#

ok

#

thaks

slender thistle
robust acorn
#
async def votecheck(ctx):
   url = {"Authorization":"token", "url":"https://discordbots.org/api/bots/514146427186839552/check?userId={0}".format(ctx.message.author.id)}
   async with aiohttp.ClientSession() as session:
        raw_response = await session.get(url)
        response = await raw_response.text()
        response = json.loads(response)
   if response['voted'] == 1:
     await client.say("You voted")
   else:
     await client.say("You did not vote")```
#

I was assuming that this is what was meant by dict?

#

like a string

#

I also need a database

slender thistle
#

Ehh

#

Uhh

#

Kinda wrong

robust acorn
#

but the problem is, many database do not support 3.6.1

slender thistle
#

The url was fine before

robust acorn
#

oh

wraith cipher
#

try mongodb

slender thistle
#

You would just need another variable with the dict

robust acorn
#

THATS WHAT I WANTED

#

mongodb

#

pymongo

#

but it does not support 3.6.1

#

does it?

#

and downgrading the database seemed like pretty hard

wraith cipher
#

maybe you should solve your reward issue first 😅

robust acorn
#

what other variable with the dict?

#

well

#

to solve the rewards issue

#

I kind of need a cooldown

#

which needs a database.....

wraith cipher
#

@commands.cooldown

#

that's the decorator you should use

robust acorn
#

what works?

#
async def votecheck(ctx):
   url = {"Authorization":"token", "url":"https://discordbots.org/api/bots/514146427186839552/check?userId={0}".format(ctx.message.author.id)}
   url = 'https://discordbots.org/api/bots/514146427186839552/check?userId={0}'.format(ctx.message.author.id)
   async with aiohttp.ClientSession() as session:
        raw_response = await session.get(url)
        response = await raw_response.text()
        response = json.loads(response)
   if response['voted'] == 1:
     await client.say("You voted")
   else:
     await client.say("You did not vote")```
slender thistle
#

If your bot doesn't go down all the time, you can use that decorator

robust acorn
#

i put the url back

slender thistle
#

Two url variables...

#

Also, no need for url in the dict

robust acorn
#

My bot stays on for like 18 hours a day.....

#

oh

#

I took it out.

slender thistle
#

So what's your code looking like atm

robust acorn
#
async def votecheck(ctx):
   url = {"Authorization":"token"}
   url = 'https://discordbots.org/api/bots/514146427186839552/check?userId={0}'.format(ctx.message.author.id)
   async with aiohttp.ClientSession() as session:
        raw_response = await session.get(url)
        response = await raw_response.text()
        response = json.loads(response)
   if response['voted'] == 1:
     await client.say("You voted")
   else:
     await client.say("You did not vote")```I have two urls......
slender thistle
#

Change the name of the dict?

#

header, data

#

Anything

robust acorn
#

btw if I want to make this a cooldown, I can put @earnest phoenix.cooldown in line two?

#

oops, sorry for the ping

slender thistle
#

Before async def, yes

robust acorn
#

ok cool

slender thistle
#

Just hold on

robust acorn
#

now I will put them in my suggest, etc

#

but my bot is sometimes downtime

#

and I have to restart the bot too

#

to test stuff

#

maybe I can make a beta bot

#
async def votecheck(ctx):
   url = {"Authorization":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUxNDE0NjQyNzE4NjgzOTU1MiIsImJvdCI6dHJ1ZSwiaWF0IjoxNTU3MDgyNjEwfQ.AT8E5MUnWLkZ9nD5svXPkrmLNdI_4s0Udv1dx42kurU"}
   url = 'https://discordbots.org/api/bots/514146427186839552/check?userId={0}'.format(ctx.message.author.id)
   async with aiohttp.ClientSession() as session:
        raw_response = await session.get(url)
        response = await raw_response.text()
        response = json.loads(response)
   if response['voted'] == 1:
     await client.say("You voted")
   else:
     await client.say("You did not vote")```
#
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'voted'```
#

error

slender thistle
#

when using session.get(), pass headers=data and rename your dict to data AND reset that API key

robust acorn
#

oh

#

I forgot about blurring that

slender thistle
#
How can I limit how often users can use bot commands?
from discord.ext.commands.cooldowns import BucketType

@commands.cooldown(rate,per,BucketType) 
# Limit how often a command can be used, (num per, seconds, Buckettype.default/user/server/channel)
#

Hope you are smart enough to figure this out on your own

robust acorn
#

yeah

#

FINALLY THE VOTE COMMAND WORKS!!

#

thank you all so much!

slender thistle
wraith cipher
robust acorn
#

btw, if someone triggers a command before the cooldown is over, how would the bot reply?

#

I think I can make my own

#

@stable gyroient.cooldown()

#

would that work?

wraith cipher
#

It raises an error

robust acorn
#

the cooldown works

wraith cipher
#

also shift to rewrite asap

robust acorn
#

@earnest phoenix.error

slender thistle
#

That depends on how you handle it

#

Use codeblocks

robust acorn
#

Why am i keep pinging people

slender thistle
#

``

robust acorn
#

yeah because there can be other reasons

#

for errors

#

other than cooldown

#

but if i try to send time remaining, that would cause an error too

#

and it would loop

#

thats bad

slender thistle
#

on_command_error if you want, handle all errors there but don't forget to output errors that you don't handle manually
or...
@command.error, yeah

robust acorn
#

yeah

slender thistle
#

time remaining? Cause an error?

#

I beg your pardon?

robust acorn
#
async def kick_error(error, ctx):
    if isinstance(error, CheckFailure):
        await client.send_message(ctx.message.channel, '{0.mention}, Looks like you dont have the permissions.'.format(ctx.message.author))```
#

like that format

#

thats one of my errors

#

is it possible to keep track of cooldown time remaining?

mossy vine
#

can someone quickly help me with a css issue? i have a div, and i want to align text to the left, but leave some space between the edge of the div and the text, how would i do that?

robust acorn
#

or do i have to start a timer manually

wraith cipher
#

error.retry_after

#

returns the time remaining

slender thistle
#

if error is instance of CommandOnCooldown or whatever it was, yeah, use that ^

wraith cipher
#

you can use datetime and modify the output

neat flame
#

@mossy vine either using padding-left or margin-left

#

actually do padding

mossy vine
#

i figured it out now, i just need to set the padding on the content, not the div itself

neat flame
#

ok cool

robust acorn
#

how does error.retry_after work?

wraith cipher
#

it returns a datetime object

robust acorn
#

oh

wraith cipher
#

wait ig it returns the amount of seconds left

slender thistle
#

float

#

hiw many seconds and milliseconds left until the command can be used again

topaz moth
#

how do i go about setting a webhook vote command with discord.py

harsh dagger
#

guys

slender thistle
#

dblpy client has some webhook settings that might help

harsh dagger
#
  if(message.author.Bot) return;
  if(message.channel.type === "dm") return;
``` somehow a bot bypassed this?
mossy vine
#

message.author.bot

#

not .Bot

harsh dagger
#

ooop

topaz moth
#

thats what i was trying before, theres a on_dbl_vote but i can find anything that tells me how it works

slender thistle
#

It's an event that takes a dict as its parameter

topaz moth
#

yeh but how does it trigger, what settings do i need to trigger it

robust acorn
#

what exists?

topaz moth
#

in the github example it has this self.dblpy = dbl.Client(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

robust acorn
#

use async

#

on event

slender thistle
#

You don't trigger it, it triggers itself when someone votes for your bot

robust acorn
#

what???

#

and how does it work

slender thistle
#

You just need to make sure your specified port is open

robust acorn
#

that would be better for me

slender thistle
#

dblpy is for 1.0.0 versions unfortunately

robust acorn
#

I have a port open

#

lol ok

#

rewrite

harsh dagger
#

@mossy vine the bot responds to other bots

grim aspen
#

not really

#

i think it responded to you

harsh dagger
#

how

slender thistle
#

If it responded to bots, it would have sent 4 messages instead of 1

harsh dagger
#

oh

#

true

grim aspen
#

it responded to you telling it to tell it to say

harsh dagger
#

ohhhhh

#

okay

#

thanks

fiery stream
#

hi

broken elm
#
let thirdGif = res.data[38].images.original.url;
                                    ^

TypeError: Cannot read property 'images' of undefined
    at C:\Users\Alex\Documents\Dunk\commands\gsearch.js:15:37
    at resolve (C:\Users\Alex\Documents\Dunk\node_modules\giphy-api\index.js:247:9)
    at IncomingMessage.<anonymous> (C:\Users\Alex\Documents\Dunk\node_modules\giphy-api\util\http.js:33:7)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1094:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
#

so

#

im getting this error

#

im counting correctly the amount of lines the response gives

#

but the "secondGif" variable works fine and supplies the gif from the images array before

#

without me using the [] on images

lament kettle
#

index 38 doesnt exist

#

most likely

#

console.log(res.data, res.data.length) and check

broken elm
#

ok

#

thanks

west spoke
#

:mmLol:

#

Wait

#

nanih

#

Oof ok

pliant needle
#

Will client.user.get("ID") work with @user#1234?

broken elm
#
[ { tags: [],
    url: 'https://tenor.com/rtUw.gif',
    media: [ [Object] ],
    created: '4/05/2015 - 13:07:18 PM',
    shares: 1,
    itemurl: 'https://tenor.com/view/anime-hug-gif-4127486',
    composite: null,
    hasaudio: false,
    title: 'hug',
    id: '4127486',
    created_stamp: 1430759238.705985 } ]
#

i get this response

#

from a tenor api

#

how do i access it

#

its inside of an array

#

but there isnt anything to do

#

with the array to get the values

buoyant wagon
#

Earth no it would not

pliant needle
#

Thought so

buoyant wagon
#

also its client.users.get("ID") not client.user.get("ID")

pliant needle
#

That's fine with me, I need it to DM me and I already have my client id

#

Oops, left out the s

buoyant wagon
#

you can however do

#

wait no

broken elm
#

nvm

#

i think i got it

broken elm
#

i got it

#

doesn’t work though

#

tenor shortens the links do their response

#

so it won’t work in embeds

earnest phoenix
#

which perm handles role assignment?

inner jewel
#

manage roles

earnest phoenix
#

thx babe

#
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {

        if(msg.content.startsWith("//inrole")){
    onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");
    onlineMembers.forEach(element => {

            if(element.roles.find(r => r.name === "Server Bots")){
    
            }
           


    

    });




}
      




});```
#

Alright, I'm super new to this so your going to need to have some patience with me.

buoyant wagon
#

hmm

earnest phoenix
#

In my forEach loop, how would I wait a set amount of time before running the next one?

#

So it would go:

action on user 1 -> (wait 10 seconds) action on user 2

#

Rather than:

action on user 1 and action on user 2 at the same time?

buoyant wagon
#

setTimeout()?

earnest phoenix
#

Where would I incorporate that?

#

Can I do that on a forEach loop?

buoyant wagon
#

no, but you can use a for loop instead

earnest phoenix
#
    setTimeout(function(){
        console.log(i);
    }, 10000)
}```
buoyant wagon
#

yes

earnest phoenix
#

Cool/.

buoyant wagon
#

onlineMembers is not defined?

earnest phoenix
#

it is

buoyant wagon
#

ok

earnest phoenix
buoyant wagon
#

well dnd and idle kind of count as online

earnest phoenix
#

mhm

#
            for(var i = 0; i < onlineMembers.length; i++){
                setTimeout(function(){
                    console.log(i);
                }, 10000)
            }```
#

n ot .size

#

.length

#

yeah?

#

@buoyant wagon Still doesn't work...

#

nothing being done

buoyant wagon
#

hmm

#

oh

earnest phoenix
#
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {

        if(msg.content.startsWith("//inrole")){
    onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");

            for(var i = 0; i < onlineMembers.length; i++){
                setTimeout(function(){
console.log(onlineMembers[i])
                }, 100)
            }


    





}
      




});```
buoyant wagon
#
onlineMembers = msg.guild.members.filter(member => member.user.presence.status === "online");
earnest phoenix
#

??

#

??????

#

it should be getting them

#

it does do it

#

🤔

buoyant wagon
#

should start with let or var

#

does it log an error

earnest phoenix
#

no

#
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {

        if(msg.content.startsWith("//inrole")){
   const onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");
            for(var i = 0; i < onlineMembers.length; i++){
                setTimeout(function(){
console.log(onlineMembers[i])
                }, 100)
            }


    





}
      




});```
#

oh waiyt

#

lemme try

#

something

buoyant wagon
#

and use .filter.array() not .filter

#

.filterArray is deprecated

earnest phoenix
#

Still doesn't work anyway.

buoyant wagon
#

hmm

#

does it log anything

earnest phoenix
#

no

buoyant wagon
#
onlineMembers.forEach((element, index) => {
    setTimeout(
            if(element.roles.find(r => r.name === "Server Bots")){console.log(element)}
    }, (index + 1) * 10000);
}```
#

hmm

earnest phoenix
buoyant wagon
#

whoops

#
onlineMembers.forEach((element, index) => {
    setTimeout({
            if(element.roles.find(r => r.name === "Server Bots") !== null){console.log(element)}
    }, (index + 1) * 10000);
}```
#

is there any online members with a role of "server bots"?

#

dnd and idle dont count here

earnest phoenix
#

yes

buoyant wagon
#

whoops again

earnest phoenix
#

not with edit either

buoyant wagon
#
onlineMembers.forEach((element, index) => {
    setTimeout(() => {
            if(element.roles.find(r => r.name === "Server Bots") !== null){console.log(element)}
    }, (index + 1) * 10000);
}```
#

also use .filter now

earnest phoenix
buoyant wagon
#

line 30?

earnest phoenix
#

It only starts when your code goes in

buoyant wagon
#

then delete the last } ?

earnest phoenix
#

I'll try it in the mornijgm

#

I just went off

#

Sorry

delicate zephyr
#

To change your background:

body {
    background-image: url('https://url-to-you-image.com/example.png')
}
#

Inside of <style> tag

earnest phoenix
#

okay

delicate zephyr
#

change that url to an imge link EG: Imgur

earnest phoenix
#

the link

#

??

delicate zephyr
earnest phoenix
#

okay

#

i'm understand

#

thanks you so much

#

i'm like you

earnest phoenix
#

@buoyant wagon still runs right away

#

😐

#
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {

        if(msg.content.startsWith("//inrole")){
    onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");


    onlineMembers.forEach((element, index) => {
      setTimeout(() => {
              if(element.roles.find(r => r.name === "Server Bots") !== null){console.log(element.id)}
      }, (index + 1) * 100000);
  })
    




 






}
      




});```
#

Should have a huge delay...

mossy vine
#

okay first of all, wtf is that indentation

earnest phoenix
#

UHHHHHHH

#

😉

mossy vine
#

whats index in the foreach?

earnest phoenix
#

It would be the number it's on, right?

#

@mossy vine

mossy vine
#

just console.log it

earnest phoenix
mossy vine
#

gohst ping

#

and yeah

#

that was expected

#

the number is too large

#

so its set to 1 ms

earnest phoenix
#

Set index to 1 ms?

mossy vine
#

no

#

what

#

do you even understand how setTimeout works

earnest phoenix
#

oh wait nvm

#

your saying

#

that index will be 1 ms

#

lol

mossy vine
#

no

earnest phoenix
#

🤔

mossy vine
#

the 2nd parameter of the setTimeout is too big, so it is automatically set to 1

earnest phoenix
#

yeah thats what i just said

#

wut

#

ok so i dont need that

#
    onlineMembers.forEach((element, index) => {
      setTimeout(() => {
          console.log(index)
              if(element.roles.find(r => r.name === "Server Bots") !== null){console.log(element.id)}
      }, 100000);
  })```
#

can i just do that?

mossy vine
#

yeah that should work

earnest phoenix
#

//inrole

#

It console.logs ALL of them at the same time after the timeout is over.

#

I want it so it would go one then the other after timeout

quartz kindle
#

Thats not how you do that

earnest phoenix
#

😐 link docs

quartz kindle
#

The foreach loop loops at nornal speed and creates all the set timeouts instantly

#

So all settimeouts get executed at once after the timeout passes

earnest phoenix
#

So which kind of loop

#

can I use?

quartz kindle
#

You can do a bunch of different things

#

You can make your settimeout timer a multiple of the loop index, so first loop timeout is 10000, second loop is 20000, etc

#

This will create an equal time intedval

#

Another option is to use recursive functions

#

A function that calls itself when it finishes

#

This would make it go in order and could be configured with a timer too

#

Another option is ti create a promise and use async await

#

Then you just await it inside the normal foreach loop

earnest phoenix
#
    onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");

var intm = 5000;
    onlineMembers.forEach((element, index) => {
      setTimeout(() => {
              if(element.roles.find(r => r.name === "Server Bots") !== null){
                  console.log(element.id)
                               
                                var intm = intm * 2 
              }
      }, intm);
  })
    




 






}```
#

Yeah?

quartz kindle
#

Idk if that would work, its better if you do js (index+1)*5000

earnest phoenix
#

I had that....

#

it went instantly

quartz kindle
#

How did you do it?

earnest phoenix
#
    onlineMembers.forEach((element, index) => {
      setTimeout(() => {
              if(element.roles.find(r => r.name === "Server Bots") !== null){
                  console.log(element.id)
                               
              }
      }, (index+1)*5000);
  })
    ```
quartz kindle
#

Hmm that should work

earnest phoenix
#

let me try again

#

uhh

quartz kindle
#

How big is that array?

earnest phoenix
#

huge

#

lol

quartz kindle
#

Lol

#

Wait.. What are you even trying to accomplish?

earnest phoenix
#

dming a certain role for a giveaway thing, but it releases the winners a certain time apart

quartz kindle
#

Whg dont you dm only the winners?

earnest phoenix
#

it checks if they are in the role

#

just like the winners

#

are in a role

#

so

#

it checks if they are

quartz kindle
#

Then invert it

#

Check if they have the role first

earnest phoenix
#

where

#

o.o

quartz kindle
#

Then if they have, fire the set tinmeout

#

And you should keep a separate value for keeping track of winners

earnest phoenix
#

    onlineMembers.forEach((element, index) => {
      setTimeout(() => {
              if(element.roles.find(r => r.name === "Server Bots") !== null){
                  console.log(element.id)
                               
              }
      }, (index+1)*5000);
  })
    
    ```
quartz kindle
#

Or even filter the array

earnest phoenix
#

i cant cuz i cant get element

#

first

#

lol

quartz kindle
#

No

earnest phoenix
#

?

quartz kindle
#

Onlinemembers.foreach
If element.roles.find

earnest phoenix
#

Oh

#

K

#

Thx

quartz kindle
#

But then yoh have to create a separate value

#

To keep track of winners

earnest phoenix
#

Mhm

quartz kindle
#

For example, a counter

earnest phoenix
#

I'll just add them to another array

quartz kindle
#

Let counter = 1
If winner settineout (counter++)*5000

earnest phoenix
#
    onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");

var people = [];


    onlineMembers.forEach((element, index) => {
                    if(element.roles.find(r => r.name === "Server Bots") !== null){  people.push(element.id);}
    onlineMembers.forEach((element, index1) => {

      setTimeout(() => {
          console.log(element)
      }, (index1 + 1) * 100000);
  })
    




 
})





}```
#

ye?

#

@quartz kindle

quartz kindle
#

No, if youre doing that way, then you have to loop over people

#

So people.foreach

earnest phoenix
#
    onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");

var people = [];


    onlineMembers.forEach((element, index) => {
                    if(element.roles.find(r => r.name === "Server Bots") !== null){  people.push(element.id);}
    people.forEach((element, index1) => {

      setTimeout(() => {
          console.log(element)
      }, (index1 + 1) * 100000);
  })
    




 
})





}```
#

Oh yeah, whoops.

quartz kindle
#

Yeah you can try that

earnest phoenix
#

oki

#

//inrole

lament meteor
#

why do you not want to run it instantly?

quartz kindle
#

Hes dming people

earnest phoenix
#

yes, i want a delay between winners being announced

lament meteor
#

how much people is he gonna dm?

#

1k?

earnest phoenix
#

no lol

#

@quartz kindle it outputs the ids like 100000 times

#

but i think it has a delay 😐

#
    onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");

var people = [];


    onlineMembers.forEach((element, index) => {
                    if(element.roles.find(r => r.name === "Server Bots") !== null){  people.push(element.id);}
    people.forEach((element, index1) => {

      setTimeout(() => {
          console.log(element)
      }, (index1 + 1) * 5000);
  })
    




 
})





}```
#

Also, do you want some money for ur help

#

ik uve been putting up with me

#

for a while

lament meteor
#

uh why are you doing a forEach in a forEach?

#

also try to do this
```js
code
```

earnest phoenix
#

        if(msg.content.startsWith("//inrole")){
    onlineMembers = msg.guild.members.filter(member => member.presence.status === "online");

var people = [];


    onlineMembers.forEach((element, index) => {
                    if(element.roles.find(r => r.name === "Server Bots") !== null){  people.push(element.id);}

    




 
})


    people.forEach((element, index1) => {

      setTimeout(() => {
          console.log(element)
      }, (index1 + 1) * 5000);
  })


}```
quartz kindle
#

yeah your foreach was inside the other one, they should be separate

earnest phoenix
#

kk

#

it should work now 😄

#

thanks timmy

fiery stream
#

Umm

earnest phoenix
#

can anyone help

#

i have my prefixes being saved into the mongoDB but when i change the prefix it changes all 675 prefix

mossy vine
#

you can change one at once

earnest phoenix
#

yeah i have custom prefixes

#

but its something about my index code or my prefix code

#

when i change the prefix with the command it changes for all 675 servers that my bot is in

#

and its confusing me i think i may have missed a bit off of the codes but i keep looking at it and it seems fine

fiery stream
#

Its easy

earnest phoenix
#

may you assist me please

fiery stream
#

Are u using enmap

earnest phoenix
#

mongoDB

fiery stream
#

Or mongoose

#

The nodejs provider

earnest phoenix
#

i use mongoose for nodejs

fiery stream
#

Ohh

#

Lemme see the part of code where u set it

earnest phoenix
#

may i send on dm?

amber fractal
#

Use findOneAndUpdate or updateOne

earnest phoenix
#

i have findone

amber fractal
#

You're most likely doing a bulk modification still

#

If it changes everything

cold niche
#

what type of db would you use to log economy transactions?

#

my bot has a virtual currency which you can send to someone else and I want these actions to be logged

#

that's fine, I'd go with postgres

#

however I want them to also expire after 30 days

#
  • if the data source supports grafana, that'd be a big plus
strange trout
#

Yes

cold niche
#

guess I'll go with redis 😋

spring ember
#

@cold niche redis is bad for transactions

#

it's like the 1 thing redis is bad for

cold niche
#

well

#

ended up using postgres

spring ember
#

that's good

#

I use postgres for everything

cold niche
#

I store a column with the date of the transaction

spring ember
#

that's cool

cold niche
#

and have a cronjob which runs every on every 30th day

#

deletes the old records

#

not the best but iunno how to do it better

thorn nexus
#

d.js
can I somehow get the id of all users who are in the voice channel?

mossy vine
#

<VoiceChannel>.members

thorn nexus
#

and how much time was the user in the voice channel?

mossy vine
#

theres the voiceStateUpdate event

#

you can use it to keep track of it

spring nymph
#

This may be simple, but I’d like some help with this, so if anyone could provide an example for this, I’d greatly appreciate it! =]

I’m looking to create a bot that simply takes in the following inputs:

  • Any string of text input_text
  • The ID of a message in another channel #########

And outputs the input text, as well as @’ing the users who reacted to the message ID of the referenced message (any emoji would be preferred, however if it’s easier to only respond to one, I can manage that)

I’m currently using javascript for the bot.

Please let me know if any other information is needed =]

wooden lance
#

Anyone know how I can make people have to vote my bot to use a command? Like, a premium thing? Thanks 😃

quartz kindle
#

use the dbl api

wooden lance
#

thonk I'm a little new to discord.js...so, how do I do that? Lol.

quartz kindle
#

on the sidebar, check javascript library

wooden lance
#

Thanks! 😃

thorn nexus
#

d.js Help. How to get the id of all users who are in the voice channel? 😅

mossy vine
#

@thorn nexus i told you already..

thorn nexus
#

I can not. I'm too stupid 😅

mossy vine
#

i literally told you wtf

thorn nexus
#

can someone help by example

mossy vine
#

and even linked the relevant documentation

#

i even gave an example

#

<VoiceChannel>.members

thorn nexus
#

how to check all the channels

opaque eagle
#

What language?

thorn nexus
#

d.js

mossy vine
#

thats not a language

#

but ok

thorn nexus
mossy vine
#

<Guild>.channels

opaque eagle
#

VoiceChannel.members like Cyber said

mossy vine
#

for the channels

opaque eagle
#

iterate through the voice channels in a guild

thorn nexus
#
const guild = bot.guilds.get(g => g.id == "465569108260421633");
console.log(guild.VoiceChannel.members)```
#

😅

mossy vine
#

thats not how .get works

opaque eagle
#

VoiceChannel is a class, not a property of Guild

mossy vine
#

^ and that as well

opaque eagle
#

And yeah Cyber is also right

mossy vine
#

do yourself a favor and read the docs

#
thorn nexus
#

thanks for the help. as I did not guess to read it. If only I understood something there .....

opaque eagle
#

Well JSDoc pages are very detailed on what you can and can't do with them... All the items under the Classes category are classes and all the items under the Typedefs category are typedefs...

#

Idk what can be so confusing about that...

thorn nexus
#

Let's start with, I have 0 knowledge and understanding, if I understood something in the documentation, I would not ask how to do it

mossy vine
#

then learn javascript properly

#

it will make stuff so much easier

opaque eagle
#

If you can't make sense of the docs, that indicates that you don't have adequate knowledge of JavaScript to begin with...

thorn nexus
#

what did I say

opaque eagle
thorn nexus
reef jacinth
#

Can I get some opinions on the css here?

trail dagger
#

Looks Okey

mossy vine
#

i dislike the lack of padding and margins

#

everything is completely fixed to the edges

#

and i personally hate that

reef jacinth
#

I had it more in the center but that looked kinda weird

#

I can try though

mossy vine
#

doesnt need to be in the center

#

just a little padding

trail dagger
#

More on the site

#

fix the padding

wild quest
#

all you need to fix is the image and the join server button and report button just move it more to the right and it should look good.

trail dagger
#

Fix padding

mossy vine
#

and same thing with the table

trail dagger
#

Everything is just on the side

wild quest
#

yeah 😉

reef jacinth
#

What do you suggest the padding to be at?

#

For the table for example

#

@mossy vine

mossy vine
#

2 potatoes

reef jacinth
#

aite

mossy vine
#

is it possible with Eris to get the client ping?

opaque eagle
#

Shard.latency @mossy vine

mossy vine
#

I assume that doesnt work if my bot isnt sharded? @opaque eagle

opaque eagle
#

Every guild is always on a shard

#

If you're not sharding, it's just considered shard 0

mossy vine
#

Oh

#

Ill try that, thanks

opaque eagle
#

So if you have a guild, for example, you can go Guild.shard.latency

#

If I'm running a Docker container based on an alpine image, what dependencies do I need to run node-canvas? This is my current Dockerfile: ```Dockerfile
FROM node:12-alpine

WORKDIR /usr/src/app
COPY package.json yarn.lock ./

ENV NODE_ENV=production
RUN apk add --update
&& apk add --no-cache --virtual .build git curl build-base python g++ make cairo-dev jpeg-dev pango-dev giflib-dev
&& yarn install --pure-lockfile
&& apk del .build

COPY . .
CMD ["yarn", "start"]```

valid frigate
#

low key random question, i've heard about internal sharding for djs but i'm not sure how to set it up

opaque eagle
bright spear
#

@valid frigate

  1. You need to be on v12/master branch
  2. Set shardCount: 'auto' in clientOptions
valid frigate
#

Cool thanks

#

Oh yeah, also is internal shading preferred or should I share using the shading manager

bright spear
#

You can do either one, they're different

#

Internal sharding makes it all in one process

valid frigate
#

And sharing spawns multiple processes

#

sharding

#

Oh I see

bright spear
#

Sharding manager makes one process per shard yeah

#

It's easier to code with internal sharding because it acts as one shard

#

There's one shared client

valid frigate
#

That's why I was gonna try it out tbh

bright spear
#

Yeah imo internal is better

valid frigate
#

Best part is you dont need to broadcast an eval to all the other clients

#

But yeah thanks

#

There's like no documentation on this stuff yet

bright spear
#

It is documented a bit

#

But you need to use master docs

valid frigate
#

Most of internal sharding is only referenced on github issues iirc

bright spear
#

Nah it's in docs

#

The client options and the websocketshard stuff

valid frigate
#

Oh yeah lmao

#

I think I misworded that, tutorials on how to do it

opaque eagle
#

I really like partials in Discord.js v12

#

They're so cool

shy rose
#

anyone know/recommend a crash course on react thats <2 hours

earnest phoenix
#

Internal Sharding can only scale a certain amount of guilds due to the single threaded nature of Node.js, @valid frigate

#

So do keep that in mind if you plan to support a bigger bot

valid frigate
#

interesting

#

multiple processes seems more efficient in handling a large amount of guilds compared to a single process

earnest phoenix
#

For sure

valid frigate
#

if i were to spawn a mongodb client for each process, having multiple process would mean multiple clients i presume

robust acorn
#

hello, how do I make a text that is able to be clicked on for a url?

buoyant wagon
#

its a link

#
[DisplayText](Link)
#

it only works in embeds as descriptions or in a field

robust acorn
#

yeah i just found that out

#

thanks

#

wait only in embeds?

#

ok got it

raw wharf
#

How to delete a role or user within the permissions of a channel? thonkku (discord.js)

lament meteor
#

delete a user?

smoky spire
#

PermissionOverwrites#delete() @raw wharf

harsh dagger
#
Bot.on("message", async message => {
  if(message.author.bot) return;
  if(message.channel.type === "dm") return;
  if(message.isMentioned(bot.users.get("561968604334260244"))){
    message.channel.send("If you need me my prefix is ``c!``")

Problem: I get an error

slender thistle
#

Bot.users

#

Not bot.users

harsh dagger
#

oh

#

still error

slender thistle
#

Well maybe post the error instead of saying that you are getting an error?

slender thistle
#

That doesn't tell me anything

harsh dagger
#

the error is bc of the code

#

oh nvm fixed it

pallid zinc
#

You are having ) extra or you need one more

earnest phoenix
#

Error at serverinfo executed at Discord Bot List:

    at guild.client.setTimeout (/root/jb8/node_modules/discord.js/src/stores/GuildMemberStore.js:223:16)
    at Timeout.setTimeout [as _onTimeout] (/root/jb8/node_modules/discord.js/src/client/BaseClient.js:83:7)
    at listOnTimeout (internal/timers.js:535:17)
    at processTimers (internal/timers.js:479:7)```

Good job discord 😂
mossy vine
#

thats not even coming from dblapi.js

earnest phoenix
#

Ik?

mossy vine
#

then why are you mentioning dbl

earnest phoenix
#

Because you should read

#

Its the error logging from my bot

#

The command serverinfo

#

I never said dblapi.js

mossy vine
#

okay well dbl is still irrelevant
whats the code that gives the error?

earnest phoenix
#

Its fetching members

#

Discord just didnt give my bot the members in time lol

mint cradle
#

Is it needed to shard a bot? If the answer is yes, from what server count?

slender thistle
#

1000 is recommended and 2500 is required

#

You can shard your bot anytime

mint cradle
#

Thanks for answering

#

I'm close to 1000

#

What if with 2500

#

I still don't shard?

slender thistle
#

Discord will refuse to allow any connections from your bot from what I've heard

mint cradle
#

Aha

#

I can't find a guide how to shard

#

Is there one on this server

#

I don't even know what it is

#

But I heard some people do it

slender thistle
#

Never seen one RenShrugGif

mint cradle
#

But they use JS

slender thistle
#

Google might help

mint cradle
#

I googled

#

There is no guide

slender thistle
#

rip

quiet topaz
#

how can i do it, that the output of my discord.js bot isn't with the userid like for example Es ist 406447103964086282,@huz17! ?

#

ping me

opaque eagle
#

@mint cradle

sudden owl
#

I'm running the discordpy rewrite branch and having issues with DBL voting webhooks. I have setup DBL with the tokens and auth correctly and perform a curl e.g. curl --data '{"test": "test"}' -H 'Authorization: <auth>' localhost:5000/dblwebhook -v which returns 200 OK but see nothing in my on_dbl_vote which is just print(data) anyone know if something special has to be done on the rewrite branch?

#

setup exactly as stated in the README.md for dbl python lib

slender thistle
#

No errors?

sudden owl
#

nope

#

ah weird, I just shutdown the process then all the events fired

slender thistle
sudden owl
#

oh my bad I think this was my logging

#

changed to using logger module and now it's printing immediately

#

must have been buffered for some reason 😕

slender thistle
#

Probably ThinkShrug

mint cradle
#

@opaque eagle
Thank you for sending a guide but I'm not using discord.js, I use discord.py.

#

Python is best

slender thistle
#

You can use AutoShardedClient/Bot

glacial pecan
late hill
#

it's just ../methods

glacial pecan
lament meteor
#

don't have the / at the end

late hill
#

bruh.

#

../methods

#

has 2 dots

glacial pecan
late hill
#

Yours has 1

#

ok

glacial pecan
#

did not work

hybrid oasis
#

that's not a good pattern, imo

#

import things when you need them and be explicit

mossy vine
#

fs.readdirSync(`${__dirname}/../methods`)

#

fs is fucking weird and likes to start at directory you execute node in

late hill
#

o

#

forgot

glacial pecan
#
const fs = require('fs');

let methodDir = '../methods';
let methods = fs.readdirSync(methodDir);
for (let method of methods) {
  exports[method.replace('.js', '')] = require(methodDir, method);
}

the code is this,How can I arrange it?

opaque eagle
#

What?

#

Wdym by “arrange” it

glacial pecan
#

Sorry, i'm brazilian this message comes from google

opaque eagle
#

What do u want to do with it?

#

Like be descriptive

mossy vine
#

i literally sent you the code to fix it

opaque eagle
#

What does he want to do with it? @mossy vine

mossy vine
#

no clue

opaque eagle
#

Lmao

glacial pecan
#

I want this command to find the folder

opaque eagle
#

And then...

glacial pecan
#

solve the problem

opaque eagle
#

What is the problem

glacial pecan
#

Do not find the folder "methods"

opaque eagle
#

Does that folder exist?

mossy vine
#

it does

#

i sent you the code to fix it

glacial pecan
#

yes

#

ok

late hill
#

what's require with 2 arguments do

opaque eagle
#

Nothing, I believe

ruby dust
#

if I'm gonna import one file into a lot of files, will it mean that it will read it's code that many times or just once?

hybrid oasis
#

if you mean in node, and you mean import or require, it caches the import. so once

slender thistle
#

I bet Python does that too

unique nimbus
#

most likely

hybrid oasis
#

it's honestly something nobody should worry about

#

just because the platform handles it for you

ruby dust
#

Yeah, unless you have an infinite loop that you don't want to start a lot of times accidentally

hybrid oasis
#

I mean, if that was the case you could just verify it wasn't started a lot of times

#

which you probably want to do. or export a function that starts it, so importing it has no side effects

grizzled spruce
#

So I have been using a .json file as the storage for custom prefixes on my bot, but it’s rather flakey. Anyone know any files that would make better storage? I use d.js

mossy vine
#

use an actual database

#

sqlite or mongodb are the most popular ones afaik

grizzled spruce
#

Hmm

#

I shall look into it

hybrid oasis
#

mongodb is usable, but I'd recommend sqlite since its a more transferrable skill and helps you not shoot yourself in the foot

exotic badger
#

or learn mongoDB properly and don't shoot yourself in the foot

mossy vine
#

then again sql is way easier to abuse

#

so you gotta be careful about your security

hybrid oasis
#

knowing mongodb isn't the problem, mongodb is the problem

mossy vine
#

elaborate thonkku

hybrid oasis
#

it's unstructured, so you have to be super diligent when you change your "schema"

zealous veldt
#

I would argue that knowing something like Mongo is a lot more useful in the industry than SQLite

hybrid oasis
#

otherwise you end up with records that have the same data in many different formats which leads to gross conditional code, etc.

exotic badger
#

its called flexibility, it lets you decide how you store your data and in what structure

hybrid oasis
#

strong disagree, sqlite is easily transferrable to mysql/postgres which has way more use than mongo

#

its called flexibility, it lets you decide how you store your data and in what structure
if you need that, you can use a jsonb column in postgres for example

scarlet phoenix
#

SQL > NoSQL for most use cases, imo. I do understand that noSQL is good as well, but in terms of personal preference. Relational data is much more safe, especially when you scale.

hybrid oasis
#

but otherwise that flexibility will burn you

#

what kikkia said

#

for a discord bot it probably doesnt matter

zealous veldt
#

Mongo is also scalable

hybrid oasis
#

but if you want your bot to be more stable or learn a skill thats more wildly used sqlite is better if comparing just those two

scarlet phoenix
#

Yes, I mean in conceptual senses not performance

hybrid oasis
#

yeah, you can scale mongo but it has significantly more problems scaling

zealous veldt
#

More and more companies and moving to managed databases such a mongo

hybrid oasis
#

that was true maybe 2 years ago

zealous veldt
#

NoSQL is growing rapidly

scarlet phoenix
#

For example, I work at a company with tons of different dbs. Many SQL and many NoSQL. I would much rather work with SQL when its somewhere I do not touch frequently

#

In the same sense that I like languages with strict typing more.

slender thistle
#

When changing machines:
Mongo documents -> convert into sqlite -> upload the file on another machine -> put sqlite data in mongo

#

:^)

zealous veldt
#

Gotem

hybrid oasis
#

agreed with kikkia again. ive worked with real world mongo databases and dear god what a nightmare it can be

scarlet phoenix
#

Mongo is good, fast and easy to learn, But having strict relationships imo is extremely nice

hybrid oasis
#

^

#

there's a lot of companies moving away from mongo to mysql/postgres, etc. but basically 0 moving away from mysql/postgres TO mongo

#

which I guess is from teams starting a new project with mongo, realizing the pitfalls, then going back

scarlet phoenix
#

If you know what your doing mongo is good, but I do not trust myself to not be lazy, also when it comes to working with multiple devs on on db. Without proper communication it can become a nightmare.

#

That being said, I use mongo frequently for very small projects

#

I like it

zealous veldt
#

Each has their use cases, I do however personally prefer managed NoSQL databases like Mongo or RethinkDB (rip)

hybrid oasis
#

which is fine as a personal choice

zealous veldt
#

Yeah

spring ember
#

@hybrid oasis this is blatant lies

#

MongoDB is popular for it's own thing

#

they don't really have a thing that's why big companies find it hard to choose mongo

hybrid oasis
#

if you're going to call something out as a blatant lie I'd expect a bit more substance to your argument

spring ember
#

it's not correct that companies are moving

#

companies almost never move databases because they need to move their data

#

Twitter still uses MySQL

hybrid oasis
#

which is why it's impressive that so many companies are moving away from mongo

#

what do you mean still uses mysql?

spring ember
#

by many you mean what other than Discord

hybrid oasis
#

it's a solid, tried and true database that's actively developed and maintained

spring ember
#

MySQL is kinda old and outdated

#

MariaDB is the best replacement

hybrid oasis
#

now you're just repeating blog spam

#

mysql published a new major version (8) a year ago

#

and pushed up a new minor version literally last month

hushed berry
#

lmfao

slate kayak
#

hello any help with this error please its an fs error

late hill
#

show code

slate kayak
#
 fs.readdir('./commands/', (err, categories) => {
        if (err) console.log(err);
        console.log(`Found total ${categories.length} category.`);
        categories.forEach(category => {
            fs.readdir(`./commands/${category}`, (err, files) => {
                console.log(`Found total ${files.length} command from ${category}.`)
                if (err) console.log(err);
                let commands = new Array();
                files.forEach(file => {
                    //delete require.cache[require.resolve(`./commands/${category}/${file}`)];
                    if (!file.endsWith('.js')) return;
                    let prop = require(`./commands/${category}/${file}`);
                    let cmdName = file.split('.')[0];
                   bot.commands.set(cmdName, prop)
                })
            })
        })
    })
#

@late hill

late hill
#

@hybrid oasis what are your sources behind this so many companies are moving away from mongo

slate kayak
#

thats where the error is

hybrid oasis
#

@late hill various blog posts I've read over the years of company X saying we're moving off of mongodb

slate kayak
#

@late hill do you see anything wrong with that fs code ??

late hill
#

I mean

#

Your console logs that you have 155 categories

#

so that's probably wrong

torn compass
#

Hi

#

at Client.module.exports.message (/app/events/message.js:16:22)

    at emitOne (events.js:121:20)

    at Client.emit (events.js:211:7)

    at MessageCreateHandler.handle (/rbd/pnpm-volume/5fdf3fb2-244c-4354-beca-f97a71579d8a/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)

    at WebSocketPacketManager.handle (/rbd/pnpm-volume/5fdf3fb2-244c-4354-beca-f97a71579d8a/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)

    at WebSocketConnection.onPacket (/rbd/pnpm-volume/5fdf3fb2-244c-4354-beca-f97a71579d8a/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)

    at WebSocketConnection.onMessage (/rbd/pnpm-volume/5fdf3fb2-244c-4354-beca-f97a71579d8a/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)

    at WebSocket.onMessage (/rbd/pnpm-volume/5fdf3fb2-244c-4354-beca-f97a71579d8a/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/event-target.js:120:16)

    at emitOne (events.js:116:13)

    at WebSocket.emit (events.js:211:7)```
#

What is the solution

mossy vine
#

because its literally not a function

amber fractal
#

client.elevation is not a function

#

What he said

mossy vine
#

theres nothing similar to it

amber fractal
#

You'd have to define it

torn compass
#

Well, thanks a lot

earnest phoenix
#

Hey so my friend invited my bot to his server but for some reason the bot command dont work there

west spoke
#

Any error?

#

And what lang do you use

earnest phoenix
#

why does my bot always after some amount of time do throw error; ?

unique nimbus
#

what error is it

earnest phoenix
#

Bot has started, with 620 users, in 242 channels of 9 guilds.
(node:17020) DeprecationWarning: Collection#filterArray: use Collection#filter instead
events.js:180
throw err; // Unhandled 'error' event
^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
at CommandoClient.emit (events.js:178:17)
at WebSocketConnection.onError (C:\Users\plane\Desktop\Pepsi_Man\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:374:17)
at WebSocket.onError (C:\Users\plane\Desktop\Pepsi_Man\node_modules\ws\lib\event-target.js:128:16)
at WebSocket.emit (events.js:189:13)
at _receiver.cleanup (C:\Users\plane\Desktop\Pepsi_Man\node_modules\ws\lib\websocket.js:211:14)
at Receiver.cleanup (C:\Users\plane\Desktop\Pepsi_Man\node_modules\ws\lib\receiver.js:557:13)
at WebSocket.finalize (C:\Users\plane\Desktop\Pepsi_Man\node_modules\ws\lib\websocket.js:206:20)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
[nodemon] app crashed - waiting for file changes before starting...

amber fractal
#

Thats a deprecation warning

#

Check the docs

earnest phoenix
#

ok

amber fractal
#

filterArray is deprecated

ruby talon
#

Anyone formiliar with PostgreSQL?

#

(And python)

earnest phoenix
#

Why is not fonctionnaly ?

var nom = args.join(' ');
	if (!args.join(' ')) return ("Veuillez préciser un nom de salon textuel.");

If I do the command without args behind it says nothing

#

I watched the doc huh

#

@amber fractal filterarray is nowhere in my code

#

thin I opened the message channel send

#

I'm stubborn!

amber fractal
#

You use commando it says?

earnest phoenix
#

yes

slender thistle
ruby talon
#

Ty.

slender thistle
#

dpy server especially has a few Postgre users

ruby talon
#

♥♥

pliant needle
#

My first lang was py

#

But I'm new to postgres

#

So I'm no help there

amber fractal
#

Well that error comes from something using filterArray

slate kayak
amber fractal
#

Possibly in commando somewhere

slender thistle
#

The hell is that API even

slate kayak
#

youtube

earnest phoenix
#

but

#

why did it crashed if it was a warning

slender thistle
#

idk, never worked with YT API

pliant needle
#

@slate kayak what lang you using?

slender thistle
#

That looks like js

pliant needle
#

Thought so

#

npm i youtube-search or npm i discord.js-lavalink

inner jewel
#

first if you want youtube-search, second if you want lavalink for discord.js

slate kayak
#

d.js @pliant needle but have fixed it thank you for the reach to me 😃

#

well @inner jewel im still learning lavaling because i want my music part to have it on

wraith cipher
#

shivaco-sensei ?

slender thistle
#

Sup

wraith cipher
#

Hii

#

You're familiar with mongodb right ?

slender thistle
#

Indeed I am

wraith cipher
#

Does pymongo have any issues with dpy/async ?

lament meteor
#

shivaco being called "sensei" 👀 . also it dosn't assasin umz

slender thistle
#

it's blocking, yep

wraith cipher
#

2 answers >.<

slender thistle
#

I mean, it's not too much of a trouble unless you do some heavy shit

#

There's async library for mongo named Motor

wraith cipher
#

Yea I was planin to shift to motor

#

Cause sometimes the update_one func doesn't work

slender thistle
#

How come?

#

Any errors you get?

wraith cipher
#

Usually after sending a message

#

No errors at all

slender thistle
#

Mind trying to reproduce it when possible and send me the code that doesn't work?

wraith cipher
#

Everything just goes fine just that one update_one func doesn't work for some reason but it's not always the case it works in some commands

#

Yea sure I'll send you the code

#

But not rn.... lol

slender thistle
#

No worries

wraith cipher
#

Arigato thank you

slender thistle
grizzled spruce
#

For no apparent reason I want to make a command that does something like this

#

I use discord.js

buoyant wagon
#

client.on

grizzled spruce
#

Anyone know any guides for this type of thing...?

ruby dust
#

you mean embed images?

grizzled spruce
#

Nono I mean logging when users change their avatar

ruby dust
#

pretty sure that falls under general member update event

grizzled spruce
#

Aight

#

Do you know a source that would guide me to this...?

zealous veldt
#

Look at the discord js docs

flint trellis
#

Wrong

#

guildMemberUpdate is not emitted on an avatar change

#

you would have to look at userUpdate

#

but if you planned on sending a log message, you have to loop through all your client guilds and check if the user is in that guild

zealous veldt
#

Yeah that's kinda yikes

grizzled spruce
#

module.exports.run = async (bot, message, args) => {
  let bicon = bot.user.displayAvatarURL
  let botembed = new Discord.RichEmbed()
  .setColor("#1134e0")
  .setTitle("Invite Here!")
  .setURL('https://discordbots.org/bot/552197229323091970')
  .setImage(bicon)
  .setFooter('© ₦anø#8550 2019', bot.user.displayAvatarURL);
  return message.channel.send(botembed);
 
}

module.exports.help = {
  name: "invite"
}```
#

How would I change this so it sends in the users DM channel

amber fractal
#

Send to the person and not the channel