#development
1 messages · Page 613 of 1
.name returns the username of the user
wait
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.```
lol it doesn;t even return the username
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")```
Is that command in a class
nope
it is not in a class
this is discord.py==0.16.12
I had trouble converting everything to rewrite
pass_context=True in command decorator
Correct
same error

Looks like a JSON inside an array inside a JSON
It never runs the script, it does not print
{ 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
Because that JSON is in an array
How do you get a first element from an array
@lofty hamlet yeah that actually seems like a fair offer
@robust acorn What's up with the command
my command does not run
not get the first object
i tried printing
DankTech, literally nothing printed? No errors?
how do i get the rest.... i wouldn't know jow to get the SECOND type: object also
never used a json response before
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
use a command cooldown
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
You have a good heberger for a discord bot ? Or OVH
Hell, I'm not even sure if 1.0.0 would apply here since I don't remember using cmd extension much in async
did you pass ctx ?
My heberger stop activity
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....
pass_context should be in the decorator
Decorator, not the function
whats that?
and its not contect
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
and just format the user id
wait it's async right
You don't have a shortcut, so use ctx.message.author
can we use f strings in py 3.6.1 ?
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
heeaader = token
Nope
my keyboard is terrible
It's a dict where Authorization is the key and your bot's DBL token is the value
Yep
the api key...
Copy the API key, put it as a value for Authorization key inside a dict
umm, can you help me?
What's up
Im not sure what you mean
by putting value for authen key inside a dict
do I have to make a dict?
Yep
and how do I do that?
{}
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
yeah I just did
Except it's Authorization
Not authorization
Oh nevermind, there was an apostrophe already, my bad
yeah, I still had an extra space though lol
Easily fixable
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
{ 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?
Yep
ok
You can now use the json
@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
just res.data[3].url
Should be good, if you are taking fourth element from your array
yes!
thank you!
i've been wanting to learn how to do this for months, i was just lazy lmao
kek
I bet images is an array too so yeah

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
but the problem is, many database do not support 3.6.1
The url was fine before
oh
try mongodb
You would just need another variable with the dict
THATS WHAT I WANTED
mongodb
pymongo
but it does not support 3.6.1
does it?
and downgrading the database seemed like pretty hard
maybe you should solve your reward issue first 😅
what other variable with the dict?
well
to solve the rewards issue
I kind of need a cooldown
which needs a database.....
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")```
If your bot doesn't go down all the time, you can use that decorator
i put the url back
So what's your code looking like atm
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......
btw if I want to make this a cooldown, I can put @earnest phoenix.cooldown in line two?
oops, sorry for the ping
Before async def, yes
ok cool
Just hold on
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
when using session.get(), pass headers=data and rename your dict to data AND reset that API key
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


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?
It raises an error
the cooldown works
also shift to rewrite asap
@earnest phoenix.error
Why am i keep pinging people
``
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
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
yeah
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?
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?
or do i have to start a timer manually
if error is instance of CommandOnCooldown or whatever it was, yeah, use that ^
you can use datetime and modify the output
i figured it out now, i just need to set the padding on the content, not the div itself
ok cool
how does error.retry_after work?
it returns a datetime object
oh
wait ig it returns the amount of seconds left
float
hiw many seconds and milliseconds left until the command can be used again
how do i go about setting a webhook vote command with discord.py
guys
dblpy client has some webhook settings that might help
if(message.author.Bot) return;
if(message.channel.type === "dm") return;
``` somehow a bot bypassed this?
ooop
thats what i was trying before, theres a on_dbl_vote but i can find anything that tells me how it works
It's an event that takes a dict as its parameter
yeh but how does it trigger, what settings do i need to trigger it
what exists?
in the github example it has this self.dblpy = dbl.Client(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
You don't trigger it, it triggers itself when someone votes for your bot
You just need to make sure your specified port is open
that would be better for me
dblpy is for 1.0.0 versions unfortunately
how
If it responded to bots, it would have sent 4 messages instead of 1
it responded to you telling it to tell it to say
hi
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
index 38 doesnt exist
most likely
console.log(res.data, res.data.length) and check
Will client.user.get("ID") work with @user#1234?
[ { 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
Earth no it would not
Thought so
also its client.users.get("ID") not client.user.get("ID")
That's fine with me, I need it to DM me and I already have my client id
Oops, left out the s
i got it
doesn’t work though
tenor shortens the links do their response
so it won’t work in embeds
which perm handles role assignment?
manage roles
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.
hmm
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?
setTimeout()?
no, but you can use a for loop instead
setTimeout(function(){
console.log(i);
}, 10000)
}```
yes
Cool/.
onlineMembers is not defined?
it is
ok
well dnd and idle kind of count as online
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
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)
}
}
});```
onlineMembers = msg.guild.members.filter(member => member.user.presence.status === "online");
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
Still doesn't work anyway.
no
onlineMembers.forEach((element, index) => {
setTimeout(
if(element.roles.find(r => r.name === "Server Bots")){console.log(element)}
}, (index + 1) * 10000);
}```
hmm
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
whoops again
not with edit either
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
line 30?
It only starts when your code goes in
then delete the last } ?
To change your background:
body {
background-image: url('https://url-to-you-image.com/example.png')
}
Inside of <style> tag
okay
change that url to an imge link EG: Imgur
@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...
okay first of all, wtf is that indentation
whats index in the foreach?
just console.log it
gohst ping
and yeah
that was expected
the number is too large
so its set to 1 ms
Set index to 1 ms?
no
🤔
the 2nd parameter of the setTimeout is too big, so it is automatically set to 1
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?
yeah that should work
//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
Thats not how you do that
😐 link docs
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
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
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?
Idk if that would work, its better if you do js (index+1)*5000
How did you do it?
onlineMembers.forEach((element, index) => {
setTimeout(() => {
if(element.roles.find(r => r.name === "Server Bots") !== null){
console.log(element.id)
}
}, (index+1)*5000);
})
```
Hmm that should work
How big is that array?
dming a certain role for a giveaway thing, but it releases the winners a certain time apart
Whg dont you dm only the winners?
it checks if they are in the role
just like the winners
are in a role
so
it checks if they are
Then if they have, fire the set tinmeout
And you should keep a separate value for keeping track of winners
onlineMembers.forEach((element, index) => {
setTimeout(() => {
if(element.roles.find(r => r.name === "Server Bots") !== null){
console.log(element.id)
}
}, (index+1)*5000);
})
```
Or even filter the array
No
?
Onlinemembers.foreach
If element.roles.find
Mhm
For example, a counter
I'll just add them to another array
Let counter = 1
If winner settineout (counter++)*5000
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
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.
Yeah you can try that
why do you not want to run it instantly?
Hes dming people
yes, i want a delay between winners being announced
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
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);
})
}```
yeah your foreach was inside the other one, they should be separate
Umm
can anyone help
i have my prefixes being saved into the mongoDB but when i change the prefix it changes all 675 prefix
you can change one at once
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
Its easy
may you assist me please
Are u using enmap
mongoDB
i use mongoose for nodejs
may i send on dm?
Use findOneAndUpdate or updateOne
i have findone
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
Yes
guess I'll go with redis 😋
I store a column with the date of the transaction
that's cool
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
d.js
can I somehow get the id of all users who are in the voice channel?
<VoiceChannel>.members
and how much time was the user in the voice channel?
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 =]
Anyone know how I can make people have to vote my bot to use a command? Like, a premium thing? Thanks 😃
use the dbl api
I'm a little new to discord.js...so, how do I do that? Lol.
on the sidebar, check javascript library
Thanks! 😃
d.js Help. How to get the id of all users who are in the voice channel? 😅
@thorn nexus i told you already..
I can not. I'm too stupid 😅
i literally told you wtf
can someone help by example
and even linked the relevant documentation
i even gave an example
<VoiceChannel>.members
how to check all the channels
What language?
d.js

<Guild>.channels
VoiceChannel.members like Cyber said
for the channels
iterate through the voice channels in a guild
const guild = bot.guilds.get(g => g.id == "465569108260421633");
console.log(guild.VoiceChannel.members)```
😅
thats not how .get works
VoiceChannel is a class, not a property of Guild
^ and that as well
And yeah Cyber is also right
do yourself a favor and read the docs
thanks for the help. as I did not guess to read it. If only I understood something there .....

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...
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
If you can't make sense of the docs, that indicates that you don't have adequate knowledge of JavaScript to begin with...
You're probably looking for this information ---> http://javascript.info/classes

Looks Okey
i dislike the lack of padding and margins
everything is completely fixed to the edges
and i personally hate that
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.
Fix padding
and same thing with the table
Everything is just on the side
yeah 😉
2 potatoes
is it possible with Eris to get the client ping?
Shard.latency @mossy vine
I assume that doesnt work if my bot isnt sharded? @opaque eagle
Every guild is always on a shard
If you're not sharding, it's just considered shard 0
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"]```
low key random question, i've heard about internal sharding for djs but i'm not sure how to set it up
I tried doing yarn add discordapp/erlpack and this happened:
https://gist.github.com/SinistreCyborg/f62478727bab9eabbce3add125050358
@valid frigate
- You need to be on v12/master branch
- Set
shardCount: 'auto'in clientOptions
Cool thanks
Oh yeah, also is internal shading preferred or should I share using the shading manager
You can do either one, they're different
Internal sharding makes it all in one process
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
That's why I was gonna try it out tbh
Yeah imo internal is better
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
Most of internal sharding is only referenced on github issues iirc
anyone know/recommend a crash course on react thats <2 hours
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
interesting
multiple processes seems more efficient in handling a large amount of guilds compared to a single process
For sure
if i were to spawn a mongodb client for each process, having multiple process would mean multiple clients i presume
hello, how do I make a text that is able to be clicked on for a url?
its a link
[DisplayText](Link)
it only works in embeds as descriptions or in a field
How to delete a role or user within the permissions of a channel?
(discord.js)
delete a user?
PermissionOverwrites#delete() @raw wharf
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
Well maybe post the error instead of saying that you are getting an error?
That doesn't tell me anything
You are having ) extra or you need one more
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 😂
thats not even coming from dblapi.js
then why are you mentioning dbl
Because you should read
Its the error logging from my bot
The command serverinfo
I never said dblapi.js
okay well dbl is still irrelevant
whats the code that gives the error?
Is it needed to shard a bot? If the answer is yes, from what server count?
Discord will refuse to allow any connections from your bot from what I've heard
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
Never seen one 
But they use JS
Google might help
rip
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
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
No errors?

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 😕
Probably 
@opaque eagle
Thank you for sending a guide but I'm not using discord.js, I use discord.py.
Python is best
it's just ../methods
@late hill http://prntscr.com/nljtar
don't have the / at the end
did not work
fs.readdirSync(`${__dirname}/../methods`)
fs is fucking weird and likes to start at directory you execute node in
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?
Sorry, i'm brazilian this message comes from google
i literally sent you the code to fix it
What does he want to do with it? @mossy vine
no clue
Lmao
I want this command to find the folder
And then...
solve the problem
What is the problem
Do not find the folder "methods"
Does that folder exist?
what's require with 2 arguments do
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?
if you mean in node, and you mean import or require, it caches the import. so once
I bet Python does that too
most likely
it's honestly something nobody should worry about
just because the platform handles it for you
Yeah, unless you have an infinite loop that you don't want to start a lot of times accidentally
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
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
mongodb is usable, but I'd recommend sqlite since its a more transferrable skill and helps you not shoot yourself in the foot
or learn mongoDB properly and don't shoot yourself in the foot
knowing mongodb isn't the problem, mongodb is the problem
elaborate 
it's unstructured, so you have to be super diligent when you change your "schema"
I would argue that knowing something like Mongo is a lot more useful in the industry than SQLite
otherwise you end up with records that have the same data in many different formats which leads to gross conditional code, etc.
its called flexibility, it lets you decide how you store your data and in what structure
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
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.
but otherwise that flexibility will burn you
what kikkia said
for a discord bot it probably doesnt matter
Mongo is also scalable
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
Yes, I mean in conceptual senses not performance
yeah, you can scale mongo but it has significantly more problems scaling
More and more companies and moving to managed databases such a mongo
that was true maybe 2 years ago
NoSQL is growing rapidly
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.
When changing machines:
Mongo documents -> convert into sqlite -> upload the file on another machine -> put sqlite data in mongo
:^)
Gotem
agreed with kikkia again. ive worked with real world mongo databases and dear god what a nightmare it can be
Mongo is good, fast and easy to learn, But having strict relationships imo is extremely nice
^
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
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
Each has their use cases, I do however personally prefer managed NoSQL databases like Mongo or RethinkDB (rip)
which is fine as a personal choice
Yeah
@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
if you're going to call something out as a blatant lie I'd expect a bit more substance to your argument
it's not correct that companies are moving
companies almost never move databases because they need to move their data
Twitter still uses MySQL
which is why it's impressive that so many companies are moving away from mongo
what do you mean still uses mysql?
by many you mean what other than Discord
it's a solid, tried and true database that's actively developed and maintained
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
lmfao
show code
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
@hybrid oasis what are your sources behind this so many companies are moving away from mongo
thats where the error is
@late hill various blog posts I've read over the years of company X saying we're moving off of mongodb
@late hill do you see anything wrong with that fs code ??
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
because its literally not a function
theres nothing similar to it
You'd have to define it
Well, thanks a lot
Hey so my friend invited my bot to his server but for some reason the bot command dont work there
why does my bot always after some amount of time do throw error; ?
what error is it
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...
ok
filterArray is deprecated
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!
You use commando it says?
yes
@ruby talon Could ask in discord.gg/python or discord.py servers
Ty.
dpy server especially has a few Postgre users
♥♥
Well that error comes from something using filterArray
http://prntscr.com/nlnsbz @slender thistle any idea why im getting this after i have put a new api key ??
Possibly in commando somewhere
The hell is that API even
youtube
idk, never worked with YT API
@slate kayak what lang you using?
That looks like js
first if you want youtube-search, second if you want lavalink for discord.js
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
shivaco-sensei ?
Sup
Indeed I am
Does pymongo have any issues with dpy/async ?
shivaco being called "sensei" 👀 . also it dosn't assasin umz
it's blocking, yep
2 answers >.<
I mean, it's not too much of a trouble unless you do some heavy shit
There's async library for mongo named Motor
Yea I was planin to shift to motor
Cause sometimes the update_one func doesn't work

Mind trying to reproduce it when possible and send me the code that doesn't work?
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
No worries
Arigato thank you

For no apparent reason I want to make a command that does something like this
I use discord.js
client.on
Anyone know any guides for this type of thing...?
you mean embed images?
Nono I mean logging when users change their avatar
pretty sure that falls under general member update event
Look at the discord js docs
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
Yeah that's kinda yikes
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
Send to the person and not the channel

