#development

1 messages ยท Page 463 of 1

viscid falcon
#

yes

quartz kindle
#

how are you converting it into an emoji object?

viscid falcon
#

i dont think i am, how would i do that (sorry if this is a dumb question)

quartz kindle
#

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

viscid falcon
#

i think i understand now thanks

#

wait

#

then what would i do witht the unicode emoji, how would i get the url from thaat?

quartz kindle
#

no idea, but the url belongs to the Emoji object

#

maybe Emoji(unicode)

#

let me check actually

earnest phoenix
#

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

night imp
quartz kindle
#

@viscid falcon nope, didnt find a way to use default emojis

#

but you could build your own database with their urls lmao

viscid falcon
#

i may have found a way, let me check

quartz kindle
#

i dont get it @earnest phoenix

viscid falcon
quartz kindle
#

you want to make it both with prefix and with mention as the prefix?

earnest phoenix
#

Yeah

quartz kindle
#

@viscid falcon easy

#

const twemoji = require('twemoji');

viscid falcon
#

oh

quartz kindle
#
        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

viscid falcon
#

well thanks for all your help!

#

this server is always great for when im stuck

quartz kindle
#

@earnest phoenix you have to separate your command first, if it came from a prefix or from a mention

earnest phoenix
#

Oh I can do that

quartz kindle
#

something like ```
if(msg.startsWith(prefix){
get arg by splitting prefix
} else if(msg.startsWith(mention)) {
get arg by splitting mention
})
//continue

earnest phoenix
#

okay yeah I was thinking that but I thought there was an easier way

quartz kindle
#

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

earnest phoenix
#

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

quartz kindle
#

yeah

#

but do you want to accept mentions from anywhere in the message?

#

or only beginning with the mention?

earnest phoenix
#

only beginning

#

but I couldn't find a better way I guess i could use <@ ID>

quartz kindle
#

yeah, do a check for both <@id> and <@!id>

#

or was it !@id? i dont remember

#

nah i think it was the first one

earnest phoenix
#

@earnest phoenix

#

Yeah its the first one

#

for nickname I'm guessing

quartz kindle
#

<@!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

earnest phoenix
#
 if(!(msg.startsWith(Bot.config.prefix.toLowerCase()) || ))```
#

Was starting to do something like tihs

#

lul

#

msg = message.content.toLowerCase()

quartz kindle
#
var array = ["<@id>","<!@id>",customprefix];
if(array.indexOf(msg.content.split(" ").toLowerCase()) > -1) {
    //continue
}
sick cloud
#

i just use an includes for mine usually

quartz kindle
#

yeah includes is shorter, im just too used to indexof

sick cloud
#
if (['!', '<@id>'].includes(msg.content[0]/*prefix thing*/)) { ...```
inner jewel
#

i just use an if-else chain of startsWith

earnest phoenix
#

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

quartz kindle
#

i dont think you need this <@${id}>

#

you can just hardcode your bot's id

viscid falcon
#

when im using .id on custom emojis it just return undefined (im using discord.j)

quartz kindle
#

it wont change

inner jewel
earnest phoenix
#

I know but I'm probably going to use this handler on multiple bots in the future

quartz kindle
#

ah i see

earnest phoenix
#

Natan

#

that looks confusing

#

lmao

#

well idek what .increment() is so I'm retarded

inner jewel
#

it's for tracking stats

#

internal trackers for which types of prefix are used

earnest phoenix
#

oh

inner jewel
#

UsageTrackers.prefixes returns a group, tracker(...) returns the tracker for that key, increment() adds one

quartz kindle
#

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); };

viscid falcon
#

when im using .id on custom emojis it just return undefined (im using discord.j) sorry that i already mentioned it

earnest phoenix
#

weird GWfroggyBlobWokeThink

#

are you getting the emoji correctly?

viscid falcon
#

tickYes.id is basicly what im doing

earnest phoenix
#

if you just want the id use \:emoji:

quartz kindle
#

it should be client.emojis.get()

earnest phoenix
#

Yeah

#

hm tim

#

what if someone does like

#

@earnest phoenixhelp

#

the split wouldn't work GWfroggyBlobWokeThink

sick cloud
#

who does that

quartz kindle
#

well, i dont respond to anything without spaces

#

i just ignore it

earnest phoenix
#

or if they put 2 spaces

quartz kindle
#

user typo, they should fix it themselves

earnest phoenix
#

true

viscid falcon
#

so would i use client.emoji.get(tickYes) ?

earnest phoenix
#

in quotes

#

btw

#
client.emoji.get(":tickYes:").id
viscid falcon
#

thanks

quartz kindle
#

idk if get works with that or only with ids

earnest phoenix
#

idk how that get works

#

lmao

#

you can use .find('name', "tickYes")

#

probably

sick cloud
#

no

quartz kindle
earnest phoenix
#

sorry am bad at js here

sick cloud
#

exactly tim

quartz kindle
#

stupid arrow functions

#

i dont use them lmao

sick cloud
#
<Client>.emojis.find(e => e.name === 'tickYes');
quartz kindle
#

i just do .find(function(a){code})

sick cloud
#

should work

#

ouch

viscid falcon
#

and what would name be? :emoji:?

quartz kindle
#

i guess

earnest phoenix
#

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

quartz kindle
#

splice changes the original

#

slice doesnt

#

so .split().splice(0,1) would remove the first item

earnest phoenix
#

would that work with slice too then? ๐Ÿค”

quartz kindle
#

it would

earnest phoenix
#

wew im learning new things okie

quartz kindle
#

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

earnest phoenix
#

okay

quartz kindle
#

jesus fucking christ are you serious

#

can someone verify this test is not broken? lmao

inner jewel
#

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

viscid falcon
#

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

inner jewel
#

which also applies to JS

quartz kindle
#

it cant be my gc, the test logs results from other users/browsers, all are identical

#

i think that specific test code is flawed

inner jewel
#

does changing the benchmark order affect results?

#

eg running the last test first

quartz kindle
#

i dont believe i can change the order

earnest phoenix
#

ReferenceError: args is not defined welp

#

I don't need async GWjiangoOmegaLUL

#
   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

viscid falcon
#

i think you might need to define args out side of the if statements

#

for the console.log

inner jewel
#

const is lexically scoped

quartz kindle
#

i think you can set them inside ifs

earnest phoenix
#

lemme just remove const

#

lmao

#

node.js

#

thanx

quartz kindle
#

i thing you dont need the slice in the first if

inner jewel
earnest phoenix
#

Yeah I do

quartz kindle
#

you already confirmed the message does start with the prefix, so you can just split it with a space, and remove it

inner jewel
#

also don't remove const

earnest phoenix
#

Tim the prefix can have spaces in it

quartz kindle
#

oh

knotty steeple
#

@inner jewel whats jsx

inner jewel
#

if(!content.startsWith(prefix)) return;
const args = content.substring(prefix.length).split(/ +/g)

#

react stuff

viscid falcon
#

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

knotty steeple
#

oh ok

inner jewel
#

why js e.name === `args[0]` instead of js e.name === args[0]?

viscid falcon
#

oh yeah forgot that

#

but besides that would that work?

earnest phoenix
#

I got it to work with 2 if statements

#

but the splice removes one starting argument GWjiangoOmegaLUL and not the prefix

#

Guessing I change this .splice(0, 1); 1 to zero?

#

or wait -1

#

lemme google

quartz kindle
#

iirc its splice(index,amount to remove)

earnest phoenix
#

Yeah it is

#

!test
@mention test


[ 'test' ]
[ '@humble pine' ]```
#

thats the output

quartz kindle
#

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

earnest phoenix
#

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);```
shell blade
#

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".

shy rose
#

whats the url your trying to send?

#

aka add a print statement and and check your sending what you think

shell blade
shy rose
#

oh ok you cant send that kind it must be in buffer form

shell blade
#

Ah.

shy rose
#

afik canvas has option to export to type buffer

shell blade
#

Should this work?

#
let buf = new Buffer(canvas.toDataURL());
return message.channel.send(new Discord.RichEmbed().setImage(buf.toString()));
shy rose
#

url != buffer

shell blade
#

Okay. How do I buffer it using canvas, then?

shy rose
#

read teh docs ๐Ÿ˜›

#

message.channel.send(new Discord.RichEmbed().setImage(canvas.toBuffer()) at a guess

shell blade
#

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()?

shy rose
#

so presumably you already have pre existing canvas code thats how you got URI right?

shell blade
#

Correct.

#

I used canvas.toDateURL() to get the URI.

shy rose
#

so then call .toBuffer on the thing you were calling .toURL() on

shell blade
#

Okay.

#

I guess not.

- (node:15552) UnhandledPromiseRejectionWarning: TypeError: canvas.toDataURL(...).toBuffer is not a function
shy rose
#

;-;

shell blade
#

I'll check the docs.

shy rose
#

you repalce to toURL to buffer

shell blade
#

I did.

shy rose
#

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

shell blade
#

I did before that.

#

I'll try again.

#
- Could not interpret "{u'data': [...], u'type': u'Buffer'}" as string.
shy rose
#

uh

#

can you send your code where it errors

shell blade
#
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()));
shy rose
#

uh

#

does djs do something wack with upload

shell blade
#

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 ๐Ÿคฆ

shy rose
#

ok got it you need files not file on the embed

#

file is for string type aka urls but files is buffer type

shell blade
#

When attaching it?

shy rose
#

this is in the djs send embed thingy

shell blade
#

I'm not sure what you mean.

shy rose
#

message.channel.send(new Discord.RichEmbed().files(canvas.toBuffer()));

shell blade
#

Oh, okay.

shy rose
#

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

shell blade
#

I'll take your "really dumb" idea.

shy rose
#

message.channel.send(new Discord.RichEmbed().files(new Discord.Attachment(canvas.toBuffer(),"why-djs.png")));

#

brackets may be off

shell blade
#

.files() isn't a function.

#

I found something that works, but only as an attachment.

shy rose
#

attachFiles

#

reading the prototypes rip me

shell blade
#

:p

#

Thanks for helping haha.

shy rose
#

that do it

#

?

shell blade
#

Yep.

#

Surprisingly.

shy rose
#

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

quartz kindle
#

i use the attachment method too lol

shy rose
#

oof

quartz kindle
#

i use it with callbacks

#

and promises

alpine lark
slender thistle
#

Yes

alpine lark
#

I keep getting SyntaxError: invalid syntax

quartz kindle
#
canvas.toBuffer(function(err, buf){
    resolve(buf);
});
msg.channel.send({"files":[new discord.Attachment(image, "chart.png")]}) //image is the resolved buffer```
slender thistle
#

Send the code that is breaking :p

alpine lark
#
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 :)")```
slender thistle
#

???
from discord.ext.commands import Bot???
commands.Bot???

#

from discord.ext import commands is the way

alpine lark
#

still dosnt work

slender thistle
#

What is the error now

alpine lark
#

same thing

slender thistle
#

Full traceback pls

alpine lark
#
  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```
slender thistle
#

Right

alpine lark
#

i do

slender thistle
#

Well, Python doesn't think so

shy rose
#

windows+python+modules=not fun

slender thistle
#

pip show discord.py in command prompt please

alpine lark
#

still error

slender thistle
#

wut

#

Did you even use that in command prompt and not in your code

alpine lark
#

yes

slender thistle
#

How the hell did you get an error even

#

What is the error

alpine lark
#
  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```
earnest phoenix
#

SyntaxError: invalid syntax Thonk wonder what could be problem

slender thistle
#

Close your bot for now

#

Open command prompt

alpine lark
#

yes

shy rose
#

if your on windows there a whole ton of hoops to jump through to use pip

slender thistle
#

Is that so

earnest phoenix
#

install python and use pip GWfroggyWeSmart

#

hoops btw

alpine lark
#

i ran pip show discord.py

slender thistle
#

And then, if you have pip installed, pip show discord.py GWchadThink

#

And what was the output?

shy rose
#

oh pugs there updated pip

#

friggen yes it actually registers to path

#

nvm what i was saying then

#

used to not register to path

alpine lark
#
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:```
slender thistle
#

Aight, that's async GWchadThink

#

Wait

#

Python3.7?

#

I doubt it even supports 0.16.12

alpine lark
#

i installed the latest python today

slender thistle
#

Move to 3.6 :^)

alpine lark
#

is there a command i can do to downgrade or no?

slender thistle
#

A command, eh? GWchadThink
Nope, uninstall Python3.7 and install... uh... Python3.6? Unless I am confusing rewrite branch with async

solid cliff
slender thistle
#

And I am assuming pip install discord.py does not have Python3.7 supported :^)

spring ember
#

Nothing supports Python 3.7

boreal acorn
#

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

earnest phoenix
#

@boreal acorn you have the wrong/no auth header with your request

spring ember
#

You didn't put a valid token

boreal acorn
#

It keeps changing

earnest phoenix
#

not your discord token

boreal acorn
#

Ik the dbl token. It keeps changing and all of my other tokens are good

wild tide
#

NO

#

Tom

#

there can only be 1 baldi

earnest phoenix
wild tide
#

fight meh D:

quiet bobcat
#

that has nothing to do with development @wild tide @earnest phoenix

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);
});
}

slender thistle
#

Isn't it .catching error instead of ifs?

earnest phoenix
#

what do you mean by that?

#

I'm still a beginner and I do not know too many things!!!

slender thistle
earnest phoenix
#

Thanx you.๐Ÿ˜€

latent heron
#
@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

slender thistle
#

Got id defined anywhere?

#

Is type(id) tuple?

latent heron
#

im not quite sure

#

the problem has gone away however

#

i guess python had a burp moment but im really disturbed as to why

unborn crow
#

xD

latent heron
#

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

earnest phoenix
pale marsh
#

Show us your code

earnest phoenix
#
    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})
  },```
latent heron
#

it could be an issue with how you're handling the split

sick cloud
#

Your not joining the reason

latent heron
#

oh yeah

#

you aren't joining/imploding with spaces again

sick cloud
#

It's an array, so it's going x,y,z

pale marsh
#

let reason = msg.content.split(" ").slice(2).join(' ');

latent heron
#

well if it was an array shouldn't it show the brackets [] too?

#

or does JS not do that in this case

pale marsh
#

No idea tbh

latent heron
#

wait

#

huh

pale marsh
#

@latent heron who's that?

latent heron
#

im actually confusion

earnest phoenix
#

ty it works

pale marsh
#

Also wrong channel

earnest phoenix
#

its a private bot I made for a server @latent heron

latent heron
#

i see

#

whats your bot on here

#

since Luca is being mean to me

earnest phoenix
earnest phoenix
#

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?

earnest phoenix
#

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

slender thistle
#

Because there is no message nor msg defined?

earnest phoenix
#

msg is defined but it says its not

slender thistle
#

Is it defined in another function?

earnest phoenix
#

yes

slender thistle
#

Well, that's the problem mmLol

earnest phoenix
#

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*

wild tide
uncut slate
#

kinda self explanatory

wild tide
#

I've never seen it ._.

#

is it usable?

jagged plume
#

neither have i but i was able to make a pretty accurate guess as to what it was

wild tide
#

lol

jagged plume
#

if you get a response from it, yes

wild tide
#

hmm

latent heron
#

i mean

#

im sure that if it didn't work the link wouldn't exist but

#

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

eager spoke
#

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

ruby dust
#

with d.py, what's the best way to delete messages containing invite links without looking for discord.gg in the link?

restive silo
#

im pretty sure you need to look for discord.gg to do that

#

use a RegEx

ruby dust
#

ok, thanks for that

#

another question

#

can there be more than one of the same event defined in the same file? actually nvm that

wind pine
#

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);
})
earnest phoenix
#

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

#

is that Discord Js?

wind pine
#

yea

earnest phoenix
#

btw do you know how i can get user avatars on my website to automatically update?

viscid falcon
#

What are the avatars for, anyone who used the bot? Or for specific people?

pale marsh
#

Avatar = profile pics

earnest phoenix
#

for my website, yes for me

#

I want it to automatically update when i change it here (on discord)

earnest phoenix
#

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

#

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

knotty steeple
#

you can use module.exports GWcmeisterPeepoShrug

#

module.exports.run = () => {}

earnest phoenix
#

so i was right?

knotty steeple
#

ye

earnest phoenix
#

yay

knotty steeple
#

but i do exports.run because its shorter :v

earnest phoenix
#

:c

knotty steeple
#

well both work so

earnest phoenix
#

well good enough

floral zinc
#

Is it somehow possible to get the memory used by only the Bot in java?

inner jewel
#

you have two options

#

the methods in Runtime, or getting the memory mxbeans from ManagementFactory

floral zinc
#

but runtime is for the entire runtime..

#

I only want the memory used by my Application

inner jewel
#

Runtime is for the jvm process

#

you can only get for the vm process without massive overhead

floral zinc
#

okay, will have to do, thanks c:

inner jewel
#

another option would be manually counting the referenced memory but that's extremely slow

#

and you'd need to handle circular references

floral zinc
#

Uh no thanks :p

floral zinc
#

thanks ;3

inner jewel
#

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

floral zinc
#

Okay

inner jewel
#

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

floral zinc
#

Ah okay thanks alot :3

inner jewel
#

nonheap can be used by java but only indirectly (eg ByteBuffer.allocateDirect()) and generally won't matter for bots

craggy roost
#

Everything seems right

inner jewel
#

@craggy roost check if the bot has MANAGE_MESSAGES

craggy roost
#

Bot is ADMINISTRATOR

#

This command is working in my personal server

#

But other server has this error

floral zinc
#

Well then maybe its is not ADMINISTRATOR on those other servers..

craggy roost
#

Has a unique role

#

So the manager is in this role

ruby dust
#

there's a chance that they removed the integrated role permissions, or simply didn't include it before adding bot to server

craggy roost
#

How so? Could they have left their own role?

inner jewel
#

even if you request admin perms in the bot invite link, users can remove them

craggy roost
#

Hmm. How can I fix this problem of authority? If they can. There must be a way.

inner jewel
#

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

craggy roost
#

I understand.

#

How are we going to adapt this customer. new msg.member.hasPerm ..... will change to what?

floral zinc
#

Just check if the bot has the permissions in that channel and if not, send the owner a pm or do nothing

craggy roost
#

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! ๐Ÿ˜ก

floral zinc
#

If you dont know what the stuff returns, check the docs..

earnest phoenix
#

Im trying to add a reload command to me command handler, It works. But does not update the code when reloading the file

floral zinc
#

I only do java, cannot help you there

earnest phoenix
#
delete require.cache[require.resolve(`./${reloadCommand}.js`)];
#

?????

latent heron
#

manually restart the file then

#

if the command works for the other files then there should be no prob

earnest phoenix
#

@latent heron But look

#

A guy aready joined and didnt know

#

It simply just doesnt update the command

latent heron
#

i dont read coffeescript

earnest phoenix
#

๐Ÿ˜ฆ

latent heron
#

sorry

earnest phoenix
#

oof

#

its js

#

idk

#

kek

#

Why does my bot send every message 2 time

#

maybe its running twice?

#

Every command does it

boreal acorn
#

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

quasi marsh
#

DBL library is incompatible with sharded bots

boreal acorn
#

do you know how to make it work then?

quasi marsh
#

You need to develop a seperate webhook solution, like a regular webserver and connect that up to your bot's database

boreal acorn
#

how do you do that?

icy matrix
#

hello can somone here help me with bash ?

earnest phoenix
#

@quasi marsh Hey, you busy? Would you be able to take a look at something for me please? Sorry bout the ping also

icy matrix
#
#! /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 ?

upper ember
#

how do I check if the amount variable contains -, . or +?

earnest phoenix
#

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? ๐Ÿค”

latent heron
#

I think what happens is that even though you dont specify it in the code

#

the bot does 2 connections

earnest phoenix
#

Who me?

latent heron
#

just close the whole script

earnest phoenix
#

@latent heron Who are you speaking to lol

latent heron
#

no

#

@earnest phoenix

earnest phoenix
#

ok

eager spoke
#

@icy matrix what do you want to do with your bash script?

knotty steeple
#

how do i make discord.js not use much memory

misty lagoon
#

does anyone here use Heroku?

#

I have a question for it

eager spoke
#

Go to their support server

#

Nvm isnt a bot xd

sick cloud
#

@misty lagoon just ask

misty lagoon
#

ask aho

#

who

viscid falcon
#

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))

misty lagoon
#

do ArrayName[numberinarray]

#

i think

viscid falcon
#

its not a specific number though i mean any item from the array

misty lagoon
#

oh

#

ok

eager spoke
#

Nested loop?

misty lagoon
#

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

eager spoke
#

And if you found a match break your loop :3

sick cloud
#

can you not send your messages in multiple @misty lagoon

misty lagoon
#

ok

sick cloud
#

and literally just ask

misty lagoon
#

ask who?

sick cloud
#

just ask your question here, your not asking anyone in specific bloblul

misty lagoon
#

umm

#

oh

#

Does anyone know why Heroku isnโ€™t hosting 24/7? after closing the tab about 4 minutes later it stops.

viscid falcon
#

so would it be like for (var i = array.length; i > array.length; i--)

#

im bad at for loops sorry

misty lagoon
#

yup

#

and put a array[i]

sick cloud
#

heroku goes down after a while

misty lagoon
#

and do the checker inside

#

oh

viscid falcon
#

ok thanks

sick cloud
#

tbh, i'd use glitch

misty lagoon
#

glitch is harder

sick cloud
#

you can get it on 24/7 with uptimerobot iirc

misty lagoon
#

ok

sick cloud
#

why not buy a vps

#

easy as

misty lagoon
#

i donโ€™t want to spend money on this

sick cloud
#

well

#

it's the better idea

#

but ok

misty lagoon
#

yea

inner jewel
#

you can get 24/7 on heroku as well

#

doing basically the same uptimerobot does

sick cloud
#

oh right, you ping it or something?

viscid falcon
#

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

sick cloud
#

i see what you wanna do

misty lagoon
#

how do you ping it then

sick cloud
#
if (['item', 'item'].includes(message.content /*or whatever*/)) { ...```
@viscid falcon
#

thats the best way

viscid falcon
#

thanks

#

whats item? do i need to change that?

sick cloud
#

duh lol, thats the array. your basically calling .includes on an array

#

so change that to an array variable, or fill it with whatever

viscid falcon
#

oh lol, sorry i just got home from school im tired

wide ruin
#

What's the error?

misty lagoon
#

idk

#

hover your mouse on top of the red dot

wide ruin
#

Mobile

#

Ugh

#

But it had been working fine

sick cloud
#

try run it and see lul

viscid falcon
#

am i using this for loop wrong? nothing inside it works
for (var i = ShardInitiateDouble.length; i > ShardInitiateDouble.length; i--) {

misty lagoon
#

i donโ€™t think so.

#

did any errors pop up?

zealous veldt
#

have you tried restarting it?

viscid falcon
#

no

#

yes i have tried restarting it

quartz kindle
#

do you need the index?

misty lagoon
#

what library are you using?

viscid falcon
#

discord.js

quartz kindle
#

you can do

misty lagoon
#

ok

quartz kindle
#

while(i--)

#

its much faster

viscid falcon
#

how do i use a while loop?

quartz kindle
#
var i = array.length;
while(i--) {
    //code
}```
viscid falcon
#

ok il try that

quartz kindle
#

make sure i never gets to negative values tho

#

or it will become an infinite loop

viscid falcon
#

how do i prevent that

#

oh wait nvm

#

just an if statement right?

fierce thorn
#

Why var god

#

use let

misty lagoon
#

yeah thatโ€™s true

viscid falcon
#

if (i < 1) {
return
}

zealous veldt
#
let me = "be free"```
viscid falcon
#

ik what let was, just had a derp and forgot what it was called so i just used var

quartz kindle
#

i always use var lol

#

im old fashioned

viscid falcon
#

yeah it doesnt rlly matter though

fierce thorn
#

let is better :D

viscid falcon
#

sources?

quartz kindle
#

there isnt any performance difference, just scoping difference afaik

zealous veldt
#

let is better in most cases

#

because scoping

fierce thorn
quartz kindle
#

let doesnt allow you to accidentally modify variables outside of the current scope, but var does

misty lagoon
#

but usually you wouldn't do that

quartz kindle
#

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

misty lagoon
#

yay

zealous veldt
#

which I do, a lot

sick cloud
#

(node:29074) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
why is this happening when my bot's token is valid?

fluid basin
#

Either wrong token or lib issue

sick cloud
#

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?

uncut slate
#

you're better off just asking your question

sick cloud
#

true

uncut slate
sick cloud
#

honestly dunno why, but okie

uncut slate
#

also, if I can offer you some advice - stay away from globals

#

kind of a horrible practice

sick cloud
#

oh

#

alright

restive silo
#

agreed

sick cloud
#

i'm kinda wondering if my config isn't being required right in app.js

inner jewel
#

you can always console.log it

sick cloud
#

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 ๐Ÿ‘€

viscid falcon
#

in js, with return does it just stop processing code or just the if statement its contained in?

sick cloud
#

the current file and code below it iirc

inner jewel
#

the current function

viscid falcon
#

thanks

sick cloud
#

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?

uncut slate
#

try logging options before super()

sick cloud
#

okay

restive silo
#

pretty sure its exports.examples or module.exports but not module

uncut slate
#

that too

sick cloud
#

where would that be tho?

#

i use module.exports

restive silo
#

do exports.examples

#

or module.exports.examples

sick cloud
#

ohhhh in the config

restive silo
#

ye

sick cloud
#

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

deft summit
#

i see that's a rich embed (top one)

#

but whats the one staffbot displays?

bright spear
#

its still an embed

pale marsh
#

No color maybe?

bright spear
#

also this channel is for bot development help

#

its the same color as the dark theme background

pale marsh
#

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

south finch
#

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 jynSUH

#

so

deft summit
#

ohhhh

#

Thanks @pale marsh

pale marsh
#

No problem

earnest phoenix
#

does anyone have any idea of how a call bot could be set up to work with firertc?

quartz kindle
#

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.

earnest phoenix
#

thank you

pale marsh
#

What even is that?

quartz kindle
#

linking a bot to a phone service

pale marsh
#

Oh like an actual phone

#

That's a really neat idea

#

Where did you get that paragraph from though?

quartz kindle
#

googled firertc api

#

first result

viscid falcon
#

if i was good enough i would totally steal get inspiration from that idea

wild tide
#

anyone know how to find a channel by id?

#

Can't find how to anywhere, and I forgot how to XD

sick cloud
#

lib?

glossy talon
#

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

earnest phoenix
glossy talon
#

@earnest phoenix The Question i am asking is how to get the id of the owner of the bot

earnest phoenix
#

its in the response from the api

glossy talon
#

Documentation link to that?

earnest phoenix
glossy talon
#

Does this require tokens? @earnest phoenix

#

For like AIOHTTP getting the info

earnest phoenix
#

nope not for that endpoint

#

once that need auth will say it

glossy talon
#

So i could use something like requests

#

to get the info

earnest phoenix
#

""requires authentication"

glossy talon
#

Ah

earnest phoenix
#

yeah its not really that clear/noticable ๐Ÿคท

#

but once you try you would find out ๐Ÿ˜‚

glossy talon
#

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

earnest phoenix
#

thats not it, its just /bots/{bot.id}

glossy talon
#

Oh

earnest phoenix
#

the response is the bot object

glossy talon
#
import requests

IsOwner = requests.get('https://discordbots.org/api/bots/458431964119040000')
print(IsOwner)
#

So like that

earnest phoenix
#

not familiar with python, but you need to get the "owners" property from the json response

glossy talon
#

Kk

earnest phoenix
glossy talon
#

I got a response 200 error

earnest phoenix
#

200 is "ok"

glossy talon
#

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

wild tide
#

anyone know how to find a channel by id?
Can't find how to anywhere, and I forgot how to XD

discord.js

#

๐Ÿ˜ƒ

sick cloud
#

look at the docs

#

guild.channels or client.channels

zealous veldt
#

Quick Discord.js question, for a ReactionCollector,if you want to collect all the reactions, what should I put as the filter?

neon swift
#

I would assume empty filter or no filter or always true returning filter

#

But I don't d.js so

floral zinc
#

I need help with postgresql.. It refuses my connections.. If somebody can help me, please send me a dm or something :c

zealous veldt
#

Have you tried not using SQL?

floral zinc
#

I want a solution, not a workaround

neon swift
#

What error does it give? Are you maybe not closing existing connections

floral zinc
#
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)

drowsy lily
#

Your database is not up

#

Or not bound to localhost:5432

floral zinc
#

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

drowsy lily
#

What OS is it on?

floral zinc
#

Debian

#

And my computer on windows

neon swift
#

Which one then??

#

or is the server debian and the client windows??

floral zinc
#

yes.

#

VServer is debian

#

And my pc is windows

neon swift
#

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

hot sleet
#

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

quartz kindle
#

routing? what do you mean?

#

you dont need express to post server count

hot sleet
#

yeah

#

i knew that

#

@quartz kindle can you give me any example

#

just how and where can i put the token

quartz kindle
#

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

hot sleet
#

@quartz kindle but ...

#

i meabt discord bots

#

not dbl

quartz kindle
#

this is the dbl server lol

#

you'll only get help for dbl here

hot sleet
#

i asked nor routing

#

for*

#

am i ?

quartz kindle
#

what do you mean routing?

hot sleet
#

idk

#

nvm

#

discord bots sucks

#

discord bots *

#

Edit : Discord bots sucks

slender thistle
#

What kind of fucking routing are you even asking about? GWmemetownOMEGALUL

hot sleet
#

wait

#

i think it was wrong value :Error:

#

How to use this api

#

GET and post

#

what kind of functions is that

karmic parcel
quartz kindle
#

you make an http request

#

to website.com/api/users/userid

hot sleet
#

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

quartz kindle
#

yes

karmic parcel
#

You should also work on understanding the code you are using instead of just copying code

hot sleet
#

yeah i do

karmic parcel
#

and also, snek is deprecated

hot sleet
#

but when i asked them they said you don't need any module

quartz kindle
#

you dont

hot sleet
#

here i use snekfetch

quartz kindle
#

you can use node http

hot sleet
#

i will check that

floral zinc
#

@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.

quartz kindle
#

snekfetch is just a package that makes http easier

floral zinc
#

That clear?

hot sleet
#

yeah

quartz kindle
#

there are other packages like snekfetch

hot sleet
#

ik

#

but its the best

quartz kindle
#

snekfetch is not the best

#

they are shutting down

hot sleet
#

but when they do

#

the module will still work

#

RRight ?

#

GWfroggySadCat please say yes

quartz kindle
#

yes but it will be outdated

#

and probably will stop working on newer nodejs versions

hot sleet
#

yeah when they shutdown

#

oh

#

they did

#

Searching for new http requests module

quartz kindle
#

@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

hot sleet
floral zinc
#

i know and the error comes from the test on the debian computer.

#

So it should work

hot sleet
#

this is node-fetch

quartz kindle
#

then the database is either not working or misconfigured

floral zinc
#

I am asking for help, i know something is wrong

#

I dont want to know if, but how

hot sleet
#

what

#

node-fetch is the same

#

just the name changed

quartz kindle
#

@floral zinc i cant help you with java, but check if your postgre is working by trying to access it directly via the terminal

karmic parcel
#

last publish, and why don't you work on understanding requests instead of worrying about what's on the npm info?

floral zinc
#

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.

hot sleet
#

because GWqlabsOilUp

earnest phoenix
#

is the port opened, and are you accessing it with the corret IP if the db is on a diff server?

quartz kindle
#

he said its on the same server

floral zinc
#

yep. doesnt work on the same either

#

Pretty sure the port is opened

earnest phoenix
#

yeah like tim said i would try via terminal

#

make sure its actually running zoomeyes

quartz kindle
#

psql DBNAME USERNAME

floral zinc
#

how do I uninstall postgre agane? I think I messed something up in the config

quartz kindle
#

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.```
drowsy lily
#

sheesh just use docker :^)

floral zinc
#

Thats not helping.

#

Tim I tried all that.

quartz kindle
#

can you connect to it via terminal?

floral zinc
#

I got it working. turns out the listen_addresses is only a comment by default, didnt notice that

#

XD

quartz kindle
#

oh lmao

earnest phoenix
#

๐Ÿ˜‚

floral zinc
#

Thanks you guys :3 Everything works now

loud helm
#

How long does it usually take to verify a discord bot?

west raptor
loud helm
#

thanks

west raptor
#

Np

shell blade
#

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
gilded blaze
#

I don't think canvas accepts url's.

quartz kindle
#

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);
shell blade
#

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?

quartz kindle
#
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

shell blade
#

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);
earnest phoenix
#

you should download the image to make a buffer out of it

shell blade
#

How do I do that?

quartz kindle
#
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

shell blade
#

Okay.

deep inlet
#

How do I react to a message with the number characters? 1โƒฃ 2โƒฃ 3โƒฃ etc.

bright spear
#

should be the same as any other emoji

quartz kindle
#

google the unicode version of them

deep inlet
#

The unicode doesn't work

#

This is the unicode 1๏ธโƒฃ

#

It's 2 characters

#

And using the \u tag doesn't work either

quartz kindle
#

it should work

deep inlet
#

Well it doesn't

quartz kindle
#

msg.react("1๏ธโƒฃ")

cerulean zinc
#

iirc you can do .react(":one:") (In what ever lang)

deep inlet
#

:one: doesn't work either

trim saddle
#

you can't react a dicksword emote

cerulean zinc
#

Whats the rest of your code look like

trim saddle
#

it has to be unicode

#

unless its custom

deep inlet
#

Wait wait wait

#

Hold on

cerulean zinc
#

kk

#

I need some more code to see whats going on

bright spear
#

@deep inlet what lib

deep inlet
#

:one: only works in Discord, not code

cerulean zinc
bright spear
#

what lib

cerulean zinc
#

Whats your code snippet?

deep inlet
#

Eris

cerulean zinc
#

I can help

deep inlet
#

Bruh

#

It's not the code

cerulean zinc
#

Well you never know

deep inlet
#

BRUH

#

OTHER REACTIONS WORK

cerulean zinc
#

I need a snippet to diagnose possible issues

#

and errors

#

What error are you getting

deep inlet
#

Invalid emoji

#

The error doesn't really matter

#

The problem is: I can't react with a number emoji

cerulean zinc
#

And whats the .react() code look like exactly

bright spear
deep inlet
#

That's because you're sending it in Discord

cerulean zinc
#

d.js is bae

trim saddle
#

actually

deep inlet
#

So it's getting the raw

#

In code, I tried the raw and it doesn't work

cerulean zinc
#

@deep inlet Whats your .react() line look like

deep inlet
#

So there has to be something I'm missing

trim saddle
#

i think its based off of libs

deep inlet
#

Derp

#

Does it matter if other reactions work?

cerulean zinc
#

You gotta send that 1 line or I cant help

#

Yes it does

deep inlet
#

Why?

cerulean zinc
#

Why cant you just send the 1 line

bright spear
#

use 1โƒฃ

#

1โƒฃ

cerulean zinc
#

1โƒฃ = 1โƒฃ