#development
1 messages · Page 583 of 1
I don't know how. I'll need to read up about it later
buy one
ha, not now
also
SELECT * FROM tablename WHERE userId ="${msg.author.id}"
lets pretend its not a userId and instead something a user can input
like say a custom prefix
ok im not explaining this just look at the links i posted
While we're talking, how do I make a table like this for my blacklists?
| UserID | Reason |
what
Ok. I do have multiple tables and one is for server customization
How I have it now is there is one select statement, and the entire code is wrapped in it. It grabs the custom prefix from the table only once
anyone a pollmaster expert here?
so just a quick question..
I have this very odd thing that I'm not getting
I have this error
but
I don't even really have a code neither packages installed
all I'm running is these few lines
const fs = require('fs');
fs.writeFile('mynewfile3.txt', 'Hello content!', function (err) {
if (err) throw err;
console.log('Saved!');
});
Just tried testing out fs
any idea on why it errors already?
Even with an example from node.js site
guys, I normally use VS Code, but I'd like to try Atom, can you tell me if there's a way to get a debugger like VS Code for Atom? i'm using python
this may be a stupid question
but are you in the right directory?
it is in one directory the main file is preset even running just the select file with node
does the same error
so yes I am
there's just been a handful of times for me where i was wondering why it was erroring only to find out i was down one dir
otherwise i have no clue
yeah its not that this time
aight thanks anyways
anyone else?
really need to learn this whole json thing and when ya try an example already fails like woop woop
Whats the name of your js file?
ok.js
Try running it with node ok.js
Well
Using node . just looks for an index.js file or a startup file defined in your package.json
ok.js was defined as that
It cant magically know what file you want to run
thats why im not getting it
XD
wew wait i get it already
right so my ok.js is in a folder in the main dir
cause I wanted to test if it would create the file in the folder
rather than in the main dir
so I could keep things in order
i see y now
now I just need to figure out how to preset a directory in a bot that the module will use to store the json files and so on
how would you fix this in Debian
I have same problem, build module on Windows
And transfer it with a USB for example
@earnest phoenix
nvm i fixed it
Okay
question, if i want to use webhooks on the bot list to catch votes and stuff. where do i get a url to send the hook to? would that be a url that i have created like a webhost url to catch it? or is there something built into discord to catch those?
The docs are pretty nice, I'd say. Lol.
It sends them to a webserver
That youare listening to
when i read the docs, it didnt say anything about where to get the url for the webhook
What lang do you use
js
You hace the js lib?
OH see i was on the webhook topic
The Cat API is signup, but it is free
ill go read that area, i didnt realize that the topics above pertained to webhooks as well
ok, so i installed the lib. i got the demo code in. generated the webhook token, put that in the connection variable. when the bot connects i get a console log that says Webhook running at http://0.0.0.0:5000/dblwebhook is this correct? it seems like that should at the very least be my ip address that the bot is hosted on?
nvm, it does indeed work when i click "test" on the dbl site
thank you @amber fractal for directing me to the proper area
anyone here knows how to set up docker
i wanna run a batch file inside a docker container whenever its started
^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
at Client.emit (events.js:178:17)
at WebSocketConnection.onError (C:\Users\chill\Desktop\chill\discord-bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:374:17)
at WebSocket.onError (C:\Users\chill\Desktop\chill\discord-bot\node_modules\ws\lib\event-target.js:128:16)
at WebSocket.emit (events.js:189:13)
at WebSocket.finalize (C:\Users\chill\Desktop\chill\discord-bot\node_modules\ws\lib\websocket.js:185:12)
at ClientRequest._req.on (C:\Users\chill\Desktop\chill\discord-bot\node_modules\ws\lib\websocket.js:641:12)
at ClientRequest.emit (events.js:189:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
at TLSSocket.socketOnData (_http_client.js:442:20)```
why do I keep getting that error?
whats your code?
Like from where my bot?
Like on line 180?
Getting it.
nwm found it
i was coding it like just now
it seemed to work
then i died
it
lol
ok
That error is from you losing connection to discord @junior summit
Make sure your vps isn't closing the connection or something
its an error in the code
not the vps
it crashes every time i do the command
but lol anyways thanks
oppf
let date = new Date();
let voteUsername = bot.users.get(vote.user).username
console.log(`User with username ${bot.users.get(vote.user).username} just voted!`);
let voteEmbed = new Discord.RichEmbed()
.setTitle(`${voteUsername} just voted!`)
.addField('ID', vote.user, true)
.addField('Time', date)
.setColor(Math.floor(Math.random() * 16777214) + 1)
bot.channels.get('552674443131093002').send({voteEmbed});``` doesnt work no error pls help
bot.users.get(vote.user).username
return undefined
Well is that with a test?
yes
People dont have to be in a server with your bot to vote
iik
It cant get a user it doesnt know
dbla.webhook.on('vote', vote => {
if (bot.users.get(vote.user) === undefined) {
console.log(`User with id ${vote.user} just voted!`);
} else {
let voteUsername = bot.users.get(vote.user).username
console.log(`User with username ${bot.users.get(vote.user).username} just voted!`);
let voteEmbed = new Discord.RichEmbed()
.setTitle(`${voteUsername} just voted!`)
.addField('ID', vote.user, true)
.setColor(Math.floor(Math.random() * 16777214) + 1)
bot.channels.get('552674443131093002').send({voteEmbed});
}```
this is my code
so if they arent in a server with my bot
it does ID
but it doesnt work
cause I asked my friend to do it and it doesnt show
And did it log anything
You could check for tests with vote.type
ok
Idk if the test id is the same every time
it is
@junior summit add a error handler on your client
client.on('error', console.error)
ok so basically
Im setting const queue into a map as reference, so what will happen to const queue once the map was deleted?
will it get gced or not
this is more on garbage collection stuff
so it doesnt do leaks or something
as long as it's referenced, it won't be GC'd
but after I deleted it on the queue map, the const queue will get out of scope
or am I not?
because the only thing Im referencing to the queue is the map
if the function with it returns, yes
wait will it not reference queue but instead, "copy" the queue ?
unless you explicitly copy, the same object will be used
so on my case, it will just reference queue into the map?
yes
and until the map isnt deleted, the queue will stay in memory?
any changes to it will be seen if you get the value from the map
yes
the map references it
(i'm keeping weak references out of this for simplicity)
Objects are a prototype, they'd point to the same location in memory iirc
but idk if I do
oh ok that made my understanding on it much more better, but in arrays
if you reference it
Im pretty sure it will reference the original array since it points to the same location in memory?
are you familiar with pointers?
in C++ I do hear them a lot
objects and arrays act like pointers (because they are)
so unless you copy the data to a new object/array, it'll still be the same
and any changes will be seen by all code referencing it
it's as if every object/array was just a key in a global map which has their data
so basically
const stuff = 1
const stuff2 = stuff
stuff2 is a reference to stuff ?
so if I modify stuff then stuff2 will be the same ?
yes
but if you modify stuff2, stuff wont change?
I'd like to see you modify a const 
you have something which is the location of the contents
so you just copy the location when you assign it to something
when you access, both point to the same location
so changes to one will be seen by the other
oh I see, so basically referencing means It will just point where is the location of the original variable?
const x = {}
x.a = 1```done @amber fractal

you cant change the x object but you can change the value inside of it 
you can't reassign it
but you can mutate the data in it
which is why const is a wrong name since it's not really a constant
Ow
I see, so if I have reference, setting the stuff2 to null will remove the reference from stuff then?
and lets stuff to be gced?
no
a = b doesn't invalidate b
setting a to null won't let it be GC'd because b still exists
setting both to null (assuming they're the only references) will allow GC to collect it
wait so both and not only the referenced stuff? even you nullify the original variable?
delete b 
lmao thats a big confuse there but ok I think I get a bit of gist
I didn't know this lmao
it means something errored on shard 0
Well yeah
That's nice
Well I didnt have an error handler at the time, never took 5 seconds to do .on('error', (error) => console.error(error))
Lmao
I just put it in
So I just got a lovely
instead of something that could've been helpful
Lol
Well it didn't error a second time, but my bot has been taking longer to restart lately
not that one tho, that was for shard testing
So im kinda dumb but is it possible to convert a GuildChannel to a Channel?
Partly
but you cant do GuildChannel.Parent as it returns the channel's catagory
i need to send a message
channel.send(...)
<Channel>.send
.sendMessage is deprecated
o
doesnt work
at Client.bot.on (/app/server.js:178:14)
at emitOne (events.js:116:13)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle (/rbd/pnpm-volume/9dbb066e-589a-41b7-8b37-52522343a97c/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/9dbb066e-589a-41b7-8b37-52522343a97c/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/9dbb066e-589a-41b7-8b37-52522343a97c/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/9dbb066e-589a-41b7-8b37-52522343a97c/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/9dbb066e-589a-41b7-8b37-52522343a97c/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)
(node:8804) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8804) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
that means the channel is undefined
or well
null
What version of d.js are you on
var createdchannelname = "ticket-"+ticketid;
var ticket = message.guild.channels.find(channel => channel.name === createdchannelname);
11.4.2
is there an update
Unless you go to master
so it should work?
You have to account for no channel being found
well did the channel ever actually get created?
Why not save the channel as you create it?
I use return server.createChannel(name, "text");
right?
or
yes the channel is created in the same command
it calls a function
that does this
You just save it like any other var
I think you have to
ok
ok
the test
ok
so it works
but .send doesnt work
so ima try .sendMessage idk
nope
I think it doesnt return the value.
this should work, right?
var ticket = makeChannel("ticket-" + ticketid, message);
You need to await it
the function?
it's return value is a promise
Mhm
so I'm trying to make a music bot
I know
ew
ok I have a question but I'm going to wait a sec
ok so what do y'all use to stream audio from youtube?
easiest method is
ytdl + discord.js voice
you're talking about downloading the whole video before playing it?
I know I can fall back to that but I'm trying to stream it also I think I just found out a way
^ easiest way
ooh
Well I think I'm going to keep using pafy to get the direct url then stream it from that
https://npmjs.com/ytdl-core-discord was created by the creator of discord.js for music bots
So well,
I've tried almost everything, but I can't seem to be able to change the bots presence for some reason.
I'm clearly doing something wrong, but what 
await client.change_presence(game=discord.Game(name="Test", type=1))
Currently just trying that, didn't work as well so :/
Rewrite branch?
Hell no, I can't be arsed to start with rewrtie right now. Async
hm shit
yeah I've got it all working except I just need to figure out how to transcode the webm audio (vorbis or something like that I think) to raw pcm
as its streaming
yeah I was thinking of it I just don't know much about ffmepg or how I would get it to work with a stream
[
'-analyzeduration', '0',
'-loglevel', '0',
'-f', 's16le',
'-ar', '48000',
'-ac', '2',
]
that converts the audio into "S16LE" 16-bit signed PCM audio.
ok sorry but I'm dumb so would that work to like do it by chunks
you said you get the stream right?
yeah I got that and I'm able to read the stream
ok is it a readable stream?
since I deal with node.js so Im not sure what is the counter part on Python
I think you use python?
It's through an http request and just reading 20 bytes at a time right now because 20 bytes is what discordpy asks for
but I can change that number
do you use ffmpeg right now?
Nope first thing I tried was just directly plugging that in but it needs to be converted so thats what I need ffmepg for
ok so to give you an idea, the arguments would be the ffmpeg arguments which you will use for the ffmpeg conversion
that arguments I gave convert the audio to pcm audio
since Im not really a python programmer thats all the help I can give you, but I would advice to use an ffmpeg package in your programming language
to make your life easier
I get that I was just wondering if it say I only gave ffmepg n bytes if it would still work but I can just play around
thanks!
also I think it may work since readable streams in node.js work like that
although you feed it directly the "data"
how can i set this little pic on a embed?
author: {
name: client.user.username,
icon_url: client.user.avatarURL
}
and when i do it like that=
https://anidiots.guide/first-bot/using-embeds-in-messages @fiery nebula read
what should i do?
You are on python2
oh
how does one do that?
mac
ew mac
Everyone has their preferences
Download Linux onto your mac
/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python: can't open file 'pip': [Errno 2] No such file or directory
O
python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/rewrite.zip#egg=discord.py[voice]
No Problemo
If you need help search discord.py cog examples
@earnest phoenix
discord.py rewrite
Ahh, people suggesting rewrite 
Yes ily2
Wdym
Well what do you mean
Would not you have a way to create a subfolder in a folder in nodejs?
what
all small
any1 sees a issue in this code? https://github.com/Madmadz16/ModBot/blob/master/commands/pay.js
why don't you post the error you are getting and/or stop copying code you can't troubleshoot
there is no errors bot when i write -pay @ user <cash> and i have the amount myself i won't give it becouse of this line:js if(coins[message.author.id] > args[1]) { return message.reply(`You only have ${coins[message.author.id].coins} coins and you need ${args[1]} coins!`) }
and when i delete that line the user gets the cash but I don't lose it
you check if the user has more coins than specified in the command arguments yet you tell them they don't have enough even if they do
Folders can have spaces 
How to see which servers is my bot
code is
const botconfig = require("../botconfig.json");
let color = botconfig.color
module.exports.run = async (bot, message, args) => {
let bicon = bot.user.displayAvatarURL;
let string = '';
bot.guilds.forEach(guild => {
string += guild.name + '\n';})
let bt = bot.user.username;
let botembed = new Discord.RichEmbed()
.setColor(color)
.addField("Servers In", string)
.setTimestamp()
.setFooter("Command Ran By: " + message.author.username, message.author.avatarURL);
message.channel.send(botembed);
}
module.exports.help = {
name: "servers"
}```
But its not possible becasue console error
```(node:400) UnhandledPromiseRejectionWarning: RangeError: RichEmbed field values may not exceed 1024 characters.```
How can i fix that
Or how can i create when i typing servers list on servers , when i typing servers 1 another servers and other
use code blocks
the error clearly tells you what's wrong, your string contains every guild's name your bot is in and you try to press that into an embed. Said string is larger than 1024 characters and thus errors out when you're trying to send the embed
I know that but how can fix this
simply use the amount of servers as an integer rather than all of their names 
or write it to a text file
and that "solution" is going to help him achieve his goal in what way exactly?
how can i write it to a text file
throwing out servers your bot is in isn't the best idea either way so i suggest you stick to raw numbers rather than server info
i dont remember how. I used to do it when working with .json but i yeeted that altogether
use stack overflow, im sure its a fairly simple process
listen i want create thath
http://prntscr.com/mu2pi3
when i typing example invites 2
Bot show me invite 2 page, when i typing invites 3 bot show me invite 3 page
I see what you're trying to do but its beyond my abilities - I've forgotten how to work with json because sql handles data better. You're gonna probably have to run a loop to limit 10 per page, again stackoverflow will really help
You actually arent allowed to have a public servers command
I didnt know thats not allowed, but yeah I'm not even sure why you need to list the server names anyway. seems the standard for global leaderboards leaves out the server names anyways
I've been quoting it as an example because I did not know how to explain otherwise what I want , because I do not know how to speak good English and use google translate
let user = message.mentions.users.first() || message.author;
const canvas = Canvas.createCanvas(127,127)
const ctx = canvas.getContext('2d');
const { body: a } = await snekfetch.get(user.avatarURL);
const avatar = await Canvas.loadImage(a);
ctx.drawImage(avatar, 10,10,230,230)
const attach = new Discord.Attachment(canvas.toBuffer(), 'avatar.png');
message.channel.send(attach);```
how i can curve the avatar
i don't want to create a circle
Like rounded borders?
Quick question lads
Quick answer mate
If I were to pass a param to a function that is a class
It passes it like an object right?
It'd pass the instance of the class
That I could use right away as an object rather than having to put all values in a new object
Yea an instance I'd be passing
Just wondering if that would be an object useable for e.g putting it in a json file
Alright so, I'd have to manually put it in an object?
Yes, you could make a method in the class for this
Aye I see
Thank you mate
used a getter
that should be fine if I believe
get classData() {
return {
name: this.name,
id: this.id,
globalLevel: this.globalLevel,
specialAccess: this.specialAccess,
members: this.members
}
}
Anyone know why custom emojis won't work with my bot?
depends how you use it
It doesn't work with both reacting and in messages.
I use the text given with \:emoji:.
ohh I see tarp
Well I used a getter now
On the class
Should work the same right?
I don't use getters, so I don't actually know how they work lmao
Oh well getters dont take params
I read about them
It is a function but it does not function as one
rip
golden explanation of the day
You work a lot with classes?
Oops not getName
how come you have function run()
classes dont need that
hm I see
class Person{
constructor(name, age, likes){
if(typeof name != "object" || name.length != 2){
throw new Error("Name must be an array with 2 entries (First name and last name).")
}
if(age < 0){
throw new Error("Age must be greater than 0")
}
if(typeof name != "object"){
throw new Error("Likes must be an array.")
}
this.firstName = name[0]
this.lastName = name[1]
this.age = age
this.likes = likes
}
setName(name){
if(typeof name != "object" || name.length != 2){
throw new Error("Name must be an array with 2 entries (First name and last name).")
}
this.firstName = name[0]
this.lastName - name[1]
}
getName(){
return `${this.lastName}, ${this.firstName}`
}
get toObject(){
return {
firstName: this.firstName,
lastName: this.lastName,
age: this.age,
likes: this.likes
}
}
}
function run(){
let person1 = new Person(["First", "Last"], 15, [])
test(person1)
}
function test(person){
console.log(person.toObject)
}
run()```
I just took it as an example
yeahh I was already thinking
lmaoo
I'd be dying if you'd do something like..
class random {
constructor() {
}
function ok() {
}
}

😂
but yours should work
the only difference with the get is that I didnt need the parentheses
aye aye
however
if Im not wrong
you cant do things like
e.g
get random() {
this.that = ok
}
Nearly sure that get only returns data
You just can't pass params
If you added parentheses it would say ... is not a function
Yeah thats true
Ok so I used the get now in a function
createJSONFile(customPerm) {
if(!customPerm instanceof CustomPerm) throw new Error('Passed value requires an Custom Permission instance.');
const data = customPerm.data();
fs.writeFile(`${this.dataPath}/${data.name}.json`, data, (err) => {
if(err) throw new Error(err);
});
return true;
}
I need to go, I'm in civics right now, just had some down time.
Ohh aight mate
You too 😄
Alright, thanks. Sorry for the late reply.
Np
what is wrong with this I got an error
With what
if (message.guild.me.voiceChannel) return message.channel.send('Sorry, the bot is already connected to the guild.');
And the error?
i says that message.guild.me.voiceChannel has error
me.voicechannel
i ant sure if me is the issue
then run it again
then run it again and send us the error
We cant help without the error,it should work
we cant help if we dont even know what the error is
Check the channel type
ok
my bot is so dumb it works for a day then your like its not having errors then 1 sec later it crashes lol
oh i got this
(node:3492) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'voiceChannel' of null
at Client.<anonymous> (C:\Users\chill\Desktop\chill\discord-bot\bot.js:445:25)
at Client.emit (events.js:194:15)
at MessageCreateHandler.handle (C:\Users\chill\Desktop\chill\discord-bot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\chill\Desktop\chill\discord-bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\chill\Desktop\chill\discord-bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\chill\Desktop\chill\discord-bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\chill\Desktop\chill\discord-bot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:189:13)
at Receiver._receiver.onmessage (C:\Users\chill\Desktop\chill\discord-bot\node_modules\ws\lib\websocket.js:137:47)
at Receiver.dataMessage (C:\Users\chill\Desktop\chill\discord-bot\node_modules\ws\lib\receiver.js:409:14)
(node:3492) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3492) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
when i dmed
but it never crashed
so idk how it crashed
Yeah, because the guild doesnt exist
because message.guild is not defined there
return on dm
show how to fix
No spoonfeed
@bot.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def kick(message, userId: discord.User):
await bot.kick(userId)
how can i modify this to not work when someone tries to kick me
first off, it's already a mistake by using async version
it's a very outdated library from around a year ago, at least
😦
secondly, learn python before writing code
install the rewrite version
prolly cause it is
duh
yes
how would i then use this library
but not only asking for help with code, also not knowing what language you are using? go back to school is all the answer I can give you
how have you been using the old library
this is the rewrite docs https://discordpy.readthedocs.io/en/rewrite/api.html
i know that i am using python, i am not a complete dumbnut, i just wanted to tell you that i dont know .js before you told me to use discord.js instead
I was not telling you anything language related?
he told you your lib was outdated. that being the case i doubt anyone will throw a lib written in a different language at you if there's an up-to-date one for your language of choice
I was telling you to learn python because you clearly do not know anything about it and trying to make something as big as a discord bot, it's just a terrible practice
development in general is a complicated thing, no one will help you if even you don't know what you're doing
eh tbf getting nodes and shite set up is confusing in itself
well thanks, but all i was asking is, could i simply use an if statement to check if userId equals my user id, and then to not do anything based on that
basically yes
i had to get someone to walk me through to actually get my bot to login, from there it was a breeze
cause from what i've seen, if statements are just ignored
again, it's best if you learn the basics of python, at the very least
..., it just jumps over the if statement, as in if i did
if userId == "Dr. Runk#0283":
return False
...that's not even the id
use the id number
oh boy
if i do print(userId) that is what show up
and yes, i have tried the ID number aswell
don't you think i tried that aswell?
No
considering your knowledge, no
i dont know python (im js boi)
but get rid of the "'s maybe and use the id
i highly doubt the python lib returns your id as an integer rather than a string
Its not a lib thing, ids are just snowflakes.
If a lib returns your tag
Then theres something wrong with the lib
it's kind of a lib thing, discord.js returns them as strings, discord.py rewrite returns as integers
It cant
wdym
@bot.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def kick(message, userId: discord.User):
if userId == "259695208453636106":
return False
else:
await bot.kick(userId)
this doesnt work
define "it can't", you surely could if you wanted to
there's nothing preventing you from converting its type before returning
@amber fractal are you js?
are you js?
if it converts it to int then he shouldn't be using quotes
read the docs and learn python instead of trying random things 
Yes, but the http request will always gove you a string, the lib might be doing the conversion
then don't fucking assume, I'm literally using discord.py rewrite and it's an integer, it's a fucking lib thing
Because Snowflake IDs are up to 64 bits in size (e.g. a uint64), they are always returned as strings in the HTTP API
It's not an assumption
It's in the docs
Your lib does the conversion
if you as a library dev are having a wonderful day and decide to parse through the string and convert it to an integer there is literally nothing preventing you from doing that no matter what the api returns
no one even asked about what ids even are, this was a discussion how the lib handles it
steven you're only making this more complicated for no reason
And you're being a dick 
well I'm sorry, it's not me that said that ids are strings out of the blue to the complete python noob when discord.py clearly uses them as ints
i kicked myself again
Sorry I can't help more, I don't use python for coding :/
ok no worries
anyway, your issue is that you defined your userId as a discord user object, so use userId.id to refer to the user object's id
yeah, but the async version may or may not use ids as strings
i could actually use userName, instead, but that doesnt work with spaces in the names
i would stick with id because id's are static
it's even better to just use user cause it's still a user object
userName is misleading cause you think it's already a user name
userName.name looks dumb
Where can I invite Mee6?
Thanks
does getting an invite object have any strict ratelimits?
How can i use node.js? All i get is a prompt, and not a windows form application :L
well
yes
frameworks are mostly packed with CLIs, not your fashionable windows apps
learn to work with CLIs because that's a big part of programming in general
uhm, ok.
probably the most useless function i have yet to refactor
i could just do client.commands[arg] inside the if statement that function is called in instead saving the spaghetti
Anyone have acquaintance with Reaction Role's creator? I have some questions about its v2 API, looking to integrate my system with it.
Go to the support server
Yes
Positive
Also, I save an instance of a class into a db, but I can't use the getter/setter methods anymore, is this normal or did I bork something
Well acturally nothing works
But it does save it as an instance of the class
Did I set it up wrong in here?
Ping me if you have a response pls.
how do you make a bot say something in a loop
Why would you want an infinite loop?
for my nsfw channel
i use too have a bot like the but someone banned it
@quartz kindle do u know how too
or how to make it say something a amount of times
Are you trying to code a bot, or make an existing bot do that?
make a existing bot do it
You cant make a bot do anything other than what it was coded to do
So you have to find a bot that does that
O
I made a bot
I want to know what to put in the code to make it do that
I thought u ment did I make a bot
@quartz kindle
Well, if you are coding your own bot, which language and library are you using?
python
An infinite loop is usually always bad, so you better stick with sending messages, if you really need that. But be aware that it is considered api abuse, and might get you rate limited if not worse
To send multiple messages, you can use a for loop
can u send me what the line looks like
I dont know which library youre using, and i dont use python, but it should be something like this, just for you to get an idea py for x in range(10): // 10 messages ctx.send(message)
hey
bot.users.get(vote.user).username returns undefined'
in this context
if (bot.users.get(vote.user) === undefined) {
console.log(`User with id ${vote.user} just voted!`);
} else {
let voteUsername = bot.users.get(vote.user).username
console.log(`User with username ${bot.users.get(vote.user).username} just voted!`);
let voteEmbed = new Discord.RichEmbed()
.setTitle(`${voteUsername} just voted!`)
.addField('ID', vote.user, true)
.setColor(Math.floor(Math.random() * 16777214) + 1)
bot.channels.get('552674443131093002').send({voteEmbed});
}```
like always
when the person is in a guild with the bot
Why not just put it in a try/catch?
just try and get the user, if it doesnt exist do the default
anything
Well the catch is just there for errors
like that
if it exists?
I honestly dont know why yours doesnt work
oh
I would recommend saving bot.users.get(vote.user) in a variable then checking if(!varName) return //stuff
look
[K] FFFFFFFFFFFFFFFFFFFFFToday at 8:02 PM
x-eval bot.users.get(345349646253817857 )
UsagiXBOTToday at 8:02 PM
undefined
ok
x-eval bot.users.get('345349646253817857').username
works
but
vote.user doesnt?
if(!user){
//stuff
}```
Did you hit test for this
Well it works for me 
can I see your code
Well it's the same as the example I gave you earlier
it returns the id of the user
you can also just rely on dbl api on whole webhook thing tho
without needing to touch your client.users
He's testing if the user shares a guild so he can post their username
so i was wondering
argh!
how can i get my bot's status similar to this?
Set it's activity
where it says it's watching something
dude
async _fetch_user(id) {
const req = await fetch(`https://discordbots.org/api/users/${id}`, {
headers: { authorization: this.dbl_token }
})
const user = await req.json()
return user.username + '#' + user.discriminator
}
async _send_new_vote_embed(user_id) {
if (!this.webhook) return
const tag = await this._fetch_user(user_id)
await this.webhook.send({
embeds: [{
color: 0x095562,
description: `📥 New User: **@${tag}** (${user_id}) voted`,
timestamp: new Date(),
footer: {
text: `💾 ${this.storage.size} stored votes`
}
}]
})
}
_onVote(req, res) {
if (req.headers.authorization !== this.auth) {
res.status(401).send('Unauthorized')
console.log('[Notice] Rejected Post Request, Details Below')
console.log(req.headers)
} else {
// Handle votes here
this._send_new_vote_embed(req.body.user).catch(console.error)
}
}
this is how my separate handler does it, if you would prefer to see how the whole code does it just ask me @empty owl
d.js?
yup
okj thanks
What in the hell is that tho 
thats how my own webhook work for dbl
as I said I dont need to rely on client.users which may return uncached users
np
ik
So use setActivity
k thanks
🤷
I gave you a snippet did you not understand it?
nope
this is the class contains that code, so I just invoke this which is the "class" of that methods, then invoke the methods
I didnt understand it either 
da f
if t he user is cached it will work
or you have your own playerstorage stuff
thats why it works
it's my db
y u delete i didnt see it yet
https://github.com/Deivu/Haruna
since my snippet confused you just look here
Simple webhook vote handler for Discord Bot List https://discordbots.org/ - Deivu/Haruna
It was an accident
ok
look on src haruna.js
the vote will be received on _onVote
just gonna ask you, do you understand classes?
then thats the reason why you cant understand my code
oh
this._send_new_vote_embed(req.body.user).catch(console.error)
when they vote
I call this
oh
async _send_new_vote_embed(user_id) and when I call that, I invoke this function
const tag = await this._fetch_user(user_id)
and there is this call to a function in my handler which is the
async _fetch_user(id)
wait
Wait so you dont even need the dblapi for that do you
it's basically your own little vote lib for dbl
no you can just rely entirely on dbl api
bot.login
no
oh
that is my own little vote lib for dbl api
as tarpegon said lmao
that doesnt rely on your bot
so even the user is not cached on your bot
it would be fine
client.users on discord bot doesnt contain all the users in discord
why would i need a username if they dont use my bot
and that could cause spotty stuff in your bot
dbl.webhook.on('vote', vote => {
let vUser = bot.users.get(vote.user)
if (!vUser) {
console.log(`User with id ${vote.user} just voted!`);
} else {
let voteUsername = bot.users.get(vote.user).username
console.log(`User with username ${bot.users.get(vote.user).username} just voted!`);
let voteEmbed = new Discord.RichEmbed()
.setTitle(`${voteUsername} just voted!`)
.addField('ID', vote.user, true)
.setColor(Math.floor(Math.random() * 16777214) + 1)
bot.channels.get('552674443131093002').send({voteEmbed});
}
});
bot.login(process.env.TOKEN)```
see
why
yea
gonna crash right
and what you did is just trololol
Yeah, dont do it
I even gave you the snippet
0ok
for supreme spoonfeed, if you have node-fetch in your bot
the reason why it doesnt work is because
dbl is in server.js
and my fs is in index.js
wait wat
.-.

that doesnt make any sense to me now
what does fs have to do with fetching a user?
like my main bot code is in index.js
and my dbl code is in server.js
but I cant login again because it bad
thats how my little library works
but it gets the user fine without any bot code
the way is to just grab it also from dbl
i use express
fastify is same as express but better
oh
I just use http 
fastify's overhead compared to express is less
you have node-fetch?
You can require server.js in index.js
if you have node fetch require it on your server.js
opk
async function _fetch_user(id) {
const req = await fetch(`https://discordbots.org/api/users/${id}`, {
headers: { authorization: this.dbl_token }
})
const user = await req.json()
return user.username + '#' + user.discriminator
}
copy that and replace authorization to your dbl token
invoke it with
const tag = await _fetch_user(vote.user)
thats how easy the snippet I gave you
Wait that little library thing you gave, all you'd have to do is make a new Haruna with the port, auth, length, token and optional dir and you're fine right?
do I just
yes
in my readme it says
This api / webhook vote handler is oversimplified. As long as you can start it, it will handle everything for you to save you the hassle of creating your own vote handler.
length is the cache lifetime of your user in cache @amber fractal
@empty owl on vote event of you dbl handler
ok
ok
thios goes?
async function _fetch_user(id) {
const req = await fetch(https://discordbots.org/api/users/${id}, {
headers: { authorization: process.env.DBLAUTH }
})
const user = await req.json()
return user.username + '#' + user.discriminator
}
below the on vote event
ok
not inside the vote event
ok
try to test it
undefined#undefined
User with id 345349646253817857 just voted!
ngl
ok so could you show your code rn?
dbl.webhook.on('vote', async vote => {
const tag = await _fetch_user(vote.user)
let vUser = bot.users.get(vote.user)
console.log(tag)
if (!vUser) {
console.log(`User with id ${vote.user} just voted!`);
} else {
let voteUsername = bot.users.get(vote.user).username
console.log(`User with username ${bot.users.get(vote.user).username} just voted!`);
let voteEmbed = new Discord.RichEmbed()
.setTitle(`${voteUsername} just voted!`)
.addField('ID', vote.user, true)
.setColor(Math.floor(Math.random() * 16777214) + 1)
bot.channels.get('552674443131093002').send({voteEmbed});
}
});
async function _fetch_user(id) {
const req = await fetch(`https://discordbots.org/api/users/${id}`, {
headers: { authorization: process.env.DBLAUTH }
})
const user = await req.json()
return user.username + '#' + user.discriminator
}```
the whole if possible
ok
const express = require("express");
const app = express();
const fetch = require('node-fetch');
var HttpProxy = require('http-proxy')
app.get("/", (request, response) => {
console.log("Ping received!");
response.sendStatus(200);
});
const Discord = require("discord.js");
const bot = new Discord.Client();
// listen for requests :)
const listener = app.listen(process.env.PORT, function() {
console.log('Your app is listening on port ' + listener.address().port);
});
const DBL = require('dblapi.js');
const http = require('http');
const server = http.createServer(app);
const dbl = new DBL(process.env.DBLTOKEN, { webhookAuth: 'hehnothanks', webhookServer: listener });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
console.log('Ready! Webhook running at /dblwebhook')
});
dbl.webhook.on('vote', async vote => {
const tag = await _fetch_user(vote.user)
let vUser = bot.users.get(vote.user)
console.log(tag)
if (!vUser) {
console.log(`User with id ${vote.user} just voted!`);
} else {
let voteUsername = bot.users.get(vote.user).username
console.log(`User with username ${bot.users.get(vote.user).username} just voted!`);
let voteEmbed = new Discord.RichEmbed()
.setTitle(`${voteUsername} just voted!`)
.addField('ID', vote.user, true)
.setColor(Math.floor(Math.random() * 16777214) + 1)
bot.channels.get('552674443131093002').send({voteEmbed});
}
});
async function _fetch_user(id) {
const req = await fetch(`https://discordbots.org/api/users/${id}`, {
headers: { authorization: process.env.DBLAUTH }
})
const user = await req.json()
return user.username + '#' + user.discriminator
}
I believe with their code you dont need to check for the user anymore
ok so could you delete first the other code on vote?
?
Because you get the username and discrim anyways
thi9s
} else {
let voteUsername = bot.users.get(vote.user).username
console.log(User with username ${bot.users.get(vote.user).username} just voted!);
let voteEmbed = new Discord.RichEmbed()
.setTitle(${voteUsername} just voted!)
.addField('ID', vote.user, true)
.setColor(Math.floor(Math.random() * 16777214) + 1)
bot.channels.get('552674443131093002').send({voteEmbed});
}?
I may be wrong I think I'm too tired 
const tag = await _fetch_user(vote.user)
console.log(tag)
just leave this on your on vote
ok
so that I can debug easier
ok
const express = require("express");
const app = express();
const fetch = require('node-fetch');
var HttpProxy = require('http-proxy')
app.get("/", (request, response) => {
console.log("Ping received!");
response.sendStatus(200);
});
const Discord = require("discord.js");
const bot = new Discord.Client();
// listen for requests :)
const listener = app.listen(process.env.PORT, function() {
console.log('Your app is listening on port ' + listener.address().port);
});
const DBL = require('dblapi.js');
const http = require('http');
const server = http.createServer(app);
const dbl = new DBL(process.env.DBLTOKEN, { webhookAuth: 'dblauthorizationcodehou', webhookServer: listener });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
console.log('Ready! Webhook running at /dblwebhook')
});
dbl.webhook.on('vote', async vote => {
const tag = await _fetch_user(vote.user)
console.log(tag)
});
async function _fetch_user(id) {
const req = await fetch(`https://discordbots.org/api/users/${id}`, {
headers: { authorization: process.env.DBLAUTH }
})
const user = await req.json()
return user.username + '#' + user.discriminator
}
@amber fractal yes the little lib handles that for you and u get the user+tag already
ok try to fire it up again
undefined#undefined
hmm ok wait a sec
lemme use my linter at that code
async function _fetch_user(id) {
const req = await fetch(`https://discordbots.org/api/users/${id}`, {
headers: { authorization: process.env.DBLAUTH }
})
const user = await req.json()
console.log(user)
return user.username + '#' + user.discriminator
}
@empty owl could you replace the _fetch_user with this
{ error: 'Unauthorized' }
undefined#undefined
the DBL token you use for server count posting
it should be the token
this stuff
avatar: 'cd2fe3bf8bdde55b97a7c5660e172286',
id: '345349646253817857',
username: 'bobthemoose',
defAvatar: '0e291f67c9274a1abdddeb3fd919cbaa',
admin: false,
webMod: false,
mod: false,
certifiedDev: false,
supporter: false,
social: {} }
bobthemoose#2228```
there thats your tag
That's the user object
bobthemoose#2228
thats already the user
into a embed or something
the const tag is the user already
oh
so like tag is the stuff?
console.log(user)
just remove this on _fetch_user so it wont flood
the tag is const tag
