#development

1 messages · Page 417 of 1

tardy hatch
#

ctx.channel.send and pm don t work

night imp
#

get the user

#

and do user.send

tardy hatch
#

To say at command..

#

Wait a sec

shy verge
#

isn't there ctx.user?

tardy hatch
#

I want to make bot to response 2 times

#

One in channel

#

One in dm

#

At command help

shy verge
#

then do that

#

send a message to the channel, then send a message to the user

tardy hatch
#

I don t know how to make bot send dm message

#

To user idk how to set man

shy verge
#

in discord a user is also a DM channel

#

so just do user.send

tardy hatch
#

okay

#

await self.bot.user.say('Hi')
await self.bot.say('Check DM. :>')

#

Is okay or

#

Lmao

#

=)))))))

shy verge
#

say()?

#

are you using and old version of the lib?

tardy hatch
#

No

#

But don t work send and ffs

#

Lmao

#

bot.user.send don t work or .say

#

...

shy verge
#

ctx, not bot bb

tardy hatch
#

ctx don t work :(.

#

U want to see the error?

earnest phoenix
#

yes show the error, maybe someone will give you a hint

tardy hatch
#

Anyone can give me a command for python bot? To send a DM message?

#

For example, i type !help and i want a response in dm

#

And i got this error at ctx

#

Ignoring exception in command invite
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "/root/Potato/cogs/invite.py", line 16, in invite
await ctx.channel.send('Invite me to your server with this link: \n\n<Link>)
AttributeError: 'Context' object has no attribute 'channel'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'channel'

knotty steeple
#

pls

#

codeblock

prime cliff
#

/root/Potato

shy verge
#

#readthedocs

solid cliff
#

There is say and there is a send or something in async forgot what it was but it's something like send(user, message)

tardy hatch
#

Okay

#

I try

solid cliff
#

send_message()

tardy hatch
#

Ok

earnest phoenix
#

Docs? What are those

shy verge
#

documentation

earnest phoenix
#

/s

tardy hatch
#

@solid cliff

#

Ignoring exception in command invite
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "/root/Potato/cogs/invite.py", line 16, in invite
await self.bot.send_message(user, 'Invite me to your server with this link: \n\n<Link>')
NameError: name 'user' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'user' is not defined

ruby dust
#

please, use codeblocks

tardy hatch
#

How))

earnest phoenix
#

Or hastebin

ruby dust
#

the button right below your esc button, put tripple of those one both sides

earnest phoenix
tardy hatch
#

Ok

solid cliff
#

User is not defined

tardy hatch
#

How to define it?

solid cliff
#

By getting the user

tardy hatch
#

Facepalm

#

I want to make this command

#

To do this:

#

'If anyone type prefix invite'

#

'Bot DM with a link'

#

😐

ruby dust
#

get a user that sent that command and send them the content

solid cliff
#

then it would be pass_context=True and add a ctx to the def aaand get user object as ctx.message.author

tardy hatch
#

Ok wait

knotty steeple
#

and people say python is easier

ruby dust
#

depends who says it

solid cliff
#

Rewrite ez angryeyes

ruby dust
#

rewrite is actually much better

knotty steeple
#

send example code

solid cliff
#

Rewrite: user.send("xd")
Async: does not auto context and send_message(user, "xd")

knotty steeple
#

👏

tardy hatch
#

Lmao

#

How can i define member..

ruby dust
#

show your current code

tardy hatch
#
Ignoring exception in command invite
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "/root/Potato/cogs/invite.py", line 16, in invite
    await ctx.message.author('Invite me to *your* server with this link: \n\n<Link>')
TypeError: 'Member' object is not callable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/usr/local/lib/python3.5/dist-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Member' object is not callable
ruby dust
#

ok that's traceback, now mind showing your python code?

tardy hatch
#

Full cog code?

#

Okay, wait a sec

solid cliff
#

Just the command code

tardy hatch
#

Is a cog

#

Ok

#
class invite:

    def __init__(self, bot):
        self.bot = bot
    @commands.command(pass_context=True)
    async def invite(self, ctx):
        """Outputs a url you can use to invite me to your server."""
        await ctx.message.author('Invite me to *your* server with this link: \n\n<Link>')
        await ctx.message.author('Check DM. :>')```
#

*i ll edit last line to send in channel

ruby dust
#

ok, you have the member defined, but you forgot the send as well

solid cliff
#

send_message(user, message) notLikeMiyaButFast

tardy hatch
#

ctx.message.send.author? Or

#

Ok

ruby dust
#

wait is that async?

solid cliff
#

Yus

ruby dust
#

im out then, idk why I was even trying lol

tardy hatch
#
@commands.command(pass_context=True)
    async def invite(self, ctx):
        """Outputs a url you can use to invite me to your server."""
        await ctx.send_message(user, 'Invite me to *your* server with this link: \n\n<Link>')
        await ctx.send_message(user, 'Check DM. :>')```
#

Is okay now?

solid cliff
#

self.bot.send_message

tardy hatch
#

But user is not defined

#

Okay

solid cliff
#

User = ctx.message.author notLikeMiyaButFast

ruby dust
#

is he sending 2 DMs one after another? 👀

tardy hatch
#
@commands.command(pass_context=True)
    async def invite(self, ctx):
        """Outputs a url you can use to invite me to your server."""
        await self.bot.send_message(user, 'Invite me to *your* server with this link: \n\n<Link>')
        await self.bot.say('Check DM. :>')```
solid cliff
#

Try it

tardy hatch
#

K

#

Add and user = ctx.message.author

#

?

solid cliff
#

Yus

ruby dust
#

alright, my turn to get help xd

solid cliff
earnest phoenix
#

is a cog like a module

#

idk py terms

solid cliff
#

Yus

ruby dust
#

before when a message was not found by id it would notify a user about it since I defined that, but now it started spitting 403 errors instead

#

ik code is shit, but it's not public so who cares lol

tardy hatch
#

@ReKT#0001

#
  File "/root/Potato/cogs/invite.py", line 14, in <module>
    user = ctx.message.author
NameError: name 'ctx' is not defined
Unclosed client session```
#

@solid cliff

solid cliff
#

Where are you putting it

tardy hatch
#

At start of code

#
user = ctx.message.author
    
@commands.command(pass_context=True)
    async def invite(self, ctx):
        await self.bot.send_message(user, 'Invite me to *your* server with this link: \n\n<Link>')
        await self.bot.say('Check DM. :>')```
solid cliff
#

Put it inside the def

tardy hatch
#

U can rewrite?

solid cliff
#

What

tardy hatch
#

can you rewrite the code?))

#

To put inside the def

#

*sorry for my bad english :(.

solid cliff
#

?

tardy hatch
#

How to put inside the def?

solid cliff
#

Just cut and paste it in

tardy hatch
#

Ok

solid cliff
#
async def x(self, ctx):
    User = ```
tardy hatch
#

Ok

#

Dome

#

Done

#

File "/root/Potato/cogs/invite.py", line 7, in setup
bot.add_cog(invite(bot))
TypeError: 'Command' object is not callable
Unclosed client session

#

=))))))))))

#

Can help?

#

@solid cliff

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

codeblock pls

tardy hatch
#

@knotty steeple

#

Is okay?

knotty steeple
#

ye

floral stone
#

@tardy hatch remember to put pass_context=True

earnest phoenix
#

how can I fix this?

halcyon abyss
#

First, MessageEmbed Is only for received embed

#

if you want to construct and send one, you have to use RichEmbed

earnest phoenix
#

Ok

#

Thx

earnest phoenix
#

People these days 🤔

topaz fjord
#

Well if your on master is MessageEmbed

loud bear
#

OwO my console is getting spammed with warnings

#

WARNING.discord.state:GUILD_MEMBER_UPDATE refernanceing an unknown member id [id]

#

and its only two ids

#

spamming my console like every few seconds

#

ok seems to have stopped

floral stone
#

any good Ubuntu mysql clients

topaz fjord
#

the command line

sinful lotus
#

I wanna ask if DBL does the servercount adding of the sharded bots

#

or we need to add it ourself before posting it

elder rapids
#

DBL will add for you

sinful lotus
#

thanks

sinful lotus
#
exports.ramUsage = async (client, bot) => {
    let memUsage = [];
    let ramUsage = await client.shard.broadcastEval('process.pid').then(results => {
        results.forEach(pid => {
            bot.pidusage(pid, async (err, stats) => {
                let memory = Math.round(stats.memory / 1024 / 1024)
                console.log(memory)
                memUsage.push(memory) 
            })
        })
        console.log('ForEach Done')
        return memUsageFinal = memUsage.reduce((prev, val) => prev + val, 0)
    }).catch(error => {
        console.log(error)
    });
    return ramUsage
}

is there a way for this code to stop until forEach is done? because it keeps on returning zero due to executing the return command even before the foreach is done

gilded blaze
#

i thought forEach was synchronous

sinful lotus
#

we got the problem its the bot.pidusage was causing it

earnest phoenix
#

use a for loop and await

tardy hatch
#

How to set owner ID? For only owner commands

lament meteor
#

what lib @tardy hatch

tardy hatch
#

Python @lament meteor

lament meteor
#

oh i dont know python but.... here is the concept:
get the message author id

if the message author id is your id run the stuff

spring ember
#

Are you using commands.ext?

craggy cave
#

@tardy hatch just add an if in the command.

#
if ctx.message.author.id == YOURID:
    Do something 
Else:
    await ctx.send("Owner only")
tardy hatch
#

Ok

livid rivet
#

else not with a caps

spring ember
#

He was probably on mobile

#

With auto caps

ruby dust
#

It's easier to just do a check if a user is not the owner, that way you don't have to do the else statement

uncut mirage
#

i'm in the server

#

reloaded page so nvm ^^

earnest phoenix
#

So I sat down and rewrote my help command.

#

Now I am stuck.

uncut mirage
#

lol

earnest phoenix
#

Like when I use the command nothing appears.

fossil portal
#

XD

earnest phoenix
#

Can anyone help me?

#

And there is no error that I see.

#

Which really ticks me off.

#

Can anyone help me???

uncut mirage
#

does your bot even have permissions?

earnest phoenix
#

i have problems with the bot

#

Yes.

#

fs.js:675
10:56 AM
return binding.read(fd, buffer, offset, length, position);
10:56 AM
^
10:56 AM
10:56 AM
Error: EIO: i/o error, read
10:56 AM
at Object.fs.readSync (fs.js:675:18)
10:56 AM
at tryReadSync (fs.js:540:20)
10:56 AM
at Object.fs.readFileSync (fs.js:575:19)
10:56 AM
at Object.Module._extensions..js (module.js:662:20)
10:56 AM
at Module.load (module.js:565:32)
10:56 AM
at tryModuleLoad (module.js:505:12)
10:56 AM
at Function.Module._load (module.js:497:3)
10:56 AM
at Module.require (module.js:596:17)
10:56 AM
at require (internal/module.js:11:18)
10:56 AM
at Object.<anonymous> (/app/node_modules/ws/index.js:3:19)

#

this

#

My bot has the permissions.

jovial sable
#

?

#

whatup

earnest phoenix
#

look up

fluid basin
#

Its an IO error

#

Most likely related to file IO

#

Yeah its fileIO

#

Can you check the file you are trying to read exists

#

and readable

earnest phoenix
#

?

jovial sable
#

check whether the file location is correct

#

wow you host on glitch?

earnest phoenix
#

yes for now

uncut mirage
#

a lot of people do?

jovial sable
#

yeah i can never get the hang of it

earnest phoenix
#

i'm in the school

#

fuck

jovial sable
#

errors everywheree

earnest phoenix
#

But what file

#

@jovial sable

#

Server.js or what

jovial sable
#

okay where's the file you're trying to access

earnest phoenix
#

I dont understand

#

:/

#

@earnest phoenix YOu new to glitch?

#

I haven't seen anybody use server.js for a bot.

#

And why?

#

JUST WHY?

#

Why are you using views/index.html

#

and cs

#

and js

#

YOu are new aren't you.

jovial sable
#

sorry glitch is just not my thing mascu :(

earnest phoenix
#

I can help.

jovial sable
#

yay

#

thanks savitar

earnest phoenix
#

Np

#

But I would need her/him to delete server.js or just rename it bot.js

jovial sable
#

i use app.js

earnest phoenix
#

And delete so many other.

jovial sable
#

lol

#

such as?

earnest phoenix
#

views/index.html

#

public/style.css and public/client.js

jovial sable
#

when i try hosting on glitch my code just goes crazy

#

so im probs not the best person to ask

earnest phoenix
#

and it would be better if he had a command handler aswell

#

Oh he doesn't have a command handler?

#

Nvm

#

She needs fs command handler so I can help.

#

Fixed

#

Thank you guys

#

Ok.

#

You are welcome i guess.

#

I*

#

@earnest phoenix :+1:

jovial sable
#

mascu are you a he or a she lol

#

we don't know which to use

earnest phoenix
#

@jovial sable /0-0/

#

Boy

jovial sable
#

aye

earnest phoenix
#

Good bot btw @jovial sable

jovial sable
#

???

#

mine?

earnest phoenix
#

Your bot

#

xd

jovial sable
#

wow

#

thanks

earnest phoenix
#

Np

jovial sable
#

it's my first project

earnest phoenix
#

Oh

#

Nice

jovial sable
#

but im hosting it on my pc atm

#

:(

earnest phoenix
#

Uh

jovial sable
#

lol

fossil portal
#

HELP

lament meteor
#

how can we help if we dont know anything just the error

fossil portal
#

What is the cause of the error .. Error: read ECONNRESET

lament meteor
#

idk

earnest phoenix
#

Either all my bot shards are down or my bot commands are broken.

#

Can anyone help me find out?

#

is your bot online

#

Yes.

#

most likely your commands then

#

Wanna see one of my bot scripts?

#

sure

#

that’s look fine but no need for exports.require

#

and is errMsg even an function

#

Where?

#

at top

#

i mean module

#

just put require

#

Ok.

lament meteor
#

module.require -> require('d.js')

earnest phoenix
#

and it be !args[0]

#

not args[0]

lament meteor
#

what is Array.?

earnest phoenix
#

that’s built in

lament meteor
#

o

#

also @earnest phoenix he/she is saying if
!ping <something here> say too many args

earnest phoenix
#

huh

lament meteor
#

dont u have to do .setColor('#hex')?

earnest phoenix
#

for embed colour yeah

#

It works either way doesn't it?

#

also it’s only require not module.require

#

Oh ok.

#

So take off module?

#

yes

#

Error

#

wait nvm

#

gtg

lament meteor
#

try to change let msg = new Discord.RichEmbed to var msg

elder rapids
#

Why would that do anything

#

let and var are same thing

earnest phoenix
#

and const

elder rapids
#

Wrong

earnest phoenix
#

but const you cant change

elder rapids
#

So it's not the same

earnest phoenix
#

still a variable

elder rapids
#

It's a constant

earnest phoenix
#

true

elder rapids
#

Not a variable

uncut slate
#

let and var are not the same thing

elder rapids
#

Boi they do the same job

#

What the hell is the difference

spring ember
#

scopes

#

you should read about it

elder rapids
#

Pls

#

They both act the same to me so nothing different

uncut slate
#

I would have expected better from you, novus

inner jewel
#

var > let

uncut slate
#

let and var are fundamentally different, one is scoped and the other is not

elder rapids
#

I'm not a JS programmer tyvm

#

Don't know what you would expect from me

fluid basin
uncut slate
#

I would expect you to read what I said and drop the ignorance. "They act the same to me, so they are the same!!" is pretty ignorant.

lament meteor
#

iirc let sometimes bug code i dont fully remember the difference with var. but i know they are differnt

earnest phoenix
#

Back.

#

How?

lament meteor
#

google difference between let, var, and const u should find why

earnest phoenix
#

If I change it what will happen to the embed?

#

No I know the difference.

#

I mean the embed.

lament meteor
#

i dont think it will change

#

do u get an error when u run the command?

earnest phoenix
#

If I change our let winner to be var winner , they'll come back as true , because it's not inside of a function, it's not scoped to it, whereas a let variable is. The other thing we need to know about it is that the difference between let and const is that const variables cannot be updated

#

Wait just to double check it should be:

#

So the code should be like this?

#

const Discord = require('discord.js')

#

It has that.

#

What about it?

#

Oh that.

#

I see.

lament meteor
#

why module.require()

earnest phoenix
#

^

#

Deleted.

#

Just saw.

lament meteor
#

and why
if (!args[1])?

earnest phoenix
#

that’s right

#

I was to do that by one you guys.

#

oh [0]

#

Ok changed to [0]

lament meteor
#

but if (!args[0]) means if u dont have args[0] it will not do anything

earnest phoenix
#

Oh so 1?

#

avoid doing that

#

What do I do?

#

if args[0] is a bool

#

it would return false

#

So args 1?

#

you want to do if (args[0] === undefined)

#

or null

#

instad of ! check

#

! check works that same way

#

not really

#

if args[0] is false

#

Ok.

#

get it?

#

if you're trying to check if something exists

lament meteor
#

can u go to my guild for a while Atlas

earnest phoenix
#

use the !== undefined

#

or null

#

if it’s false how could it be undefined then?

#

you dont get it

#

!something = check if false

#

!== undefined/null = check if exists

#

the problem with using the first one is that if the users inputs a false boolean (in this situation)

#

it would return false

lament meteor
#

if args[0] === false it is the same thing as if !args[0]

earnest phoenix
#

yea

#

what were you trying to check, if it was false?

#

or if it exists

#

as in defined

#

Ok I am my phone now,

#

Ok I am my phone now,

#

So it is more buggy.

#

And hard to code.

#

And the internet is worse.

craggy cave
#

anyone know any free NSFW api's?

spring ember
#

Pornhub has one

#

Not that I use it GWqlabsSweats

earnest phoenix
#

Lmao

#

Well my bot still has errors.

#

I’m try to run it now.

#

Doesn’t work but doesn’t show any error.

frail kestrel
#

has errors
doesnt show errors

earnest phoenix
#

So what do I do??

spring ember
#

What is the error

earnest phoenix
#
  1. If you are wanna get a member by tagging them, please use
message.mentions.members.first()

instead of

message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
  1. Also instead of doing something like this
args.join(" ").slice(22);

Use this instead

args.slice(1).join(" ");

That way it slices the first argument, without leaving any empty space.

  1. And if you are kicking or banning a user, you must use
User.kick(Reason) //or 
User.ban(Reason)

instead of

message.guild.member(User).kick(Reason) //or
message.guild.member(User).ban(Reason)
  1. Additionally, if you want to tag someone with the bot and you have the user object you can just send the user object, like this:
Channel.send(`Hello there ${UserObject}`);

instead of using this

Channel.send(`Hello there <@${UserObject.id}>`);
#

JavaScript^

#

Discord.js

umbral pelican
frail kestrel
#

no one is gonna pin it if u tell them to

earnest phoenix
#

Shh

#

I never said that.

inner jewel
#

User.kick

restive silo
#

^

#

User does not have any kick method

#

only GuildMember have these

shrewd marten
#

😠

#

🇫

#

🇫 🇺 🇨 🇰

quiet bobcat
earnest phoenix
#

ok

lament reef
#

how to upload custom/animated emojis discord.js?

grizzled isle
#

message.react(":EMOJI NAME:EMOJI ID");

lament reef
#

how to upload

grizzled isle
#
// Create a new emoji from a url
guild.createEmoji('https://i.imgur.com/w3duR07.png', 'rip')
  .then(emoji => console.log(`Created new emoji with name ${emoji.name}`))
  .catch(console.error);
#

I love the docs

earnest phoenix
#

Can webhooks send custom emotes?

ruby dust
#

what are the common reasons a discord bot returning 403 code?

inner jewel
#

lack of permissions

ruby dust
#

odd...

#

so here's a thing I'm assuming, it's returning 403 because it can't find the message specified? cause that's what's happening

#

I give it a non existant message id intentionally and it should say that it didn't find the message, but instead it prints that error

uncut slate
#

if it can't find the message it'd probably spit out a 404

ruby dust
#

but it's not

uncut slate
#

if you're getting a 403 with getmessage you probably don't have READ_MESSAGE_HISTORY

ruby dust
#

hmm

#

nope, that's not it

#

I gave the bot a limit of looking back up to 500 messages per channel to find that message, may that be the cause?

#

I'm starting to think it's discord's at fault that fucks it up weirdly

uncut slate
#

highly doubt it

ruby dust
#

the other weird thing about it is that it worked fine before with a proper way of failing to find that message, and now without changing anything at all it started this crap instead

#

I haven't touched the code for like 4 days and this started yesterday

#

so no ideas?

desert bough
#

how can i get the number of votes for my bot off the site?

spring ember
#

Use a webhook

#

I will finish the tutorial today

vagrant beacon
#

wheres thay

desert bough
#

i meant like for my bot to use tho in an embed

inner jewel
desert bough
#

wha?

#

oh ok

inner jewel
#

GET /bots/:ID

#

"points" is number of upvotes

desert bough
#

ok

#

wait so how can i use that in JS?

inner jewel
#

use an http request library like snekfetch or something

lament reef
#

how do bots get animated emojis? i tried doing <\:loader:448541225860071444> but it just defaults back to loader

desert bough
#

ok

inner jewel
#

<a:name:id>

lament reef
#

ohh

#

thanks

#

doesn't work @inner jewel

#

😕

vagrant beacon
#

wow

#

u guys created bots

#

cool

frail kestrel
#

is that appropriate for this channel

spring ember
#

Idk probably not

earnest phoenix
restive silo
#

what does client.commands Map store? im sure its not string right? aslong as thats the case, this will always be true

prime cliff
#

@earnest phoenix You have an extra ) on the second line?

#

Oh wait nvm

earnest phoenix
#

is using .json for a small bot good? because I wanna setup server prefixes for my bot (I'm using python)

prime cliff
#

Does || even work like that without an if statement

earnest phoenix
#

I think so

#

hmm I'll check more into that

halcyon abyss
#

Yes it works

earnest phoenix
#

yes you can use statements like that

#

why does it always return true value?? XD

halcyon abyss
#

is cmd a string ?

#

ah no

#

it's a bool

#

arg[0] won't equal cmd

#

then

earnest phoenix
#

its not a bool xD

#

its whatever is stored in those maps

halcyon abyss
#

you use || so isn't it a bool ?

earnest phoenix
#

what 雪音 said

#

|| doesn't mean its a bool

#

e.g. const lorem = null || "hello" lorem will be "hello"

halcyon abyss
#

mb I though doing this would convert the expression to bool

earnest phoenix
#

hmm

#

it will store the first expression that evaluates as true (a non-empty string, a number > 0, a true bool etc.) or the expression of the last result

#

but how should I do it ?

#

do a console.log(cmd) and show us what the map returns

#

I save client.commands as a "enmap"

#

"collections"

#

wtf

#

so just do if (!cmd) // you are trying to reload a non-existing command

topaz fjord
#

^

#

thats how a collection looks like

shy verge
#

is 🅱edis ok as a persistent db

earnest phoenix
#

do you mean redis Thonk

shy verge
#

yes

abstract crystal
earnest phoenix
#

well redis is a key/value database, it can work as a persistent database for some situations with many considerations (like no need of SQL magic, small data storing etc.) with some good configuration and preparation from the beginning but its usually advised against

abstract crystal
#

Quoting: RDB is NOT good if you need to minimize the chance of data loss in case Redis stops working (for example after a power outage).

earnest phoenix
#

my bot keeps crashing

#

but no error

#

well,

#

one error

#

tell us

topaz fjord
#

do you have the <Client>.on("error", error => { ... })

earnest phoenix
#

no

topaz fjord
#

add that

#

then wait for it to come back

earnest phoenix
#

what does it do?

topaz fjord
#

handles that error

earnest phoenix
#

it handles errors

#

so it'd be like

#
console.log(error)
}```
#

?

topaz fjord
#

you didnt close the (

earnest phoenix
#

Oh

#

but If I did

topaz fjord
#

but yes

earnest phoenix
#

and you can skip the { part if you're only going to log it

#

bot.on("error", console.log)

topaz fjord
#

^

earnest phoenix
#

how would I get rid of the error?

topaz fjord
#

well

#

we dont know the error yet

#

so you have to add that and wait

earnest phoenix
#

ye do that and come back

topaz fjord
#

once you get an error send it here and we'll help

earnest phoenix
#

ok

#

thx

#

now we wait

#

again

#

crashed but no error

#

like completely silent, process crashes?

#

Yeah

#

it could be an unhandled promise error being thrown

#

Imma try to restart it

#

is it reproducable?

#

it just randomly crashed

#

crashes*

#

nvm

#

gateway is throwing not authenticated

#

what does that mean?

spring ember
#

you aren't authenticated

earnest phoenix
#

are you trying to do something before bot is ready?

topaz fjord
#

oh

#

Your discord bots connection was reset before it can start

earnest phoenix
#

ready means before ```
bot.on("ready", )

#

right?

topaz fjord
#

no

earnest phoenix
#

oh

#

then when the bot goes online?

#

that's my code

topaz fjord
#

could you do console.log(error.error) in the error event

#

so we can see the stacktrace

earnest phoenix
#

ok

#

I just got that when launching my bot

topaz fjord
#

whats at line 57

spring ember
#

id is undefined

earnest phoenix
#

oh

spring ember
#

umm no

earnest phoenix
#

woops

spring ember
#

the user is undefined

earnest phoenix
#

it was guild not guilds

#

soz

#

when should the error get logged?

#

when I attempt to stop the program to restart it?

spring ember
#

if you don't catch it it needs to be logged

earnest phoenix
#

it doesn't log anything

#

it just crashes

spring ember
#

that isn't good

earnest phoenix
#

no

spring ember
#

it should throw an error at you

#

not crash

earnest phoenix
#

how would I attempt to catch it?

#

if I don't know where its comming from

spring ember
#

promise.catch()?

#

so you should find it

earnest phoenix
#

tho it says v5 is deprecated, have a look over at their api

#
promis.catch(error) => console.logerror)
```?
#

promise*

#

you can always use

#

how would I find this error though?

#
.catch(error) => console.error)```
#

put it on the promise 👀

#

where would I put the catch?

knotty steeple
#

missing a )

earnest phoenix
#

oops

#

setActivity returns a promise, it could be the one that errors

#

you execute it a few seconds after your bot is ready so it'd make sense

#

so how would I get it to wait a few seconds?

#

just catch promise errors in case it throws one

#

when dealing with promises you either have to await for them

#

or catch any potential errors they might throw

#

if you await on a promise the error will be thrown in the stack

#

that?

#

where you do setActivity(...) do it like setActivity(...).catch(console.error)

#

Ok

#

nope, not the setActivity

#

wait

#

Juptain

#

you have modular code

#

yet

#

you're using it in a msg event??

#

hecc?

#

I can see a problem with your code

#

I do too

#

:3

#

I see a worse one

#

oh god

#

bot.on("message", async message =>{

#

that?

#

:3

inner jewel
#

saving data in json

#

and reading for every message

topaz fjord
#

o no

earnest phoenix
#

smh

#

you are doing let seconds = ms(5000) for some reason and that calls upon ms module which converts 5000 ms to 5s (string) then you do setInterval(function() { // set bot activity here }, seconds) which causes the interval to spam as it wants an integer param in ms not a string

#

which causes bot.user.setActivity to spam and not sure how discord.js handles that

inner jewel
#

what the hell node

#

crossed throwing on invalid arguments
check parsing all digits from the string until a non digit is found and using that as an argument

earnest phoenix
#

i hate this error tbh

shy verge
#

@tall condor the option should be under new when you rightclick the folder at the top

waxen spoke
tall condor
#

im not seeing anything related to group package :/

earnest phoenix
#

@earnest phoenix tried re-installing? is disk almost full by any chance?

#

how do I send a message to a specific channel ona server=

#

language?

#

js

#

I have to remove everything and put all that back?

#

@earnest phoenix

blazing stag
#

threading support for nodejs. interesting

earnest phoenix
#

client.channel.get(448559746568421398).send('My Message');

#

this does not work

#

@earnest phoenix just try a npm install and npm upgrade make sure you're up2date and see if you get it again

blazing stag
#

elaborate @earnest phoenix

earnest phoenix
#

?

#

its client.channels

blazing stag
#

ahh wait didnt see your message before that

earnest phoenix
#

not channel

#

@earnest phoenix ok thx

blazing stag
#

@earnest phoenix your id needs to be a string

brisk notch
#

@earnest phoenix it's
bot.guilds.get('guildid').channels.get("channe;id").send('hey')

earnest phoenix
#

bot.channels work too as long sharding isn't being used

#

use a string instead of an integer

#

snowflakes are string

#

as tom said

#

uhm I cant find "send"??

brisk notch
#

?

tall condor
earnest phoenix
#

client.channels.get("448559746568421398").send('My Message')

blazing stag
#

TypeScript is where its at for Javascript

#

haha

knotty steeple
#

ew typescript

blazing stag
#

Why

brisk notch
#

@earnest phoenix it's better to get the guild instead for just getting the channel

blazing stag
#

I like my types

earnest phoenix
#

I prefer ecmascript mmLol

brisk notch
blazing stag
#

same thing

#

its compiled to javascript

#

which is ecmascript

knotty steeple
#

you can also find the name of a channel

earnest phoenix
#

I was just saying that both work @brisk notch

brisk notch
#

mmLol mmk

molten pewter
#

I want to add a deep-fry command to my bot, but I'm not sure how to do so with ImageMagick

earnest phoenix
#

it says It misses permission

molten pewter
#

How would I pull that off?

earnest phoenix
#

nvm

tall condor
#

is anyone available to help me?

brisk notch
#

sure

#

what is it

tall condor
#

does anyone have experience with JDA?

earnest phoenix
#

client.channels.get(${settings.notifyChannel}).send('My Message')

#

whay doesnt this work?

raw sandal
#

@tall condor no but you can join the jda discord for help

earnest phoenix
#

like wtf

#

client.channels.get(settings.notifyChannel).send('My Message')

#

does not work...

raw sandal
#

What are the params for client.channels.get()?

knotty steeple
#

it has to be an id

#

also make it get the guild id

blazing stag
#

What does settings.notifyChannel contain

#

Where does that come from?

#

Also are you reading the discord.js docs

#

?

knotty steeple
#

its a channel i think

blazing stag
#

i figured but i wanted to know its actual value.

#

also client.channel.get returns a Channel

#

there's no send method on Channel

earnest phoenix
#

settings.notifyChannel is athe channel name of a specific channel?

#

so how do I make it send it to a channel ?

#

that i only kno wthe name on?

#

if its the name you have to do find("name", settings.notifyChannel) instead of get

#

get is strictly for collection key and in that case that's the id aka snowflake

#

like this? client.channel.find("name", settings.notifyChannel).send('My Message')

#

yes

#

but channels not channel

#

thx mate :))

blazing stag
#

That works? Because channels is a Collection of Channel

topaz fjord
#

it is on the discord.js docs

blazing stag
#

Doesnt it need to be a TextChannel

earnest phoenix
#

Channel is the base class which is extended by DM/Text channel etc

blazing stag
#

yes

#

i know

#

send isnt on the base class though

earnest phoenix
#

doesn't matter, the retrieved object will be the proper class

topaz fjord
#

Channel is all the channels, whether group, dm, text, etc.

earnest phoenix
#

also if you will be using find with name its better to search by guild first @earnest phoenix

#

otherwise you'll have conflicts

#

snowflakes are unique, names aren't

blazing stag
#

Hmm.

topaz fjord
#

although iirc if u use .find() on the channel it finds the type of channel and returns that

earnest phoenix
#

correct, it will return the object with its proper class based on its type

topaz fjord
#

which is why you can use .send on it

blazing stag
#

cools

#

Ahh yeah i found an instance where i was doing this too.

#

but im in typescript land, so i had to do a cast

#

const channelToMessage: TextChannel = this.channels.get(notifyChannel.id) as TextChannel;

#

In order for this to work

molten pewter
#

How would I do this Python PIL code with ImageMagick?

con = ImageEnhance.Color(img)
img = con.enhance(10)
earnest phoenix
#

EW PYTHON

topaz fjord
#

ew u

blazing stag
#

What's wrong with Python

topaz fjord
#

also python is gud

ruby dust
#

personal oppinions...

topaz fjord
#

well you could say that about every language

blazing stag
#

I want their opinion on python and why they dislike it

#

Or is it just a case of "I don't understand x technology therefore I dislike it" :^)

ruby dust
#

nothing more than just a regular behavior of a person liking their own prefered language, thus "insulting" other languages

earnest phoenix
molten pewter
knotty steeple
#

i prefer javascript

#

but i dont dislike python

blazing stag
#

I don't tend to work with JavaScript directly anymore heh

uncut mirage
#

can you add a masked link (markdown) in an embed field title?

knotty steeple
#

you dont need markdown for title

#

if you mean the thing right on top

abstract mango
#

yeah

#

i think there's a url field for that

knotty steeple
#

if your using d.js you can just do something like

link: "oof"
abstract mango
#

lemme checc my code

knotty steeple
#

or something like that

uncut mirage
#

no the actual field title

#

not title

#

.addField('[link name](url)', 'desc', true)

wanton needle
#

i need help with a customizable prefix for js

#

prefix*

abstract mango
#

oh, field title

knotty steeple
#

make it store a prefix if u use something like !setprefix &

#

then check for the guild prefix in your db

#

if there is nothing use the one in config

#

if yes use prefix in db

wanton needle
#

i want a command like !setprefix ! and it changes the prefix only in that server until they change it again

knotty steeple
#

you need a db

verbal night
#

^

knotty steeple
#

well right now im using json but

verbal night
#

what DB you use doesn't really matter >.>

wanton needle
#

what is that. sorry im not the best at coding

knotty steeple
#

database

verbal night
#

hell i use a .yml file just because i have the code for it >.>

knotty steeple
#

A base of data

#

its in the name

#

¯_(ツ)_/¯

wanton needle
#

i just don't know how to code it

verbal night
#

what language?

knotty steeple
#

ok then use fs and json

wanton needle
#

discord.js

knotty steeple
#

also thats not a language >_>

wanton needle
#

java

abstract mango
#

script.

wanton needle
#

mhm

abstract mango
#

discord.js is not java

#

lol

wanton needle
#

omlllllll

#

you know what i mean tho

verbal night
#

welp i'm useless here >.>

wanton needle
#

oof

knotty steeple
#

@wanton needle if you dont know how to use databases you cant do custom prefixes

verbal night
#

anyways, you'll want some type of database
.json
.yml
.sqlite
Doesn't really matter since you're not storing a large amount of info

wanton needle
#

o well then

knotty steeple
#

sqlite is pretty good tho

#

json can corrupt if too much data is being removed/written

verbal night
#

I've personally just been using yaml since i have the code for it already 🤷 i don't really store enough information to require me to learn sqlite or mysql xD

floral stone
#

should I use pm2 over systemd

#

For autorestarting my bot?

abstract mango
#

i wouldn't think so

#

systemd is pretty easy to use imo

earnest phoenix
#

I use pm2 and I'm happy with it

#

I guess you could call it preference

abstract mango
#

yeah, it's definitely preference

#

i usually don't like big npm packages :p

#

aka: 2 zillion deps

floral stone
#

I'm talking about memory usage over if it's easy

abstract mango
#

ah

#

well i think systemd would do better in that, definitely

#

systemd is written in C, it's the init daemon you know

floral stone
#

I recently upgrade to 16.04 and my process are like 25% more memory usage then 14.04

#

Why is it taking more memory.

earnest phoenix
#

could be a billion reasons

abstract mango
#

on systemd or pm2?

floral stone
#

systemd

abstract mango
#

ic

#

could be a systemd bug but idk

floral stone
#

Half of it is used

#

My memory

#

It just bothers me that it's half

abstract mango
#

ic

floral stone
#

It was like 30% on ubuntu 14.04

abstract mango
#

either it's something w/ your code or systemd

#

or maybe python itself

#

idk

floral stone
#

Not sure what could be causing it.

earnest phoenix
#

32% mem in 2g looks like a lot for a bot to me

floral stone
abstract mango
#

try and find top things that use memory, there's a few modules for that

earnest phoenix
#

don't take my word tho haven't dealt with py before

floral stone
#

@abstract mango like what?

floral stone
#

Was looking for a recommendation before I google. That's why I didn't....

abstract mango
#

ah

#

there's a few builtins as well for it i think

floral stone
#

Profiling an entire application

#

gumpy seems legit

abstract mango
#

built in module :p

floral stone
#
/usr/local/lib/python3.5/dist-packages/discord/activity.py:573: size=472 KiB, count=7548, average=64 B
/usr/local/lib/python3.5/dist-packages/discord/activity.py:137: size=337 KiB, count=1541, average=224 B
/usr/local/lib/python3.5/dist-packages/discord/activity.py:139: size=332 KiB, count=1577, average=215 B
/usr/local/lib/python3.5/dist-packages/discord/activity.py:138: size=245 KiB, count=1122, average=224 B
/usr/local/lib/python3.5/dist-packages/discord/state.py:346: size=150 KiB, count=602, average=256 B
/usr/local/lib/python3.5/dist-packages/discord/activity.py:580: size=146 KiB, count=1099, average=136 B
/usr/local/lib/python3.5/dist-packages/discord/activity.py:367: size=128 KiB, count=587, average=224 B
/usr/local/lib/python3.5/dist-packages/discord/activity.py:572: size=76.9 KiB, count=579, average=136 B
/usr/local/lib/python3.5/dist-packages/discord/activity.py:576: size=41.7 KiB, count=593, average=72 B```
#

Not what I'm looking for

#

let's try gumpy

abstract mango
#

you probably don't have python libraries

#

python3.6?

floral stone
#

yeah

abstract mango
#

if you run python 3.6 package you need to install python3.6-dev

floral stone
#

No, it's 3.5

#

which is installed

#

Guppy is python2

#

i'll try something tommorow, it's late.

earnest phoenix
#

i wanna hide my bot token or a file from github, how do i do that?

#

(bot lib is python)

topaz fjord
#

add a gitignore

earnest phoenix
#

what to do next? xd

#

i can still see it

abstract mango
#

.gitignore needs content in it to hide it

#

basically

#
# gitignore file

# example
secret.json

git will not hide if you've already commited it, you need to git rm --cached secret.json
and then probably should reset your token because it will most likely still show up in git's history

earnest phoenix
#

wait

#

how do i do that command like thing

frail kestrel
#

???

earnest phoenix
#

thegit rm --cached secret.json thing

frail kestrel
#

that’s a command

earnest phoenix
#

idk is it

frail kestrel
#

do you have git installed

#

yes it is

earnest phoenix
#

git bash?

frail kestrel
#

thst works i think

dusty sandal
#

hey. for js how would i do cooldown errors? basically a command has a cooldown and if the command is run before the cooldown ends, the bot sends a message with the time remaining on the cooldown.

shy verge
#

aren't you using akairo

dusty sandal
#

yes

#

@shy verge i am using the akairo

#

sorry for the ping

shy verge
#

akairo has a cooldown param in it's command constructor

dusty sandal
#

example pls?

shy verge
#

in your super function

#

just use cooldown

#

value is counted in milliseconds

dusty sandal
#

i know, but i want to display an error message if the cmd is run before the cooldown ends

shy verge
#

do you have a commandBlocked listener

dusty sandal
#

i think so

#

its in a listeners folder yes

shy verge
#

kk

dusty sandal
#

so what happens here

shy verge
#

k nvm

dusty sandal
#

?

shy verge
#

create a listener for the commandCooldown event

#

it's emitted by commandHandler

dusty sandal
#

thats the event name right?

shy verge
#

yes

dusty sandal
#

so i would do eventName: commandCooldown

shy verge
#

yes

dusty sandal
#

ok thank

earnest phoenix
#

ok im still confused on how to hide files on github, ill provide more information:

lib: python
host: heroku
bot: psychic
question: i wanna hide my bot token, can someone give me an example rather than teaching me

please respond, i know this is annoying but i really need it

#

.gitignore

#

i need a tutorial on that

#

im new to github

#

(locally hosting bot and wanna host it on heroku)

fresh cedar
#

@earnest phoenix there are a lot of tutorials available on YouTube

#

And they also explain how to hide private variables

#

And if heroku doesn't work for you i would also recommend glitch.com

earnest phoenix
#

ok

shy verge
#

heroku is literally the worst god damn thing ever

earnest phoenix
#

sounds good

earnest phoenix
#

uhm lol

#

If I change stuff here it appears in my mod-log on my own server

#

"newsNotify": "true",

#

client.channels.find("name", settings.modLogChannel).send(${key} successfully edited to ${value.join(" ")});

#

"modLogChannel": "mod-log",

#

why does it log stuff happening on this server?

#

how do I make it post on the guilds channel only?

#

Anyone know eris and is willing to help me out?

lament meteor
#

well sure(have u read the docs?)

earnest phoenix
#

Yes.

#

Wow I respond late don't I?

#

@lament meteor

#

Sorry for the tag.

#

But I got to fo this.

#

to*

lament meteor
#

what u need?

earnest phoenix
#

Depends which you wanna help me with?

#

Discord.js bot ain't responding.

#

Or

#

Eris making a new bot {first time using eris and first time using visual studio code and command prompt}

#

Which one you wanna help with?

tardy hatch
#

Hi there

#
@bot.command(pass_context=True)
async def stop():
    await bot.say('Shutting down..')
    await bot.logout()```
#

How to make this command

#

For owner only?

#

And how can i make this command to be used in a server/dm and to response in dm?

slender thistle
#

Use bot.send_message(ctx.message.author, 'Shutting down..') and for owner only, you may use if ctx.message.author.id == 'YourIDHere'.

tardy hatch
#

Thanks

#

#

@slender thistle

#
  File "bot.py", line 17
    if ctx.message.author.id == '254198214415220738'
                                                   ^
SyntaxError: invalid syntax```
earnest phoenix
#

How do a use the bot

#

A have no clue

spring ember
#

Umm? How do you code it?

#

What bot?

earnest phoenix
#

I need some one to set it up

#

Mixer

spring ember
#

Ask their support server

tardy hatch
#

@spring ember

#

U know python?

#

I need a little help

topaz fjord
#

If someone knows python they will help

spring ember
#

Yes

tardy hatch
#

To set owner only

topaz fjord
#

You don't need to ping

spring ember
#

You use commands.ext?

tardy hatch
#

Yep

#

Asyncio

#

U want the full command?

spring ember
#

In the start of the command

tardy hatch
#
@bot.command(pass_context=True)
async def stop(ctx):
    await bot.say('Shutting down..')
    await bot.logout()```
#

Where

spring ember
#

ctx.message

#

Is the message

tardy hatch
#

Is okay to add at start?

spring ember
#

Also you can do a check in d.py

tardy hatch
#

At @bot.command

spring ember
#

By adding the anonataion @bot.check(func)

tardy hatch
#

@bot.command(pass_context=True, if ctx.message.author.id!=MyId)

#

Ffs

#

Wait

#

I ll add check

#

bot.check_if owner

#

Or idk

#

And

#

Where i need to add author id