#development
1 messages ยท Page 463 of 1
how are you converting it into an emoji object?
i dont think i am, how would i do that (sorry if this is a dumb question)
but according to the docs, an emoji object is for custom emojis only
you would have to try to convert the emoji from the message content into the unicode version of the emoji
because they dont have custom ids
i think
i think i understand now thanks
wait
then what would i do witht the unicode emoji, how would i get the url from thaat?
no idea, but the url belongs to the Emoji object
maybe Emoji(unicode)
let me check actually
My old command handler got a command like this const args = message.content.slice(Client.config.prefix.length).split(/\s+/); const CommandName = args.shift().toLowerCase(); I'm trying to make that work with mentions, I've already made it so if the bot is mentioned it passes through
its just the "CommandName" Assignment
The prefix is configurable (I'm going to make it configurable) so it might have spaces
any Idea how I would assign the variable? ;3
@viscid falcon nope, didnt find a way to use default emojis
but you could build your own database with their urls lmao
i may have found a way, let me check
i dont get it @earnest phoenix
https://github.com/Novuh-Bot/Custodian/blob/master/commands/Canvas/jumbo.js somehow this bot manages to do it, but i cant quite firgure out what they did that im doing wrong
you want to make it both with prefix and with mention as the prefix?
Yeah
oh
const regex = /src="(.+)"/g;
const regTwemote = regex.exec(twemote)[1];```
the parse the unicode with an external emoji database
its the same as i told you, build your own emoji database lmao
or use that
@earnest phoenix you have to separate your command first, if it came from a prefix or from a mention
Oh I can do that
something like ```
if(msg.startsWith(prefix){
get arg by splitting prefix
} else if(msg.startsWith(mention)) {
get arg by splitting mention
})
//continue
okay yeah I was thinking that but I thought there was an easier way
well, there are other ways to do that comparison, but im pretty sure you need it
ou could to a ternary operator for example
arg = (msg.startsWith(prefix) ? split with prefix : split with mention)
but you'd need to check for their existence before
Yeah I have a filter its something like if(!message.isMentioned(Bot.user)) { if(!message.content.toLowerCase().startsWith(Bot.config.prefix.toLowerCase()) return; }
just to cancel out any messages not starting with a prefix or a mention
yeah
but do you want to accept mentions from anywhere in the message?
or only beginning with the mention?
yeah, do a check for both <@id> and <@!id>
or was it !@id? i dont remember
nah i think it was the first one
<@!id> is when you have a custom nickname yes
if someone renames your bot in their server
so you could do if(msg.content.startsWith(<@id>) || msg.content.startsWith(<!@id>) || msg.content.startsWith(prefix)) { continue }
or even better
if(!(msg.startsWith(Bot.config.prefix.toLowerCase()) || ))```
Was starting to do something like tihs
lul
msg = message.content.toLowerCase()
var array = ["<@id>","<!@id>",customprefix];
if(array.indexOf(msg.content.split(" ").toLowerCase()) > -1) {
//continue
}
i just use an includes for mine usually
yeah includes is shorter, im just too used to indexof
if (['!', '<@id>'].includes(msg.content[0]/*prefix thing*/)) { ...```
i just use an if-else chain of startsWith
I could use this
if(!(msg.startsWith(prefix) || msg.startsWith(`<@${id}>`) || msg.startsWith(`<@!${id}>`)))
maybe
idk how well I'm am at coding tbh
and just put a return
when im using .id on custom emojis it just return undefined (im using discord.j)
it wont change
I know but I'm probably going to use this handler on multiple bots in the future
ah i see
Natan
that looks confusing
lmao
well idek what .increment() is so I'm retarded
oh
UsageTrackers.prefixes returns a group, tracker(...) returns the tracker for that key, increment() adds one
this is mine lul js if(!running) { return; }; if(msg.author.bot) { if(msg.author.id === "344272098488877057") { logmsg(msg); }; return; }; var m = msg.content.split(" ")[0]; for (var i = 0, c = commands.length; i < c; i++) { if(m === commands[i]) { msg.content = msg.content.replace("โ","--"); logmsg(msg); if(!checkperms(msg)) { return; }; if(maintenance === true && msg.author.id !== "180112943612952577") { msg.channel.send("Astrobot is under maintenance. Try again shortly :3"); return; }; eval(commands[i].replace(".", "") + "(msg)"); }; }; if(msg.content == "@oak sentinel" || msg.content == "@oak sentinel") { logmsg(msg); if(!checkperms(msg)) { return; }; help(msg); } else if(msg.content.indexOf("@oak sentinel") > -1 || msg.content.indexOf("@oak sentinel") > -1) { logmsg(msg); if(!checkperms(msg)) { return; }; talkback(msg); } else if(msg.author.id === "344272098488877057"){ logmsg(msg); };
when im using .id on custom emojis it just return undefined (im using discord.j) sorry that i already mentioned it
.id is basicly what im doing
if you just want the id use \:emoji:
it should be client.emojis.get()
Yeah
hm tim
what if someone does like
@earnest phoenixhelp
the split wouldn't work 
who does that
or if they put 2 spaces
user typo, they should fix it themselves
true
so would i use client.emoji.get(
) ?
thanks
idk if get works with that or only with ids
no
sorry am bad at js here
exactly tim
<Client>.emojis.find(e => e.name === 'tickYes');
i just do .find(function(a){code})
and what would name be? :emoji:?
i guess
after I do this to remove the first item in the array is slice right? message.content.split(/\s+/)
splice, slice, split I always get confused
splice changes the original
slice doesnt
so .split().splice(0,1) would remove the first item
would that work with slice too then? ๐ค
it would
wew im learning new things okie
i dont remember if the arguments are the same for both
but in this case they would be exactly the same
idk about performance difference tho, let me check
okay
jesus fucking christ are you serious
can someone verify this test is not broken? lmao
look at the debugger's profiler
probably a GC pause killing results
it's hard to reliably benchmark garbage collected languages
and JIT-ted languages to a certain extent
and JS is both
well, hard when they're non deterministic
im kinda confuse on how to use this code tony gave me
<Client>.emojis.find(e => e.name === 'tickYes');
if im trying to get the id of the user specified emoji, would it be something like
<Client>.emojis.find(e => e.name === `args[0]`);
this is with args[0] being the first user argument which would be a custom emoji
which also applies to JS
it cant be my gc, the test logs results from other users/browsers, all are identical
i think that specific test code is flawed
i dont believe i can change the order
ReferenceError: args is not defined welp
I don't need async 
if(msg.startsWith(prefix)) {
const args = message.content.slice(prefix.length).split(/\s+/);
console.log("1 | " + message.content);
} else {
const args = message.content.split(/\s+/).splice(0, 1);
console.log("2 | " + message.content);
};
console.log(args || "No arguments defined")
apperently... the first const args isn't working
i think you might need to define args out side of the if statements
for the console.log
const is lexically scoped
i think you can set them inside ifs
i thing you dont need the slice in the first if
Yeah I do
you already confirmed the message does start with the prefix, so you can just split it with a space, and remove it
also don't remove const
Tim the prefix can have spaces in it
oh
@inner jewel whats jsx
if(!content.startsWith(prefix)) return;
const args = content.substring(prefix.length).split(/ +/g)
react stuff
im kinda confuse on how to use this code tony gave me
<Client>.emojis.find(e => e.name === 'tickYes');
if im trying to get the id of the user specified emoji, would it be something like
<Client>.emojis.find(e => e.name === `args[0]`);
this is with args[0] being the first user argument which would be a custom emoji
oh ok
why js e.name === `args[0]` instead of js e.name === args[0]?
I got it to work with 2 if statements
but the splice removes one starting argument
and not the prefix
Guessing I change this .splice(0, 1); 1 to zero?
or wait -1
lemme google
iirc its splice(index,amount to remove)
Yeah it is

!test
@mention test
[ 'test' ]
[ '@humble pine' ]```
thats the output
test is the prefix?
wait
why are there 2 separate arrays
oh nvm
ah i see the problem
splice returns the removed part
so you have to use slice
or make 2 lines
original array;
splice
//use original array now
ill try slice
yey
thanks man
These three lines work
if(!(msg.startsWith(prefix) || msg.startsWith(`<@${id}> `) || msg.startsWith(`<@!${id}> `))) return;
if(msg.startsWith(prefix)) var args = message.content.slice(prefix.length).split(/\s+/);
if(!args) var args = message.content.split(/\s+/).slice(1);```
How do I send an image using its URI? I tried sending it as an attachment and through a RichEmbed both, but it's too long and "not a well formed URL".
whats the url your trying to send?
aka add a print statement and and check your sending what you think
I'm trying to send this image URI that was generated using canvas.
https://hastebin.com/mokoduwawo
oh ok you cant send that kind it must be in buffer form
Ah.
afik canvas has option to export to type buffer
Should this work?
let buf = new Buffer(canvas.toDataURL());
return message.channel.send(new Discord.RichEmbed().setImage(buf.toString()));
url != buffer
Okay. How do I buffer it using canvas, then?
http://can-you-plz.givemefish.com/479108797034397697/0.png better idea...
read teh docs ๐
message.channel.send(new Discord.RichEmbed().setImage(canvas.toBuffer()) at a guess
Oh, lol my bad.
I'm not sure how to implement .toBuffer().
var Canvas = require('canvas'),
Image = Canvas.Image,
canvas = new Canvas(200, 200),
ctx = canvas.getContext('2d');
Image = Canvas.Image.toBuffer()?
so presumably you already have pre existing canvas code thats how you got URI right?
so then call .toBuffer on the thing you were calling .toURL() on
Okay.
I guess not.
- (node:15552) UnhandledPromiseRejectionWarning: TypeError: canvas.toDataURL(...).toBuffer is not a function
;-;
I'll check the docs.
you repalce to toURL to buffer
I did.
message.channel.send(new Discord.RichEmbed().setImage(canvas.toBuffer()) at a guess
as said before
no by that errror you added toBuffer onto the end of toDataURL
I did before that.
I'll try again.
- Could not interpret "{u'data': [...], u'type': u'Buffer'}" as string.
if (command == 'test') {
var Canvas = require('canvas'),
Image = Canvas.Image,
canvas = new Canvas(500, 500),
ctx = canvas.getContext('2d');
var img = new Image;
img.src = canvas.toBuffer();
ctx.drawImage(img, 0, 0, 50, 50);
ctx.drawImage(img, 50, 0, 50, 50);
ctx.drawImage(img, 100, 0, 50, 50);
// ctx.font = '30px Impact';
// ctx.fillText(`Hello ${message.author.username}!`, 50, 100);
// var te = ctx.measureText('Awesome!');
// ctx.strokeStyle = 'rgba(0,0,0,0.5)';
// ctx.beginPath();
// ctx.lineTo(50, 102);
// ctx.lineTo(50 + te.width, 102);
// ctx.stroke();
return message.channel.send(new Discord.RichEmbed().setImage(canvas.toBuffer()));
I hope not.
When I send it as an attachment it says it's too long of a URL, and when I send it in a RichEmbed it says it's not a well-formed URL ๐คฆ
ok got it you need files not file on the embed
file is for string type aka urls but files is buffer type
When attaching it?
this is in the djs send embed thingy
I'm not sure what you mean.
message.channel.send(new Discord.RichEmbed().files(canvas.toBuffer()));
Oh, okay.
btw did i mention i dont know djs specifically rolling off the docs rn
if that ndoesnt work then there one other thing i can see but that seems really dumb if its right
I'll take your "really dumb" idea.
message.channel.send(new Discord.RichEmbed().files(new Discord.Attachment(canvas.toBuffer(),"why-djs.png")));
brackets may be off
.files() isn't a function.
I found something that works, but only as an attachment.
wow thats jank
if some here who actually uses djs can show another way thats probably better but from the docs that looks right and seems really ugly
i use the attachment method too lol
oof
Anyone here use discord.py?
Yes
I keep getting SyntaxError: invalid syntax
canvas.toBuffer(function(err, buf){
resolve(buf);
});
msg.channel.send({"files":[new discord.Attachment(image, "chart.png")]}) //image is the resolved buffer```
Send the code that is breaking :p
from discord.ext.commands import Bot
import asyncio
client = commands.Bot(command_prefix = ".")
@bot.event
async def on_ready():
print("Im Ready!")
@bot.event()
async def on_message(message):
if message.content == "hi":
await client.send_message(message.channel, "Hi There!")
client.run("You Thought :)")```
???
from discord.ext.commands import Bot???
commands.Bot???
from discord.ext import commands is the way
still dosnt work
What is the error now
same thing
Full traceback pls
File "c:/Users/havef/Desktop/DiscordBot/bot.py", line 1, in <module>
import discord
File "C:\Users\havef\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\havef\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 38, in <module>
from .state import ConnectionState
File "C:\Users\havef\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 36, in <module>
from . import utils, compat
File "C:\Users\havef\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\compat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax```
i do
Well, Python doesn't think so
windows+python+modules=not fun
pip show discord.py in command prompt please
still error
yes
File "bot.py", line 1, in <module>
import discord
File "C:\Users\havef\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\havef\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 38, in <module>
from .state import ConnectionState
File "C:\Users\havef\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 36, in <module>
from . import utils, compat
File "C:\Users\havef\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\compat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax```
SyntaxError: invalid syntax
wonder what could be problem
yes
if your on windows there a whole ton of hoops to jump through to use pip
Is that so
i ran pip show discord.py
And then, if you have pip installed, pip show discord.py 
And what was the output?
oh pugs there updated pip
friggen yes it actually registers to path
nvm what i was saying then
used to not register to path
Version: 0.16.12
Summary: A python wrapper for the Discord API
Home-page: https://github.com/Rapptz/discord.py
Author: Rapptz
Author-email: None
License: MIT
Location: c:\users\havef\appdata\local\programs\python\python37-32\lib\site-packages
Requires: aiohttp, websockets
Required-by:```
i installed the latest python today
Move to 3.6 :^)
is there a command i can do to downgrade or no?
A command, eh? 
Nope, uninstall Python3.7 and install... uh... Python3.6? Unless I am confusing rewrite branch with async
am assuming has something to do with
And I am assuming pip install discord.py does not have Python3.7 supported :^)
anyone know why this is happining
(node:25656) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
at IncomingMessage.res.on (C:\Users\1winm\Desktop\DreamingBot\node_modules\dblapi.js\src\index.js:115:25)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:25656) 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:25656) [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.
after the discord stuff it will not work and then i keep making a new dbl token and still no work
tag me if you can help plz
@boreal acorn you have the wrong/no auth header with your request
You didn't put a valid token
It keeps changing
not your discord token
Ik the dbl token. It keeps changing and all of my other tokens are good

fight meh D:
that has nothing to do with development @wild tide @earnest phoenix
good i have made a code for unban but it does not work for me could you help me the code is the following
if (mSplit[1] === 'unban') {
bot.unbanMember(cleanID(mSplit[2]), message.channel.server.id, function (error) {
if (error) {
bot.reply(message, error);
return;
}
bot.reply(message, "I've unbanned: " + mSplit[2] + " from: " + message.channel.server.id);
});
}
Isn't it .catching error instead of ifs?
what do you mean by that?
I'm still a beginner and I do not know too many things!!!
Thanx you.๐
@commands.command()
async def profile(self, ctx, user: discord.User):
""" Gets back information and displays it about the user. """
name = user.name
id = user.id
avatar = user.avatar_url```
getting a bit of an issue
for some reason it throws en error with id acting as a tuple index even though that's not what I want
(using discord.py rewrite in cogs)
im not quite sure
the problem has gone away however
i guess python had a burp moment but im really disturbed as to why
xD
this is going in the books for another reason why i dont like python
i have to sometimes exit the script and re-run the whole application
which i should never have to do
Why does my bot put , instead of spaces for the kick reason
Show us your code
let member = msg.mentions.members.first();
let reason = msg.content.split(" ").slice(2);
let mod = msg.author.username
let embed = new Discord.RichEmbed()
.setColor("GREEN")
.setTitle("User kicked!")
.addField(`User`, `${member}`)
.addField(`was kicked for`, `${reason}`)
.addField(`by moderator`, ` ${mod}`)
if (!msg.member.hasPermission('KICK_MEMBERS')) return msg.channel.send(`You don't have permission to run this command!\nMissing Permissions: \`KICK_MEMBERS\``)
if (!msg.guild.me.hasPermission('KICK_MEMBERS')) return msg.channel.send(`I don't have permission to run this command!\nMissing Permissions: \`KICK_MEMBERS\``)
member.kick(reason)
msg.channel.send({embed})
},```
it could be an issue with how you're handling the split
Your not joining the reason
It's an array, so it's going x,y,z
let reason = msg.content.split(" ").slice(2).join(' ');
well if it was an array shouldn't it show the brackets [] too?
or does JS not do that in this case
No idea tbh
@latent heron who's that?
im actually confusion
ty it works
Also wrong channel
its a private bot I made for a server @latent heron
My join message wont send
```bot.on(guildMemberAdd, async (member) => {
let LewdServer = bot.guilds.get(419193162469212160)
if (member.guild.id == LewdServer) {
if (String(LewdServer.members.size).endsWith("1")) numbersuffix = "st"
else if (String(LewdServer.members.size).endsWith("2")) numbersuffix = "nd"
else if (String(LewdServer.members.size).endsWith("3")) numbersuffix = "rd"
else numbersuffix = "th"
channel = bot.channels.get(`472385983682314243`)
channel.send(`Welcome to ${LewdServer.name}, **${member.displayName}**! ๐ You are the **${LewdServer.members.size}${numbersuffix}** member.`)
}
});```
const Discord = require("discord.js");
const bot = new Discord.Client({disableEveryone: true});
bot.on("ready", async () => {
console.log(`${bot.user.username} is online!`);
bot.user.setGame("On SourceCode!");
});
bot.on('error', err => {
console.log(err)
});
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type == "dm") return;
let prefix = botconfig.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
if(cmd === `${prefix}hello`){
return message.channel.send("Hello");
}
});
bot.login(botconfig.token);
This doesnt work?
This keeps saying message and msg is undefined
bot.on(`guildMemberAdd`, () => { message.channel.send("Hello this is a test") }); bot.on(`guildMemberRemove`, () => { message.channel.send("Looks like you left") });
bot.on(`guildMemberAdd`, () => { msg.channel.send("Hello this is a test") }); bot.on(`guildMemberRemove`, () => { msg.channel.send("Looks like you left") });
it says that because i cant get it to work
Because there is no message nor msg defined?
msg is defined but it says its not
Is it defined in another function?
yes
Well, that's the problem 
This gives me an error.
at _errnoException (util.js:1022:11)
at TLSWrap.onread (net.js:628:25)
(node:16876) 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:16876) [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.
here is an error*
https://status.discordapp.com/api wat is dis ._.
neither have i but i was able to make a pretty accurate guess as to what it was
lol
if you get a response from it, yes
hmm
It's the server status of discord, and the api provided is for whoever want to make an application that take the server status information of discord's server
that could be helpfull for bot's api developper to adjust for example reconnect time for not surcharging discord's server when they are unstable/down
with d.py, what's the best way to delete messages containing invite links without looking for discord.gg in the link?
ok, thanks for that
another question
can there be more than one of the same event defined in the same file? actually nvm that
Im trying to add messageUpdate but it doesnt work
client.on("messageUpdate", (oldMessage, newMessage) => {
if(oldMessage.author.bot) return;
let editedMessage = new Discord.RichEmbed()
.setDescription(`**Message edited in ${oldMessage.channel}**`)
.setAuthor(`${oldMessage.author.tag}`, `${oldMessage.author.displayAvatarURL}`)
.setFooter(`User ID: ${oldMessage.author.id}`)
.setTimestamp()
.setColor('#09c1ef')
.addField("Before", `${oldMessage.content}`)
.addField("After", `${newMessage.content}`);
newMessage.guild.channels.find(`name`, "logs" && "testar_bots_logs") .send(editedMessage);
})
yea
btw do you know how i can get user avatars on my website to automatically update?
What are the avatars for, anyone who used the bot? Or for specific people?
Avatar = profile pics
for my website, yes for me
I want it to automatically update when i change it here (on discord)
Using a command handler, how would I call a function inside of a different file using d.js?
module.exports i think
hmm
@earnest phoenix You sure it isnt exports.run?
maybe
hmm
Okie lmao
ยฏ_(ใ)_/ยฏ
so i was right?
ye
yay
but i do exports.run because its shorter :v
:c
well both work so
well good enough
Is it somehow possible to get the memory used by only the Bot in java?
you have two options
the methods in Runtime, or getting the memory mxbeans from ManagementFactory
but runtime is for the entire runtime..
I only want the memory used by my Application
Runtime is for the jvm process
you can only get for the vm process without massive overhead
okay, will have to do, thanks c:
another option would be manually counting the referenced memory but that's extremely slow
and you'd need to handle circular references
Uh no thanks :p
thanks ;3
you can take a look at the other ManagementFactory methods if you want even more detailed info on memory usage
if you want just a quick and dirty approach (eg for eval) Runtime should be enough
https://docs.oracle.com/javase/10/docs/api/java/lang/management/MemoryPoolMXBean.html this gives really detailed info
Okay
but for just general memory usage it might be a bit too detailed
and you'd need to know jvm internals to understand what each area is
also, if you use the MemoryMXBean approach (which should be enough for your case), you want the heap memory usage
which is what java code uses
Ah okay thanks alot :3
nonheap can be used by java but only indirectly (eg ByteBuffer.allocateDirect()) and generally won't matter for bots
What the error? https://hastebin.com/qasilowomu.coffeescript
Everything seems right
@craggy roost check if the bot has MANAGE_MESSAGES
Bot is ADMINISTRATOR
This command is working in my personal server
But other server has this error
Well then maybe its is not ADMINISTRATOR on those other servers..
there's a chance that they removed the integrated role permissions, or simply didn't include it before adding bot to server
How so? Could they have left their own role?
even if you request admin perms in the bot invite link, users can remove them
Hmm. How can I fix this problem of authority? If they can. There must be a way.
you can check if the bot has perms and send an error message if it doesn't
there's no way of ensuring you have the permissions
unless you leave the guild when you don't have them
I understand.
How are we going to adapt this customer. new msg.member.hasPerm ..... will change to what?
Just check if the bot has the permissions in that channel and if not, send the owner a pm or do nothing
That's what I have to do to do that. <client> .... what will hasPerm put here?
I am fixing an error, but another error is coming from another place. They are not on my server, they are on another server! ๐ก
If you dont know what the stuff returns, check the docs..
Im trying to add a reload command to me command handler, It works. But does not update the code when reloading the file
I only do java, cannot help you there
manually restart the file then
if the command works for the other files then there should be no prob
@latent heron But look
A guy aready joined and didnt know
It simply just doesnt update the command
i dont read coffeescript
๐ฆ
sorry
oof
its js
idk
kek
Anybody else know please? The help command will not updatewhen I use the relaod command https://hastebin.com/apijiniwom.coffeescript#
Why does my bot send every message 2 time
maybe its running twice?
Every command does it
im trying to work on sharding and discord bot list is giving me this error
events.js:167
0|shardstart | throw er; // Unhandled 'error' event
0|shardstart | ^
0|shardstart | Error: listen EADDRINUSE :::5657
0|shardstart | at Server.setupListenHandle [as _listen2] (net.js:1336:14)
0|shardstart | at listenInCluster (net.js:1384:12)
0|shardstart | at Server.listen (net.js:1471:7)
0|shardstart | at DBLWebhook._startWebhook (/root/dbot/node_modules/dblapi.js/src/webhook.js:45:18)
0|shardstart | at new DBLWebhook (/root/dbot/node_modules/dblapi.js/src/webhook.js:27:12)
0|shardstart | at new DBLAPI (/root/dbot/node_modules/dblapi.js/src/index.js:69:22)
0|shardstart | at Object.<anonymous> (/root/dbot/index.js:25:13)
0|shardstart | at Module._compile (internal/modules/cjs/loader.js:689:30)
0|shardstart | at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
0|shardstart | at Module.load (internal/modules/cjs/loader.js:599:32)
0|shardstart | at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
0|shardstart | at Function.Module._load (internal/modules/cjs/loader.js:530:3)
0|shardstart | at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
0|shardstart | at startup (internal/bootstrap/node.js:266:19)
0|shardstart | at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
does anyone know what it means i think its with the api but idk
DBL library is incompatible with sharded bots
do you know how to make it work then?
You need to develop a seperate webhook solution, like a regular webserver and connect that up to your bot's database
how do you do that?
hello can somone here help me with bash ?
@quasi marsh Hey, you busy? Would you be able to take a look at something for me please? Sorry bout the ping also
#! /bin/sh
while true
do
echo Starting Bot
node bot.js
echo Restarting Bot in 5sec
sleep 5
done
this is my bash with one run again bot when it down
but on debian it not work ... what is wrong here ?
how do I check if the amount variable contains -, . or +?
can anyone here mind helping me with making a reload command
cuz im having some trouble
Same bro
Why is the YoutubeDL searching for videos outside of youtube? ๐ค
i found this issue with discord.py too
I think what happens is that even though you dont specify it in the code
the bot does 2 connections
Who me?
just close the whole script
@latent heron Who are you speaking to lol
ok
@icy matrix what do you want to do with your bash script?
how do i make discord.js not use much memory
@misty lagoon just ask
in java script if i want to check if a message starts with an item from an array, what would i do? ik its something like if (message.content.startswith(im not to sure what i would put here, ik something with the array but im not sure what))
its not a specific number though i mean any item from the array
Nested loop?
then
yup
what i was about to say lol
use a for loop
and then for how many there are in the list
replace that with i
and make i go -1 each time
and put ArrayName[i]
inside the loop
And if you found a match break your loop :3
can you not send your messages in multiple @misty lagoon
ok
and literally just ask
ask who?
just ask your question here, your not asking anyone in specific 
umm
oh
Does anyone know why Heroku isnโt hosting 24/7? after closing the tab about 4 minutes later it stops.
so would it be like for (var i = array.length; i > array.length; i--)
im bad at for loops sorry
heroku goes down after a while
ok thanks
tbh, i'd use glitch
glitch is harder
you can get it on 24/7 with uptimerobot iirc
ok
i donโt want to spend money on this
yea
oh right, you ping it or something?
and if i want to check if a message has a word would it be if (message.content.has('word')) {?
normally dont use arrays sorry
i see what you wanna do
how do you ping it then
if (['item', 'item'].includes(message.content /*or whatever*/)) { ...```
@viscid falcon
thats the best way
duh lol, thats the array. your basically calling .includes on an array
so change that to an array variable, or fill it with whatever
oh lol, sorry i just got home from school im tired
try run it and see lul
am i using this for loop wrong? nothing inside it works
for (var i = ShardInitiateDouble.length; i > ShardInitiateDouble.length; i--) {
have you tried restarting it?
do you need the index?
what library are you using?
discord.js
you can do
ok
how do i use a while loop?
var i = array.length;
while(i--) {
//code
}```
ok il try that
yeah thatโs true
if (i < 1) {
return
}
let me = "be free"```
ik what let was, just had a derp and forgot what it was called so i just used var
yeah it doesnt rlly matter though
let is better :D
sources?
there isnt any performance difference, just scoping difference afaik
let doesnt allow you to accidentally modify variables outside of the current scope, but var does
but usually you wouldn't do that
if i wanted to modify a variable outside of scope, i would just omit the declaration var a = 1; if(true){ a = 2 }
let is better if you want to reuse the same variable name over and over again for different things
yay
which I do, a lot
(node:29074) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
why is this happening when my bot's token is valid?
Either wrong token or lib issue
token is right, lib shouldn't be an issue
it could be due to how i made my handler
anyone have experience with classes then?
you're better off just asking your question
true
error:
(node:29074) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
app.js https://hastebin.com/zoyavefoho.js
src/ListenClient https://hastebin.com/edupexusuf.js
i know the token is valid, so why is this happening? ๐
this watered down version works fine, realistically your token is probably invalid https://tc.bad-me.me/be6df4.png
honestly dunno why, but okie
also, if I can offer you some advice - stay away from globals
kind of a horrible practice
agreed
i'm kinda wondering if my config isn't being required right in app.js
you can always console.log it
true
oh
token is undefined
the what now (โฏยฐโกยฐ๏ผโฏ๏ธต โปโโป
i did console.log(JSON.stringify(options, null, 2)) and it gave me this:
{
"connect": true,
"clientOptions": {
"disableEveryone": true
},
"locale": "en-US",
"globalize": true
}
no token ๐
in js, with return does it just stop processing code or just the if statement its contained in?
the current file and code below it iirc
the current function
thanks
ok tf
it's apparently removing the token?
// config.js
module.examples = {
token: ' token ',
// app.js
const Listen = require('./src/ListenClient');
const Sync = require('./src/Sync');
const config = require('./config.js');
const client = new Listen.Client({
static: { token: config.token, },
connect: true,
clientOptions: { disableEveryone: true },
locale: 'en-US',
globalize: true,
});
Sync.syncAll(client, true, {
commands: './commands',
events: './events',
});
console.log(config.token) // => undefined
why is it being logged as undefined?
also in the client file, static comes out as {}, like token was removed?
try logging options before super()
okay
pretty sure its exports.examples or module.exports but not module
that too
ohhhh in the config
ye
crap, ok. thats it probs
woo that worked lol
now if only it'd read events and work
TypeError: ev.bind is not a function was this changed or something?
it worked fine for me before
stupid question but
i see that's a rich embed (top one)
but whats the one staffbot displays?
its still an embed
No color maybe?
also this channel is for bot development help
its the same color as the dark theme background
It's technically still related to the discord api ๐คท
Hmm yeah I guess you're right
@deft summit try changing your theme to white color and see if the embed looks different
This channel is for any type of development help, not just bots. They just stupidly put "bot" in the channel description and won't change it 
so
No problem
does anyone have any idea of how a call bot could be set up to work with firertc?
Unfortunately there isnโt really a very easy way to do that. Iโd recommend just using https://sipjs.com/53 and connecting to https://www.twilio.com/24 or https://www.flowroute.com/30 yourself. Thatโs bascially what we do (with https://freeswitch.org/37 and https://www.opensips.org/27 in the middle). Iโve run SIP.js in Node before. It works okay until you need to send media but if you really work at it you may be able to get around.
thank you
What even is that?
linking a bot to a phone service
Oh like an actual phone
That's a really neat idea
Where did you get that paragraph from though?
if i was good enough i would totally steal get inspiration from that idea
anyone know how to find a channel by id?
Can't find how to anywhere, and I forgot how to XD
lib?
I got a Question.
How would i check the owner of a discord bot python 3.6+
Cause what i am trying to do is check for a link to discordbots.org, then check if the owner of the bot is the same person as the dude who posted the message
Use discordbots.org api and compare the ID 
@earnest phoenix The Question i am asking is how to get the id of the owner of the bot
its in the response from the api
Documentation link to that?
Ah
yeah its not really that clear/noticable ๐คท
but once you try you would find out ๐
https://discordbots.org/api/bots/458431964119040000/owners
Correct?
Uh got a issue
import requests
IsOwner = requests.get('https://discordbots.org/api/bots/458431964119040000/owners')
print(IsOwner)
404 Response
Oof
Oh
the response is the bot object
import requests
IsOwner = requests.get('https://discordbots.org/api/bots/458431964119040000')
print(IsOwner)
So like that
not familiar with python, but you need to get the "owners" property from the json response
Kk
I got a response 200 error
200 is "ok"
Yeah
It popped up as a error
One mintue
import requests
import json
IsOwner = requests.get('https://discordbots.org/api/bots/458431964119040000').json()
print(IsOwner)
Yep
IT works now
anyone know how to find a channel by id?
Can't find how to anywhere, and I forgot how to XD
discord.js
๐
Quick Discord.js question, for a ReactionCollector,if you want to collect all the reactions, what should I put as the filter?
I would assume empty filter or no filter or always true returning filter
But I don't d.js so
I need help with postgresql.. It refuses my connections.. If somebody can help me, please send me a dm or something :c
Have you tried not using SQL?
I want a solution, not a workaround
What error does it give? Are you maybe not closing existing connections
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:238)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnection(Driver.java:454)
at org.postgresql.Driver.connect(Driver.java:256)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at main.java.Main.main(Main.java:34)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.postgresql.core.PGStream.<init>(PGStream.java:69)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:152)
I tried every fix i could find.. None worked.. If its not up, how can i start it? If its not bound to that, how can I do it? I would also like to access it from my computer, not from localhost
What OS is it on?
And you are trying to access the database on localhost??
You do realize that it will try to access the loopback, which is your own machine
If I ask you do make something clear to me, then please don't answer the same way
Now, what computer is the client???
And also what computer is actually running the database
Guys how to use routing
any example how to post server count to discord bots
here is better but there no one give any examples
the only thing i found on internet that i should install express
yeah
i knew that
@quartz kindle can you give me any example
just how and where can i put the token
you can use the official dbl api
npm install dblapi.js
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
or make your own POST request using any http connection or http lib
what do you mean routing?
What kind of fucking routing are you even asking about? 
wait
i think it was wrong value :Error:
How to use this api
GET and post
what kind of functions is that

great
great
But how to make http request
const snekfetch = require('snekfetch');
const key = 'YOUR DBL KEY';
snekfetch.post(`https://discordbots.org/api/bots/${bot.user.id}/stats`)
.set('Authorization', key)
.send({ server_count: bot.guilds.size,
shard_count: bot.shard.count,
shard_id: bot.shard.id })
.then(() => console.log(`Posted to dbl.`))
.catch((e) => console.error(e));```
if i used this will it work ?
i will change some values
i will try that
yes
You should also work on understanding the code you are using instead of just copying code
yeah i do
and also, snek is deprecated
but when i asked them they said you don't need any module
you dont
here i use snekfetch
i will check that
@neon swift The database runs on the debian computer. My bot runs there too but while im testing im running the bot on the windows computer.
snekfetch is just a package that makes http easier
That clear?
yeah
there are other packages like snekfetch
yes but it will be outdated
and probably will stop working on newer nodejs versions
@floral zinc localhost means the database is only accessible on the local computer. so if the database is on debian, you can only access it from within debian

this is node-fetch
then the database is either not working or misconfigured
@floral zinc i cant help you with java, but check if your postgre is working by trying to access it directly via the terminal
last publish, and why don't you work on understanding requests instead of worrying about what's on the npm info?
Tim i already know its not the code that makes it fail. Its postgre itself or my vserver
So maybe you can help me there.
because 
is the port opened, and are you accessing it with the corret IP if the db is on a diff server?
he said its on the same server
psql DBNAME USERNAME
how do I uninstall postgre agane? I think I messed something up in the config
also, from a google search
1) Your postgresql is binded only on 127.0.0.1 address and you want to ask him from other computer. In this case you have to check postgresql.conf file and check line beginning listen_addresses. There have to be '*'. Or you can use firewall and you have protected access to port 5432, which is default Postgresql port.
2) You have set bad permissions in file pg_hba.conf. Please, check this file, it obviously have some commented examples.```
sheesh just use docker :^)
can you connect to it via terminal?
I got it working. turns out the listen_addresses is only a comment by default, didnt notice that
XD
oh lmao
๐
Thanks you guys :3 Everything works now
How long does it usually take to verify a discord bot?
thanks
Np
Could someone help me with canvas?
I'm trying to add the user's avatar to a blank image using ctx.drawImage(message.author.avatarURL, 0, 0); and I'm getting this error:
- (node:17553) UnhandledPromiseRejectionWarning: TypeError: Expected object, number and number
I don't think canvas accepts url's.
specially not remote urls
you have to download the remote image with an http request
and convert it into a buffer or a base64 dataurl
then you can feed it to canvas
actually you can try using an image element
but idk if it accepts remote urls
img.src = 'imageurl.png';
ctx.drawImage(img, 0, 0);
Ah, okay.
I get an error saying the image was done loading by the time it got to ctx.drawImage(). How do I prevent that?
img.onload = function() { alert("Height: " + this.height); }
img.src = "http://path/to/image.jpg";```
put the drawimage inside the onload function
i havent tested this, but it should work
Okay.
I tried using it and I'm not getting any errors, but the image that's sent is blank.
var img = new Image(), buf = new Buffer(message.author.avatarURL);
img.src = buf.toString('base64');
img.onload = function() { ctx.drawImage(img, 0, 0); };
let attachment = new Discord.Attachment(canvas.toBuffer(), 'test.png');
return message.channel.send('', attachment);
you should download the image to make a buffer out of it
How do I do that?
img.src = buf.toString('base64');``` i dont think this is how it works
you're creating a buffer from a string
not the image itself
img.src accepts urls, so try that
without buffers
if it doesnt work, then you need to download the image using an http request
with something like node http, node-fetch, request, etc
Okay.
How do I react to a message with the number characters? 1โฃ 2โฃ 3โฃ etc.
should be the same as any other emoji
google the unicode version of them
The unicode doesn't work
This is the unicode 1๏ธโฃ
It's 2 characters
And using the \u tag doesn't work either
it should work
Well it doesn't
msg.react("1๏ธโฃ")
iirc you can do .react(":one:") (In what ever lang)
:one: doesn't work either
you can't react a dicksword emote
Whats the rest of your code look like
@deep inlet what lib
:one: only works in Discord, not code

what lib
Whats your code snippet?
Eris
I can help
Well you never know
I need a snippet to diagnose possible issues
and errors
What error are you getting
Invalid emoji
The error doesn't really matter
The problem is: I can't react with a number emoji
And whats the .react() code look like exactly
:one: works in d.js
That's because you're sending it in Discord
d.js is bae
actually
@deep inlet Whats your .react() line look like
So there has to be something I'm missing
i think its based off of libs
Why?
Why cant you just send the 1 line
1โฃ = 1โฃ



please say yes