#development

1 messages ยท Page 386 of 1

idle grail
earnest phoenix
#

๐Ÿคฆ

idle grail
#

How to refer to a package

tepid laurel
#

How do you except to a file fully being logged by requiring it

earnest phoenix
#

not that

#

i mean

idle grail
#

lol

tepid laurel
#

Thats what you are doig

earnest phoenix
#

7

tepid laurel
#

Requiring a file and logging it

earnest phoenix
tepid laurel
#

No shit its undefined

idle grail
#

...

earnest phoenix
#

everything is fine

#

package is connected

#

but in package code there is something wrong

#

and i want to fix it

#

is it that fucking hard

tepid laurel
#

Is the file a function?

earnest phoenix
#
module.exports = function () {
    request("https://bts.net.pl/random_image/api", function(err, link) {
                return link.body;
            });
    }   ```
tepid laurel
#

You realize

#

That if you export it of a file

#

<somefile>.somefunc()

#

Is what you want

earnest phoenix
#

this is the url i fetch images url from

tepid laurel
#

Mate

#

Mate

earnest phoenix
#

?

tepid laurel
#

Change module.exports = function()

#

To

#

exports.<somenameforthefunction> = function()

#

Give it a name, and then

#

Wherever you are requiring it

#

<somefile>.thatFunctionofYours()

earnest phoenix
#

ok

tepid laurel
#

You at least got it t work ๐Ÿคท๐Ÿผโ€โ™‚๏ธ

#

And looking at what you do with the request

#

You do not know at all what you are doing, do you?

earnest phoenix
#

i do know

tepid laurel
#

Then why use brackets on request

earnest phoenix
#

i dont know if i should choose snekfetch or request

tepid laurel
#

Either way youre still doing it wrong

earnest phoenix
#

i could use snekfetch

tepid laurel
#

request() is a function that returns the url fetched

#

Not sure if its a promise

#

I do know request-promise will return it promise based

earnest phoenix
tepid laurel
#

And you could act on that ๐Ÿคท๐Ÿผโ€โ™‚๏ธ

steep bane
#

how To get the bot online on koltin?

idle grail
#

[emojis]

steep bane
#

[no u]

ruby dust
#
Traceback (most recent call last):
  File "/root/discord.py-rewrite/discord/client.py", line 223, in _run_event
    yield from coro(*args, **kwargs)
  File "/root/discord.py-rewrite/modules/Events.py", line 39, in on_command
    print('\nCommand Executed\n    Command: ' + str(ctx.message.content) + '\n    Server: ' + str(ctx.guild.name) + ' [' + str(ctx.guild.id) + ']\n    User: ' + str(ctx.author.name) + ' [' + str(ctx.author.id) + ']')
AttributeError: 'NoneType' object has no attribute 'name'```
#

what could be causing this?

#

oh, could the reason be because a command was ran in a DM?

low rivet
#

ywah maybe

ruby dust
#

hmm, that's the only thing I can think of

#

maybe that's it

nimble merlin
#

I need a very thorough and informative tutorial on how to use dataset..specifically in discord.py async.....I looked on YT but I couldn't find anything....

low rivet
#

do you know python?

nimble merlin
#

ish...

#

It's my only programming language

low rivet
#

have u done any projects before?

nimble merlin
#

yes, I had on old bot a while back...but since I created a new bot....it is much more advanced than before...

#

but not with dataset...

#

brb

low rivet
#

what dataset

nimble merlin
#

you know...dataset....the database "language" (I guess you could call it?)

low rivet
#

owo theres actually a lib called dataset

nimble merlin
#

yes

low rivet
nimble merlin
#

I have literally no-clue how to set it up or how to integrate it into my commands

#

oh ok....thanks...I guess ๐Ÿ˜ƒ

low rivet
#

well i use mongo (yaml and json if that counts)

nimble merlin
#

lol....I was advised not to use JSON by another certified dev sooooo lol ๐Ÿ˜„

#

My goal with dataset is to get typical "economy commands" and a customizable prefix

low rivet
#

JSON isnt good for databases, but its ok for config. im moving over to yaml for config now though cos it looks better

solemn obsidian
#

using nosql database and storing json in files are a different thing

nimble merlin
#

ok

#

For anyone that has made them before, are database commands like "economy" (based) commands and customizable prefix's easy???

low rivet
#

yes if u know how to work with databases and all

nimble merlin
#

obviously I don't lol ๐Ÿ˜„ but that's a bit more encouraging thanks anyway lol ๐Ÿ˜„

#
db = dataset.connect('sqlite:///mydatabase.db')

# connecting to a MySQL database with user and password
db = dataset.connect('mysql://user:password@localhost/mydatabase')

# connecting to a PostgreSQL database
db = dataset.connect('postgresql://scott:tiger@localhost:5432/mydatabase')``` Do I need to use this at all???
low rivet
#

that isnt a hard goal though, once you manage it youll understand basic insert and getting data

nimble merlin
#

ok

low rivet
#

i think thats just examples of different uris

#

depends on your uri

nimble merlin
#

oh ok lol

#

I don't have a database yet...do I need one or can I just do that inside of the code???

low rivet
#

you need one

nimble merlin
#

ok...

nimble merlin
#
             aliases=['Account', 'ACCOUNT'])
async def account(ctx):
    table.insert(dict(name=ctx.message.author, balance='100'))``` OK...I *think* that I have come to grips with it....is this the sort of thing that would be used to add a record on the database???
ruby dust
#

why do I always see you asking a question with at least 3 question marks at the end...?

nimble merlin
#

idk....

#

anyway, what is missing before table.insert as it's giving me an error

#

if you know obviosuly...

ruby dust
#

I only know SQLite3

nimble merlin
#

oh....i'm using dataset

nimble merlin
#

Does anyone else know what should be placed infront of table.insert?

earnest phoenix
#

m?invert @ruby dust

quiet bobcat
earnest phoenix
#

Ah sorry

quiet bobcat
earnest phoenix
#

I have not seen the channel sorry

nimble merlin
#

hellllloooooo???????? What do I need to place infront of table.insert to make it function in a command?

abstract crystal
#

infront nothing

#

in () a lot

nimble merlin
#
             aliases=['Account', 'ACCOUNT'])
async def account(self, ctx):
    table.insert(dict(name=ctx.message.author, balance='100'))``` I tried using this but it gave a syntax error stating that `table.insert` was not defined...
topaz fjord
#

Then it's not defined

#

Don't know how clear it can be...

abstract crystal
#

have you defined table var?

nimble merlin
#

no

abstract crystal
#

well there you go

nimble merlin
#

how do I do that?

#

lol ๐Ÿ˜‚

elder rapids
#

table.insert => This isn't Lua

abstract crystal
#

table = something_here

nimble merlin
#

no, it's dataset

ruby dust
#

it would've been a lot easier if you would just go with SQLite3

nimble merlin
#

ok

abstract crystal
#

it's already on sqlite3

nimble merlin
#

wait, SQLite3 is a language???

elder rapids
#

dataset Thonk

#

oh lord

nimble merlin
#

yea

#

lol

elder rapids
#

You didn't know SQL is a language

nimble merlin
#

...

#

don't ask

elder rapids
#

SQL => Structured Query Language

ruby dust
#

you start with import sqlite3, make any sense?

nimble merlin
#

I start with import dataset but yea...it makes sense

ruby dust
#

haha

#

ok

nimble merlin
#

lol ๐Ÿ˜„

abstract crystal
#

then you continue with _DB = dataset.connect('sqlite:///./database.db')

nimble merlin
#

I'm using dataset for the last time...

ruby dust
#

oh lord, dataset is so difficult compared with sqlite3

nimble merlin
#

OK fine....i'll migrate to that since I have done nothing so far

#

I'll only migrate if this command fails though

#
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InterfaceError: (sqlite3.InterfaceError) Error binding parameter 0 - probably unsupported type. [SQL: 'INSERT INTO balances (name, balance) VALUES (?, ?)'] [parameters: (<discord.member.Member object at 0x077363D8>, '100')] (Background on this error at: http://sqlalche.me/e/rvf5)``` This is the error message ๐Ÿ˜ฉ
abstract crystal
#

inserting discord.Member class is not a good idea

#

ID is a better option since is unique

nimble merlin
#
             aliases=['Account', 'ACCOUNT'])
async def account(ctx):
    table.insert(dict(name=ctx.message.author, balance='100'))
    await bot.say('I have created you an account and add $100 to it, happy spending!')``` I can't exactly see a discord.Member class in there...
abstract crystal
#

or snowflake as is called these days

nimble merlin
#

ohhhh

#

ok...so I change that to ctx.message.author.id

#

oh lol

#

I just spotted a typo as well lol ๐Ÿ˜„

nimble merlin
#

table.update(dict(name=ctx.message.author.id, balance=balance + 500)) will that work...I made it up off the top of my head so idk..

abstract crystal
#

not rly

nimble merlin
#

hmmmm

#

how could I add more to the balance variable then?

#

or should 500 be a string???

abstract crystal
#

No

#

That part is ok

#

You need to specify which column should update function search for the id

nimble merlin
#

ok

abstract crystal
#

Aka. Look at the docs

nimble merlin
#

ok

#

table.update(dict(name=ctx.message.author.id, balance=table + '500')) I did that off the top of my head and all but it most likely doesn't work lol

abstract crystal
elfin ledge
#

hello

#

different id ???

#

and it worked

abstract crystal
#

there you go

elfin ledge
#

my question why ids different

abstract crystal
#

maybe you were copying wrong id

elfin ledge
#

175589848982355978

#

is that ur id

abstract crystal
#

yes

elfin ledge
#

thats how i was opying it

#

copying

abstract crystal
#

then you were copying it from another bot/user

elfin ledge
#

100%

#

i was not

#

208645298308775936

#

208635581654106113

abstract crystal
#

it's impossible sorry

elfin ledge
#

top id is if i copy bot user

abstract crystal
#

Too short

#

lul

elfin ledge
#

and second is from app

#

the second id worked

#

m8

abstract crystal
#

or you have created that app very early

elfin ledge
#

i did

#

one of the first

#

about 2 year ago

abstract crystal
#

there you go

elfin ledge
#

but would i have to id's

#

for the same bot

abstract crystal
#

lemme just calculate sth

#

first ID: '2016-07-29 18:01:55.559000'
second ID: '2016-07-29 17:23:18.928000'

#

creation dates

elfin ledge
#

o

#

how do i get a an api key for

#

discordbots

#

as my bot aint showing up

abstract crystal
#

when the bot gets approved then you can have it

elfin ledge
#

ah

#

how do i get approved

abstract crystal
#

you wait

elfin ledge
#

so i don't need to do any thing

trim plinth
#

no

abstract crystal
#

for now

elfin ledge
#

just wondering

#

my bots starting to get to a certain size which requires shards where would the best place to learn about that be?

abstract crystal
#

which language?

elfin ledge
#

discord.js

abstract crystal
#

probbs the library docs

trim plinth
abstract crystal
#

or that ^

elfin ledge
#

o wow

#

thx

nimble merlin
#

My bots code is 925 lines long....I should probably learn how to shard it....any hints for tutorials for d.py async???

abstract crystal
#

no

#

it's not the lines it's the servers that you shard

nimble merlin
#

ohhhh

#

ok...my bot is only in 11 servers so...I could forget about it...but if it's easy then I might as well do it....is it relatively easy??

abstract crystal
#

also what are you doing on async lul

nimble merlin
#

lol

abstract crystal
#

use rewrite, async is feature locked

nimble merlin
#

can't be assed to migrate ๐Ÿ˜‚

#

it's sooo....what's the word....gritty I guess

topaz fjord
#

You should probs use a CMD handler

nimble merlin
#

like?

topaz fjord
#

Idk google

abstract crystal
topaz fjord
#

Idk python

abstract crystal
#

lul

nimble merlin
#

oh...ok fair enough

#

also, how do I shard my bot?

abstract crystal
#

and you dont use sharding until you get to at least 2500 servers

nimble merlin
#

oh....fair enough

topaz fjord
#

@abstract crystal u sharder at 1k

abstract crystal
#

shhh

nimble merlin
#

lol

topaz fjord
#

*I sharded

abstract crystal
#

i have work intensive commands, that has nothing to do with sharding

nimble merlin
#

lol

trim plinth
#

@abstract crystal Your bot will be broke by the time you reach 2500 servers because you didn't shard in time

abstract crystal
#

damn then it already broke

nimble merlin
#

lol ๐Ÿ˜‚

topaz fjord
#

Just make sure db allows lots of connections lol

abstract crystal
#

from discord.ext.commands import AutoShardedBot

#

Oh i've fixed my bot

#

lul

topaz fjord
#

Adding 1 a doesn't change shit from hsving 0

#

It'll all crash when I reach 2 shards

#

Soon โ„ข 750 guilds needed

abstract crystal
#

lul dont mind me client = AutoShardedBot(command_prefix=get_prefix, shard_count=3)

nimble merlin
#

python -m async2rewrite ollie.py so I did this...but nothing happened

elfin ledge
#

when a bot is sharded

#

does it split the server equally

#

or

#

does it do like 2500 one shards 100 servers another

topaz fjord
#

No

#

It doesn't split equally

elfin ledge
#

how does it split

topaz fjord
#

It can be a random amount on each

elfin ledge
#

does it balance the servers tho

abstract crystal
#

it isn't random

#

i think

topaz fjord
#

For d.js it is

#

Doesn't split Evenly

abstract crystal
#

it's not up to the lib

#

gateway splits servers

nimble merlin
#

so @abstract crystal how do I use async2rewrite???

abstract crystal
#

(guild_id >> 22) % num_shards == shard_id

topaz fjord
#

I've seen a bot have 3k servers with 1.3k on one and 1.7k on another

abstract crystal
nimble merlin
#

ohhhhh Ik now...thanks ๐Ÿ˜ƒ

topaz fjord
#

Discord why u not make docs for mobile

abstract crystal
#

Official fix: use a desktop

nimble merlin
#

huh, what da ya know...async2rewrite works...brilliant

elfin ledge
#

why would u use docs on mobile

nimble merlin
#

it missed a few things tho...I see that it does that normally

abstract crystal
#

rewrite is evolving

#

so yea

nimble merlin
#

k

topaz fjord
#

Cus im not at my computer

abstract crystal
#

โœ… Request desktop site

nimble merlin
#

what does @dusk verge.command change to in rewrite???

#

lol...theres actually a bot called bot lol

abstract crystal
#

look. at. the. docs.

nimble merlin
#

o. k

nimble merlin
#

is it dangerous to shard your bot too early??

abstract crystal
#

no, but it's useless

nimble merlin
#

oh ok...I was just going to do it just to save me the effort of doing it if my bot ever gets more than 2500 guilds lol ๐Ÿ˜„

#

from discord.ext.commands import AutoShardedBot why am I unable to do this?

abstract crystal
#

wdym

nimble merlin
#

when I try to run my bot, it gives this error message: from discord.ext.commands import AutoShardedBot ImportError: cannot import name 'AutoShardedBot'

abstract crystal
#

yea exacly

nimble merlin
#

ish...

#

I'm not using that file yet

#

soo???

abstract crystal
#

let me reiterate myself: did you update discord.py to rewrite?

nimble merlin
#

I have...into a different file, however, I am not yet going to use that file

abstract crystal
#

wdym into a different file

#

did you do pip install -U ......

nimble merlin
#

When I did python -m async2rewrite ollie.py it created a new file that was updated to rewrite, however, I have decided to not yet run that file

abstract crystal
#

ok

nimble merlin
#

I did pip install discord.py[rewrite] if that's what you mean?? lol ๐Ÿ˜„

#

ok ๐Ÿ˜ƒ

abstract crystal
#

well that doesn't work

#

but sure

nimble merlin
#

in rewrite?

abstract crystal
#

in python

nimble merlin
#

oh....

#

ok...fair enough

abstract crystal
#

pip install -U git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py

nimble merlin
#

ohhh, yea, when I did that...it installed all that I needed BTW

abstract crystal
#

it installed async

nimble merlin
#

what, when i did pip install discord.py[rewrite]...the rewrite bit is there for a reason

abstract crystal
#

yes, but it does not serve any purpose since is not defined in setup.py in extras:

nimble merlin
#

oh

abstract crystal
nimble merlin
#

ok...fair enough...you win lol ๐Ÿ˜„

#

yea, ok

abstract crystal
#

do your research first

nimble merlin
#

๐Ÿ˜ณ

#

from discord.ext.commands import AutoShardedBot anyway, why doesn't this work???

#

or do you not know?

abstract crystal
#

Because you don't have rewrite installed

nimble merlin
#

oh ok...would it work on async code but with rewrite installed???

abstract crystal
#

no

nimble merlin
#

oh...fair enough

hushed oyster
#

you could do manual sharding

#

but I can't help you with that

nimble merlin
#

oh...ok...

abstract crystal
#

on dbl?

#

css

nimble merlin
#

oh....hmmmm....what would I put into the detailed description to edit that though???

#

i'll have a look at the docs...then ispect element if all else fails

#

I have no idea.... ๐Ÿ˜‘

abstract crystal
#

css my friend, css

trim plinth
#

you use html style tags and css

#

@nimble merlin

ruby dust
#

yeah btw, where do people do that css edit in their dbl page?

abstract crystal
#

long desc

trim plinth
#

@ruby dust long description

nimble merlin
#

to make it look better

ruby dust
#

hmm

nimble merlin
#

oops..I read that wrong lol

elfin ledge
#

just wondering what sort of time scale for bot approval and is there a notification or do i need to keep an eye?

nimble merlin
#

soo, how do I actually edit the info provided?

#

@elfin ledge they generally start approving soon

ruby dust
#

@elfin ledge you get notified by bot

trim plinth
#

@elfin ledge luca will message you if it gets denied or accepted

elfin ledge
#

thx

ruby dust
#

lol 3 mentions

nimble merlin
#

yep

#

lol

edgy vale
#

Huh my bot's muted

#

Didnt even notice

nimble merlin
#

lol

edgy vale
#

Weird

nimble merlin
#

OK...so...what CSS code do I need to use to edit the details of my bots page...or is there a dedicated tutorial somewhere for specifically dbl???

trim plinth
#
  1. no tutorial
nimble merlin
#

aww

#

lol

abstract crystal
trim plinth
#
  1. messa around with inspect for a while and you'll find it
nimble merlin
#

ok

trim plinth
#

try right-clicking on the library name and clicking inspect and hope you find the selector in the css

#

thats how I did it

#

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

edgy vale
#

does somebody have a say command they could quickly test my bot with?

#

want to see if it still responds to other bots

nimble merlin
#

oh..it's actually pretty easy TBH...thanks! Great help ๐Ÿ˜ƒ

trim plinth
#

@edgy vale I can use my eval to check. Just need your bots name and help command

edgy vale
#

wait nvm that doesnt work if its muted haha

trim plinth
#

o lol

edgy vale
#

should i ping the mod that muted my bot if i fixed it?

trim plinth
#

yes

#

but you want to make sure its fixed

edgy vale
#

i checked with my other bot

trim plinth
#

mk then go ahead

edgy vale
#

@uncut slate hey i fixed my bot (@earnest phoenix) responding to other bots

nimble merlin
trim plinth
nimble merlin
#
<head>
<div class="column is-10-mobile is-two-thirds-tablet is-4-desktop is-offset-2-tablet is-offset-1-mobile is-offset-1-desktop" id="bot-info"><span class="status purple">ONLINE</span>
<span class="lib"><a id="libclick" href="/search?q=library:%20discord.py">Ollie.py</a></span>

</div>
</head>
</html>
<style>``` What's wrong with it???
trim plinth
#

wheres the second style tag

#

oh wait nvm

nimble merlin
#

yea, but what stops it from replacing it on the bots actual page instead of the description

abstract crystal
#

why do you want to rename the lib you are using. You haven't even modified it, are you trying to dishonor the author?

nimble merlin
#

oh, so should I change %20discord.py... with something else?

abstract crystal
#

no you leave it as it is

nimble merlin
#

soooo

abstract crystal
#

discord.py

nimble merlin
abstract crystal
#

whatever

nimble merlin
#

...

nimble merlin
#

OML......this is difficult...there must be another way that doesn't use inspect cos copying that and hoping doesn't work

pulsar cairn
#

how do i dm someone with jda

nimble merlin
#

OK....so...i'm trying to edit the color of the text displayed at the top of my bots page, however, any attempt that I make either, doesn't work, is classed as "malicious" or adds it to the detailed description.....IF anyone has done this on their page and is willing to help, please, either dm me or mention me.

elfin ledge
#

My bot was declined if i fixed the issue can it get reavaluated

trim plinth
#

yes

elfin ledge
#

how do i resubmit

trim plinth
#

you just add the bot like normal

nimble merlin
#

does anyone know the resolution to my issue???

earnest phoenix
#

What's wrong with this 'purge10': (msg) => { if (msg.guild.member(msg.author).hasPermission('MANAGE_MESSAGES')) msg.channel.fetchMessages(10).then(msgs => msgs.delete()) },

tepid laurel
#

fetchMessages returns a collection

#

You cant call delete like that on a full collection

#

bulkDelete is what deletes a certain amount of messages at once

earnest phoenix
#

!say Hi

#

Why isnโ€™t it working

#

Cause you cant use bots in here

#

Oh

#

how do i use bulkDelete? @tepid laurel

#

Oops

tepid laurel
#

Call it on a channel and pass either an amount to delete, a collection etc

earnest phoenix
#

im gonna guess this msg.channel.bulkDelete() ?

tepid laurel
earnest phoenix
#

Thanks @tepid laurel

#

works :D

tepid laurel
#

Np

earnest phoenix
#

if (msg.guild.member(msg.author).hasPermission('MANAGE_MESSAGES')) return; else msg.channel.send(`Sorry! You require the permission MANAGE MESSAGES to use this command!`) why does the code still execute under it?

gilded blaze
#

I would just do if it isnโ€™t then return the message

#

And hasPermission is deprecated

tepid laurel
#

Its not on a member itself I thought

#

Some strange thing

earnest phoenix
#

@trim plinth How do I get uptime in hours minutes and seconds

trim plinth
#

you have to do that yourself

earnest phoenix
#

ffs

inner jewel
#
  1. basic math
  2. there are probably 30000 npm modules that do that
earnest phoenix
#

sff

trim plinth
#

not very quick maths

gilded blaze
#

How would I tell between a kick and a member leaving normally? Right now I use audit log, but if the person joins and leaves again it logs.

gilded thunder
#

@nimble merlin ```html
<style>
p {
color: #FFFFFF;
}
</style>

#

Pretty sure that's how.

nimble merlin
#

ok

gilded thunder
#

And for any other text fields, just change p with the tag.

nimble merlin
#

ok ๐Ÿ˜ƒ

gilded thunder
tepid laurel
#

@gilded blaze discord.js?

sharp stump
#

@gilded blaze you'd need to check the audit log and see if there is a kick event for that member recently (within the last second)

tepid laurel
#

And that

#

Myself I was wondering if someone could look at this and see if Im going the wrong direction

#
const User = require('discord.js').User

class socialUser extends User {
    constructor(user) {
        super();
        
        this.test = 'ok';
        
        }
    }
}

module.exports = socialUser;
sharp stump
#

what's that class for?

tepid laurel
#

Well gonna extend the regular user class

#

To add new props and functions

#

On the class itself

#

Just the super part

#

Didnt do that before yet

#

Made my own classes yes, but extending no

sharp stump
#

that's pretty difficult because discord.js creates regular users

#

you'd probably be better off creating a stand alone class with a user property like member

gilded thunder
#

How can I add a ping time to ```python

ping command

@bot.command(pass_context=True)
async def ping(ctx):
"""Ping the bot."""
embed = discord.Embed(title="Pong! :ping_pong:", color=0x8080ff)
await bot.say(embed=embed)

tepid laurel
#

@sharp stump that requires more cache tho

#

I mean I guess its a way

cold harness
#

if anyone is having problems downloading files from attachments and stuff on d.py,async def download_file(url, file_name, file_type): if file_type == 'exe' or file_name == 'js': return headers = { 'User-agent': 'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0' } r = requests.get(url, headers=headers, stream=True) with open(str(file_name)+'.'+str(file_type), 'wb') as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk)

tawny lava
#

@tepid laurel d.js v12 has a structures class which allows you to extend classes already made

tepid laurel
#

Lmao thats a nice one they did

abstract crystal
#

@cold harness use aiohttp lib for accesing the web

#

In the docs you can find an example

muted oxide
#

I am trying to actually upgrade my eval, but this happens.

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_hackrun/iiec_hackrun.py", line 29, in <module>                start(fakepyfile,mainpyfile)                              File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_hackrun/iiec_hackrun.py", line 28, in start                   exec(open(mainpyfile).read(),  __main__.__dict__)         File "<string>", line 36                                  SyntaxError: f-string: mismatched '(', '{', or '['          
[Program finished]

This : to_compile = f"async def func():\n{textwrap.indent(body, " ")}"

earnest phoenix
#

I'm having an issue with my Discord Bot.

Every so often my bot goes offline and does not respond to commands. It does not leave an error which confuses me.

I've tried this with just node ., nodemon and PM2 I primarily use PM2.

When using PM2. It continues to say it's online (while offline in Discord), it leaves no logs or errors.

I'm highly confused why it goes offline and it's hosted on AWS.

shrewd silo
#

is there any way to tell if a channel is nsfw in discord.py without rewrite

low rivet
#

no

#

why arent u upgrading?

shrewd silo
#

i am considering it

earnest phoenix
#

does anyone know if asyncios subprocess functions have a universal_newlines argument?

#

actually fuck

#

nvm

nimble merlin
#
             aliases=['About', 'ABOUT'])
async def about(ctx):``` Quick question (possibly a dumb one too) am I able to use this type of code as a command in rewrite...I want to know before I  migrate just incase...
ruby dust
#

yes, but the only difference is that you don't have to pass_context anymore since it defaults to true

nimble merlin
#

oh ok...that's brilliant...thanks! ๐Ÿ˜ƒ

#

I just wanted to check cos i'd rather not have to check & change 920 lines of code

#

Hmmmm.....what is the terminal command to install rewrite again....I cannot find it on the internet for some bizarre reason

ruby dust
#

I just typed pip install discord and got what I needed... I think, at least

nimble merlin
#

lol ๐Ÿ˜‚

#

I see no reason why that wouldn't work....but idk.....lol

ruby dust
#

I guess that just installs both rewrite and async, but idk

nimble merlin
#

I would guess that it does...all I did when installing async was pip install discord.py sooooo

#
        game=discord.Game(type=1
            name='{} Servers! | Upvote me on discordbots.org'.format(len(bot.servers)),
            url='https://twitch.tv/jacktek05'))``` Why does this, output with this: ``` File "ollie.py.a2r.py", line 53
    name='{} Servers! | Upvote me on discordbots.org'.format(len(bot.servers)),
       ^
SyntaxError: invalid syntax```
inner jewel
#

missing comma

nimble merlin
#

yea....I noticed that a few moments ago...thanks anyway ๐Ÿ˜ƒ

#

await discord.send_message(id=423890604645285888, embed=embed) OK....what do I need to replace "send_message" with to make the bot send it to a specific channel id??? Is it discord.Object.utils?

ruby dust
#
channel = bot.get_channel(channel_id)
await channel.send(content)
nimble merlin
#

ok...thank you

ruby dust
#

please read the rewrite docs

#

it will be better for everyone rather than asking here constantly

nimble merlin
#

good point....I probably should...

ruby dust
#

it's not that different from async, but it has some changes in the code

nimble merlin
#

ik....lol

nimble merlin
#

I would assume that a command using @bot.command would not output with this: File "ollie.py.a2r.py", line 105, in <module> @bot.command() File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 296, in __getattr__ raise AttributeError(msg.format(self.__class__, name)) AttributeError: '<class 'discord.client.Client'>' object has no attribute 'command' ERROR:asyncio:Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x06A87950> ERROR:asyncio:Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x06AB43F0> but it does.....YES I HAVE CHECHKED THE DOCS FOR OVER 5 MINUTES!!!!

#

anyway....moving along....what have I done wrong?

upper tundra
topaz fjord
#

User doesn't exist

nimble merlin
#

OK...so, weirdly enough, ctx.message.user.name doesn't work...the code is await bot.send_message(ctx.message.user.name, 'You have been given a warning in {}'.format(ctx.message.server.name) + '\nReason: {}'.join(args))

P.S: I have checked the docs for async and couldn't find what I was looking for

ruby dust
#

if you are using rewrite, why are you looking up the async docs?

nimble merlin
#

i'm not...i'm not switching for a few more days

ruby dust
#

well async is pretty outdated and will probably never receive any updates, so you have your chance to switch libs while you still can

nimble merlin
#

ik...like I said i'm switching in a few days....do you know the answer to the question?

ruby dust
#

if I'm gonna look for an answer then I will find it in async docs, which you failed anyway

#

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

nimble merlin
#

You know what never mind

slim heart
#

```IF EXISTS (SELECT * FROM censorbot WHERE serverid = + message.guild.id +)
INSERT INTO censorbot SET ?

what's wrong with this...
nimble merlin
topaz fjord
#

Quick question

nimble merlin
#

go on?

topaz fjord
#

Are you sure you know python

nimble merlin
#

no....it's just a hobbie...the only decent way to learn it is to do it

#

that's my opinion anyway

topaz fjord
#

You should probs take some courses online

#

To learn the language fully

nimble merlin
#

I probably should...

#

anyway...are you able to answer my question or not?

topaz fjord
#

No

#

Idk python

nimble merlin
#

oh ok...

ruby dust
#

UnicodeEncodeError: 'ascii' codec can't encode characters in position 96-103: ordinal not in range(128)
UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 37: ordinal not in range(128)
I know what that means, but is there a way to prevent that from flooding my console with that crap?

topaz fjord
#

Don't encode unicode

ruby dust
#

yeah, like I'm doing that intentionally..

topaz fjord
#

What are you trying to do

ruby dust
#

you know, users being users, sometimes the console prints a normal command execution and sometimes this error, and since I can't see what the users do I don't know the cause of it

topaz fjord
#

So

#

Do you use pm2

#

Yes or no

ruby dust
#

I don't know what that means, but I'm using d.py btw

topaz fjord
#

Ok

#

So what you should do

#

Is when you console.log errors

#

Set the timestamp it console.logged

#

And also create a log file that logs what command was used at what timr

#

Time

#

Then wait for it to appear again

#

Then you'll know the cause

ruby dust
#

hmm, but the problem is that I can't see what the command was used or the other type of issue because of that error appearing instead...

topaz fjord
#

Why not log the command in your message event

ruby dust
#

huh

#

never thought of that

topaz fjord
#

Lmao

nimble merlin
#
             aliases=['BotInfo', 'BOTINFO', 'Botinfo'])
async def botinfo(ctx, user: discord.Member):
   embed = discord.Embed(description="{}'s info".format(bot.user.name), color=0x6e7be1)
   embed.add_field(name='Name:', value='{}'.format(bot.user.name))
   embed.add_field(name='ID:', value='{}'.format(bot.user.id))
   embed.add_field(name='Prefix:', value='{}'.format(bot.prefix))
   embed.add_field(name='Certified:', value='{}'.format(bot.certifiedBot))
   embed.add_field(name='Discriminator:', value='{}'.format(bot.discriminator))
   embed.add_field(name='Library:', value='{}'.format(bot.library))
   embed.add_field(name='Tags:', value='{}'.format(bot.tags))
   embed.add_field(name='Description:', value='{}'.format(bot.shortdesc))
   embed.add_field(name='Owner(s):', value='{}'.format(bot.owners))
   embed.add_field(name='Invite:', value='{}'.format(bot.invite))
   embed.add_field(name='GitHub', value='{}'.format(bot.github))
   embed.add_field(name='Support:', value='{}'.format(bot.support))
   embed.add_field(name='Website:', value='{}'.format(bot.website))
   embed.set_thumbnail(url=bot.user.avatar_url)
   await bot.say(embed=embed)``` I am absolutely mind boggled...i've tried the API, i've tried the docs but I just cannot find why this isn't working...does anyone know why this isn't working because, to me, it should work
steel tinsel
#

has anyone had any issue with my bot?

earnest phoenix
#

?

nimble merlin
#

embed.add_field(name='Prefix:', value='{}'.format(bot.prefix)) So, the API says that a bots prefix can be found using prefix however when I place this after .format(bot... the error message is: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: '<class 'discord.ext.commands.bot.Bot'>' object has no attribute 'prefix' Which is starting to confuse me....

earnest phoenix
#

object has no attribute 'prefix'

#

did you check to see if a prefix actually exists

#

Log the object that the prefix is supposed to be a part of

nimble merlin
#

OK....so I thought that the field simply needs to be placed infront of .format(bot. have I been confused with what this documentation is saying?

inner jewel
#

the d.py bot object isn't a dbl bot object

nimble merlin
#

ok...so how do I use the dbl bot object?

ruby dust
#

o.0

nimble merlin
#

yea...we both know that I am completely new and an absolute noob

#

you don't have to rub it in a bit.... ๐Ÿ˜ƒ

ruby dust
#

prefix is a part of your bot, nothing to do with dbl

inner jewel
#

that screenshot is from the dbl docs

nimble merlin
#

ik

bitter sundial
#

are you listing your own prefix?

nimble merlin
#

yes!

#

no!

#

my bad

bitter sundial
#

just load it from your config

#

oh

nimble merlin
#

it's a general botinfo command

#

it would be easy otherwise

bitter sundial
#

then you need to fetch the bot object

inner jewel
#

GET /api/bots/:id

nimble merlin
#

OK

nimble merlin
#
             aliases=['BotInfo', 'BOTINFO', 'Botinfo'])
async def botinfo(ctx, user: discord.Member):
    GET /api/bots/:id``` it's probably wrong....
#

oh wait ik

ruby dust
#

oh dear...

nimble merlin
#

I need to define it right?

ruby dust
#

should I just give him a tutorial courses for api or can we just forget this ever happened?

nimble merlin
#

You choose

ruby dust
#

seriously... you aren't going to get anywhere, go learn python and API

nimble merlin
#

ouch.....

ruby dust
#

you'll get more knowledge from there than here

inner jewel
bitter sundial
#

or

gusty topaz
#

lmgtfy is an annoying piece of shit

bitter sundial
#

the python library

nimble merlin
#

lol

gusty topaz
bitter sundial
#

idk if it has implemented getting

inner jewel
nimble merlin
#

k

bitter sundial
abstract crystal
#

Steps to get bot info in python:

  1. Pleaseeee useee async (aiohttp) but if you insist fine use requests, just remember that they are not asynchronous
  2. Make a request to GET BOT api endpoint (/api/bots/insert_bot_id_here)
  3. Parse JSON request to a dict object with data = your_request_var.json()
  4. Read data from the dict: short_description = data['shortdesc']
nimble merlin
#
             aliases=['BotInfo', 'BOTINFO', 'Botinfo'])
async def botinfo(ctx, user: discord.Member):
    info = requests.get(/api/bots/423889279630966787)
    data = get.info.json()
    name = data['username']
    bot_id = data['id']
    discriminator = data['discriminator']
    short_description = data['shortdesc']
    certified = data['certifiedBot']
    library = data['library']
    tags = data['tags']
    owners = data['owners']
    prefix = data['prefix']``` Did you mean like that???
abstract crystal
#

why get in get.info if your request var is info

nimble merlin
#

idk....what should be there then????

abstract crystal
#

try it

nimble merlin
#

ok

abstract crystal
#

you'll se that get does not exist

nimble merlin
#

oh yea....idk why I put that in there

abstract crystal
#

you haven't defined get therefore you are unable to use it

#

just remove it

nimble merlin
#

k

#

info = requests.get(/api/bots/423889279630966787) my guess is to make that a string

abstract crystal
#

yes

nimble merlin
#

k

abstract crystal
#

that would be good

nimble merlin
#

no error message upon loading the bot...that's a start

#
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'library'``` That's the output....was it because the variables are unused??
#

maybe it's a typo actually

#

yea, it is

#

It should have been lib not library

abstract crystal
#

no, the response doesn't have library value

#

IF you'd actually read the docs you'd know that it's not called library but lib:

#
@bot.command(pass_context=True,
             aliases=['BotInfo', 'BOTINFO', 'Botinfo'])
async def botinfo(ctx, user: discord.Member):
    info = requests.get(/api/bots/423889279630966787)
    data = get.info.json()
    name = data['username']
    bot_id = data['id']
    discriminator = data['discriminator']
    short_description = data['shortdesc']
    certified = data['certifiedBot']
    library = data['library']   <----- Right here
    tags = data['tags']
    owners = data['owners']
    prefix = data['prefix']```
nimble merlin
#

nvm...theres no terminal output so I assume it worked

abstract crystal
#

i guess

nimble merlin
#

I haven't assigned an output so it probably is right

earnest phoenix
#

~>bal

trim plinth
idle grail
#

Can someone help me

#

How do you convert a parsed date into a date

#

someone

#

;-;

proven shale
#

is there a way to create a bot in java

trim plinth
#

yes

proven shale
#

can u give me a link where I can learn

#

I'm comfortable w/ java but idk the discord-specific stuff

inner jewel
proven shale
#

thx

zealous forge
#

@proven shale if you making a Bot. Like a standard one I'd heavily recommend JDA utilities

sinful lotus
#

im wondering why simple youtube api

#

some youtube videos return undefined like this

   Channel {

     type: 'channel',

     raw: 

      { kind: 'youtube#video',

        etag: '"RmznBCICv9YtgWaaa_nWDIH1_GM/s_cwZQQU5n75SyBim6WA6MNFXTQ"',

        id: '9eyyhtOrKPI',

        snippet: [Object],

        contentDetails: [Object] },

     full: false,

     kind: 'youtube#video',

     id: 'UCB6pJFaFByws3dQj4AdLdyA',

     title: 'Reol Official' },

  duration: 

   { weeks: 0,

     years: 0,

     months: 0,

     days: 0,

     hours: 0,

     minutes: 3,

     seconds: 48 } }

[ { id: '9eyyhtOrKPI',

    title: '[MV] REOL - drop pop candy',

    url: 'https://www.youtube.com/watch?v=9eyyhtOrKPI' } ]

undefined

any ideas?

#

it works on other videos

earnest phoenix
#

wat are you logging?

olive crown
#
  if (message.content.startsWith(prefix + "kick")) {
    let member = message.mentions.members.first();
    member.kick();
    message.channel.send(":white_check_mark: User kicked :white_check_mark:")
  };
  if (message.content.startsWith(prefix + "ban")) {
    let member = message.mentions.members.first();
    member.ban();
    message.channel.send(":white_check_mark: User banned :white_check_mark:")
  };```
#

please.

earnest phoenix
#

help

solemn obsidian
#

and you want us to help you how?

earnest phoenix
#

idk what to do

#

a nice guy is now using my bot token

#

and save my bot

#

he is good

austere meadow
#

@restive silo hey yuki i asked earlier in the d.js guild but since you're here i might as well ask you, do you know if the client.channels collection is supposed to not update after a channel is edited?

restive silo
#

what you mean "not update"

#

the Channel Object should update

austere meadow
#

only updates after i restart the bot

restive silo
#

master?

#

or stable?

austere meadow
#

im on latest master so im not sure if its an issue with me or not

#

yeah

restive silo
#

it should update ofc

austere meadow
#

latest commit

restive silo
#

oh no

#

wait

#

can you try something for me?

austere meadow
#

yeah whats up

restive silo
#

try msg.channel === client.channels.get(msg.channel.id) next time this happens

austere meadow
#

alright

restive silo
#

or wait can you reproduce it?

austere meadow
#

it happens everytime until i restart the bot

restive silo
#

hmm

#

seems like d.js isn't patching the channel object correctly

austere meadow
#

hmm im not sure

#

is there anyone else you know on latest master

#

maybe they could try it

restive silo
#

idk but i could ask space or bella to look into that

austere meadow
#

im not sure if its just an issue with me or if it is a lib issue tho

restive silo
#

i think space is using latest master somewhere

#

how would this be an issue with you?

#

oh did you disable any WS events?

austere meadow
#

idk i just assume

#

oh i did actually

restive silo
#

look up which

austere meadow
#
"disabledEvents": [
    "RELATIONSHIP_ADD",
    "RELATIONSHIP_REMOVE",
    "MESSAGE_REACTION_REMOVE_ALL",
    "USER_NOTE_UPDATE",
    "USER_SETTINGS_UPDATE",
    "TYPING_START",
    "CHANNEL_PINS_UPDATE",
    "CHANNEL_UPDATE"
  ]

ok im very sorry for wasting your time LMAO

#

channel update was disabled

#

fuck

#

sorry about that and thanks for the help blobheart

restive silo
#

haha no problem jynEHEH

#

i remember i got some breaking methods as i disbaled GUILD_MEMBERS_CHUNK or smth i couldn't fetch any members anymore

austere meadow
#

oh shit hahahaha

tepid laurel
#

@restive silo is that like a common issue?

#

Cause I have that event disabled aswell and been having the errors that โ€œMembers didnt arrive in timeโ€

#

Might that be connected?

restive silo
#

Yea you shouldnt disable that event

#

it is related

#

Because basecally you fetch members but ignore tge result snd then d.js timeout

tepid laurel
#

Hm I will enable it

#

Thanks for the info๐Ÿ‘Œ๐Ÿป

restive silo
#

You need to if you want fetch membrrs

heady zinc
#

@austere meadow henlo

earnest phoenix
#

ping

heady zinc
#

you don't need to disable user_note_update, nor user_settings_update, relationship_add and relationship_remove

#

you will never receive them on a bot account

#

also i don't recommend disabling channel_pins_update, the lib use it to update the cached channel object

sonic idol
#

what is the comand prefix for tonkku

uncut slate
#

it's a mention

clear hill
#

l

lime cave
#

@lime cave

solemn obsidian
#

Anyone uses the pool class coming with the pg lib for nodejs? How would I go about setting the current schema?

#

^ figured it out

clear tulip
#

hey someone set their bots library to Luki.js how could i set mine to my custom library?

indigo notch
#

You don't

clear tulip
#

wut is Luki.js then?

indigo notch
#

But that bot is certified

quiet bobcat
#

You can do it on any bot

#

Put it on other

#

@clear tulip

#

and save

clear tulip
#

but thats developer tools

#

thats for debugging

quiet bobcat
#

It's inspect element

#

Just do it

#

It works

#

I promise

#

Nate showed me it

solemn obsidian
#

input validation plz

inner jewel
#

it works

#

i did that

quiet bobcat
#

and there's your proof/validation

nimble merlin
#

OK...so I have set up a botinfo command (actually it was pretty much everyone else), however, when attempting to execute the command when the bot has no posted server count, the command fails...how can I get my bot say that Server Count: No server count? (I have checked the docs BTW)

clear tulip
#

ill try it momentarily

edgy needle
#

Hello

#

Can someone please help me with my bot

#

?

placid pendant
#

unfortunately im a beginner so

#

It depends what language its in

edgy needle
#

java

inner jewel
#

just ask the question, no need to ask to ask

edgy needle
#

ok

#

Can someone help me make a anime commands

#

?

nimble merlin
#

Hey, you know how we can setup botinfo commands by getting info from the DBL API, well, if the bot in question doesn't have a server count, how can I get my bot to change Server Count: ... to Server Count: No Server Count without the command failing as it checks for a servercount????

uncut slate
#

you need to post stats

#

there's no other way to add server count

nimble merlin
#

OK...let me reiterate what I meant: You know how if the bot that you want to find doesn't have a server count and so @gilded plank would say: Server Count: No Server Count yea? Well how do I do that is what I meant?

quiet bobcat
#

What if it hasn't got a server count

nimble merlin
#

exactly

quiet bobcat
#

on the site it says N/A

nimble merlin
#

ik

#

but the command fails if I try to get that

quiet bobcat
#

understood that

#

idk python

#

so can't help you :/

nimble merlin
#

I'm the one asking the question

#

oh ok...I misread the statement....idiot

quiet bobcat
#

it's ok

nimble merlin
#

lol ๐Ÿ˜ƒ

earnest phoenix
#

Is there any way i can ignore this
errors
at item.request.gen.end (/rbd/pnpm-volume/e67eaa42-e9dc-4865-a80b-09086f77c28d/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:71:65)

at then (/rbd/pnpm-volume/e67eaa42-e9dc-4865-a80b-09086f77c28d/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/node_modules/snekfetch/src/index.js:215:21)

at <anonymous>

at process._tickCallback (internal/process/next_tick.js:188:7)

(node:19250) 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: 6)
its trying to send a message to the #logs thats why

frail kestrel
#

ur not catching promise rejections

earnest phoenix
#

You don't technically have to do that

#

Unless it's requires with 11.3.1

#

how can i catch promise rejections?

#

It tells you in the error

frail kestrel
#

try { // thing } catch(err) { // thing }

nimble merlin
#

Hey, you know how we can setup botinfo commands by getting info from the DBL API, well, if the bot in question doesn't have a server count, how can I get my bot to change Server Count: ... to Server Count: No Server Count without the command failing as it checks for a servercount????

earnest phoenix
frail kestrel
#

old

nimble merlin
#

IK how to post it....

earnest phoenix
#

Oh?

frail kestrel
#

api libs now

#

fingerguns

earnest phoenix
#

Oh wait it's a command ur doing

nimble merlin
#

yes

earnest phoenix
#

<Client>.guilds.size should work

nimble merlin
#

i'm in async BTW

frail kestrel
#

if ur getting guild size from dbl

nimble merlin
frail kestrel
#

u can just do

earnest phoenix
#

Hmmmm

#

I gtg now, wish I could help more

quiet bobcat
#

He's making a botinfo command

frail kestrel
#

server count || "none"

#

|| means or

nimble merlin
#
             aliases=['BotInfo', 'BOTINFO', 'Botinfo'])
async def botinfo(ctx, user: discord.Member):
    
    info = requests.get('https://discordbots.org/api/bots/{}'.format(user.id))
    data = info.json()
    name = data['username']
    bot_id = data['id']
    discriminator = data['discriminator']
    short_description = data['shortdesc']
    certified = data['certifiedBot']
    library = data['lib']
    tags = data['tags']
    owners = data['owners']
    prefix = data['prefix']
    votes = data['points']
    servers = data['server_count']
    embed = discord.Embed(title="{}'s info:".format(user.name), color=0x6e7be1)
    embed.add_field(name='Name:', value='<@' + bot_id + '>' + "![dblCertified](https://cdn.discordapp.com/emojis/392249976639455232.webp?size=128 "dblCertified")" if certified else '<@' + bot_id + '>')
    embed.set_thumbnail(url=user.avatar_url)
    embed.add_field(name='ID:', value=bot_id)
    embed.add_field(name='Prefix', value=prefix)
    embed.add_field(name='Discriminator:', value=discriminator)
    embed.add_field(name='Library:', value=library)
    embed.add_field(name='Upvotes:', value=votes)
    embed.add_field(name='Servers:', value=servers)
    embed.add_field(name='Certified:', value=certified)
    embed.add_field(name='Tags:', value=", ".join(tags))
    embed.add_field(name='Owner(s):', value=', '.join([f'<@{id}>' '![dblCertifiedDev](https://cdn.discordapp.com/emojis/401725450470031362.webp?size=128 "dblCertifiedDev")' for id in owners]) if certified else ', '.join([f'<@{id}>' for id in owners]))
    embed.add_field(name='Description:', value=short_description)
    await bot.say(embed=embed)``` Here's the coed
frail kestrel
#

discord.pyyyy

nimble merlin
#

oh

frail kestrel
#

yay

#

in py, use or

nimble merlin
#

ok

frail kestrel
#

|| means or in plain English and python

nimble merlin
#

so embed.add_field(name='Servers:', value=servers || 'No Server Count')

frail kestrel
#

also why r u formatting the bot page into the message authors id

#

no

nimble merlin
#

oh...

frail kestrel
#

use or if ur in python

nimble merlin
#

oh ok lol

frail kestrel
#

or for py
|| for js

nimble merlin
#

Ahhhh ok thank you! ๐Ÿ˜ƒ

#
    yield from command.invoke(ctx)
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'server_count'``` It still won't work
#

embed.add_field(name='Servers:', value=servers or 'No Server Count') Is that what you meant???

frail kestrel
#

keyerror means u mistyped something I think

#

either that or itโ€™s wrong

nimble merlin
#

hmmmm, I can't have mistyped something.....hmmm

#
             aliases=['BotInfo', 'BOTINFO', 'Botinfo'])
async def botinfo(ctx, user: discord.Member):
    
    info = requests.get('https://discordbots.org/api/bots/{}'.format(user.id))
    data = info.json()
    name = data['username']
    bot_id = data['id']
    discriminator = data['discriminator']
    short_description = data['shortdesc']
    certified = data['certifiedBot']
    library = data['lib']
    tags = data['tags']
    owners = data['owners']
    prefix = data['prefix']
    votes = data['points']
    servers = data['server_count']
    embed = discord.Embed(title="{}'s info:".format(user.name), color=0x6e7be1)
    embed.add_field(name='Name:', value='<@' + bot_id + '>' + "![dblCertified](https://cdn.discordapp.com/emojis/392249976639455232.webp?size=128 "dblCertified")" if certified else '<@' + bot_id + '>')
    embed.set_thumbnail(url=user.avatar_url)
    embed.add_field(name='ID:', value=bot_id)
    embed.add_field(name='Prefix', value=prefix)
    embed.add_field(name='Discriminator:', value=discriminator)
    embed.add_field(name='Library:', value=library)
    embed.add_field(name='Upvotes:', value=votes)
    embed.add_field(name='Servers:', value=servers or 'No Server Count')
    embed.add_field(name='Certified:', value=certified)
    embed.add_field(name='Tags:', value=", ".join(tags))
    embed.add_field(name='Owner(s):', value=', '.join([f'<@{id}>' '![dblCertifiedDev](https://cdn.discordapp.com/emojis/401725450470031362.webp?size=128 "dblCertifiedDev")' for id in owners]) if certified else ', '.join([f'<@{id}>' for id in owners]))
    embed.add_field(name='Description:', value=short_description)
    await bot.say(embed=embed)``` That's the code
ruby dust
#

oh god...

#

embed.add_field(name='Owner(s):', value=', '.join([f'<@{id}>' '![dblCertifiedDev](https://cdn.discordapp.com/emojis/401725450470031362.webp?size=128 "dblCertifiedDev")' for id in owners]) if certified else ', '.join([f'<@{id}>' for id in owners]))why are you so overcomplicating thigs...

nimble merlin
#

idk...deal with it

#

as long as it works...I don't give a fuck

#

is there an if and else statement that I can do to check if the bot has a server count???

topaz fjord
#

Check if server count field isn't empty

#

Check if the string is empty

nimble merlin
#

what would I be checking for...as in would it be if: server_count == ' '????

topaz fjord
#

String that are empty are usually ''

nimble merlin
#

ok...i'll try that lol

#
    if servers == '':
        embed = discord.Embed(title="{}'s info:".format(user.name), color=0x6e7be1)
        embed.add_field(name='Name:', value='<@' + bot_id + '>' + "![dblCertified](https://cdn.discordapp.com/emojis/392249976639455232.webp?size=128 "dblCertified")" if certified else '<@' + bot_id + '>')
        embed.set_thumbnail(url=user.avatar_url)
        embed.add_field(name='ID:', value=bot_id)
        embed.add_field(name='Prefix', value=prefix)
        embed.add_field(name='Discriminator:', value=discriminator)
        embed.add_field(name='Library:', value=library)
        embed.add_field(name='Upvotes:', value=votes)
        embed.add_field(name='Servers:', value='No Server Count')
        embed.add_field(name='Certified:', value=certified)
        embed.add_field(name='Tags:', value=", ".join(tags))
        embed.add_field(name='Owner(s):', value=',\n '.join([f'<@{id}>' '![dblCertifiedDev](https://cdn.discordapp.com/emojis/401725450470031362.webp?size=128 "dblCertifiedDev")' for id in owners]) if certified else ', '.join([f'<@{id}>' for id in owners]))
        embed.add_field(name='Description:', value=short_description)
        await bot.say(embed=embed)``` It still won't work
nimble merlin
#

Hello, does anyone know what I did wrong???

sonic idol
#

lol

#

@nimble merlin not you the music

#

in the music server

nimble merlin
#

oh lol

abstract crystal
#

no

#

don't do that in python

#

if you want to check if string is not empty do if some_string:

#

@nimble merlin

nimble merlin
#

ok

#

so if server_count: ''????

#

Or have I misread your meaning

abstract crystal
#

do you want to print server count if it exists?

nimble merlin
#

nope

abstract crystal
#

i'd do it like this: ```python
embed.add_field(name='Servers:', value=servers if servers else "No server count")

nimble merlin
#

ah ok...thanks alot for the help ๐Ÿ˜ƒ

abstract crystal
#

if you get a key error then you should do servers = data.get("server_count", "")

nimble merlin
#

ok

edgy needle
#

can someone help me host my bot 24/7?

nimble merlin
#

It worked..thanks alot....that was a real help ๐Ÿ˜ƒ

abstract crystal
#

@edgy needle $$$, use vpsdime, vultr, digitalocean, linode or scaleway

edgy needle
#

are they free?

abstract crystal
#

nothing is free

nimble merlin
#

nope

edgy needle
#

i made my bot for free

nimble merlin
#

hosting is never free

abstract crystal
#

^

#

if you have github educational pack you can get 50$ free credit for digitalocean, but you must be a student

nimble merlin
#

^

edgy needle
#

can i just lie?

nimble merlin
#

nope

#

You have to give legal documents as far as ik

#

and if you lie, you could get prosicuted

edgy needle
#

oh

nimble merlin
#

for fraud

abstract crystal
#

well if you have a students id or any other verification that you are a student

#

you'll be fine

edgy needle
#

im trying heroku

abstract crystal
#

good luck, heroku is not 24/7

edgy needle
#

#sudlufe

nimble merlin
#

^

abstract crystal
#

you only get so many credits per day

nimble merlin
#

Your best chances are to invest a few $$$ a month into a decent VPS

edgy needle
#

credits?

nimble merlin
#

I will wait until either my bot gets a higher server count or I get a job in April

abstract crystal
#

server has to be offline for x amount of hours per day

edgy needle
#

oh ok

#

also one more thing

abstract crystal
#

yes?

edgy needle
#

how do a command run if the author has a spesific role

#

(sorry for bad england)

#

And my bot is scripted in java

abstract crystal
#

sorry i don't know jda, you should check documentation of your discord lib

edgy needle
#

oh ok

#

also will servers = data.get("server_count", "") work in a java script as a variable?

abstract crystal
#

no

#

this is python

edgy needle
#

rip

nimble merlin
#

lol

edgy needle
#

i need a server count script that works for java

abstract crystal
nimble merlin
#

^

restive silo
#

they are kinda old

trim plinth
#

@edgy needle posting server count or getting server count GWbowsuBlobThonkeng

slim heart
#

Im tryna make my bot message a specific thing in all the servers it's in, I already have this var guildList = bot.guilds.array() guildList.forEach(guild => guild.defaultChannel.send("+on"))
but the problem is that .defaultChannel is deprecated, but I can't use const blah = guild.channel.find("name", "general") because it can't define guild, and if I put it in the .forEach statement it doesn't like it

edgy needle
#

i need it to get the server count and show it

slim heart
#

@edgy needle show it where?

edgy needle
#

ik how to make it in PLaying

#

i just need to get it

#

the value

slim heart
#

client.guilds.size

edgy needle
#

lemme try it

nimble merlin
#

'GitHub'(if github else "No GitHub repo")) What would be wrong with this???

oblique sequoia
#

Github is a variable right

nimble merlin
#

yes

slim heart
#

crap

abstract crystal
#

hmmmm hyperhmm

edgy needle
#

Heroku 24/7 worked i dont need to pay

slim heart
#

One Eyed Reaper

#

that doesnt work

#

i think

#

cuz that's for js not py :>

abstract crystal
#

my friend @edgy needle

oblique sequoia
#

so you can do something like value=github or "No GitHub repo"

abstract crystal
#

no (one eyed....)

oblique sequoia
#

it tries the github variable first

nimble merlin
#

ik...but I want it to be a hyperlink

abstract crystal
#

@nimble merlin show the whole line

#

tnx

nimble merlin
#

k

oblique sequoia
#

Like a []() style link?

edgy needle
#

At least my bot is online when my pc is off

nimble merlin
#

oh...erm...yea...kinda hold on

#

embed.add_field(name='GitHub:', value='GitHub'(if github else "No GitHub repo"))

abstract crystal
#

there is the problem

#

why do you have if statement in parenthesis

nimble merlin
#

GitHub needs to be in []???

#

to check for a github link???

abstract crystal
#

value=f"[GitHub]({github_link_var})" if github_link_var else "No GitHub repo"

nimble merlin
#

oh

#

ok...thanks....๐Ÿ˜ณ

abstract crystal
#

your line doesn't make sense because you have "Github" as string but then just a space no + or something to link it together, then you have if statement in parentheses and nothing before if which makes it unusable

nimble merlin
#

Well.....i'm a dumb ass when it comes to coding soooooo

ruby dust
#
if isinstance(ctx.channel, discord.DMChannel):
    return
```is this a good way to check if the command was ran in DM? (discord.py-rewrite)
abstract crystal
#

uhmmmm lemme check, but i think yes

#

yes this should be fine

ruby dust
#

alright thanks

earnest phoenix
#

@slim heart that is not good code for global announcements

#

That will spam the API

slim heart
#

ik i'm just tryna add all the guilds to a mysql row ๐Ÿ˜ข

earnest phoenix
#

so you're not trying to do global announcements anymore?

slim heart
#

Well like, I was tryna get the bot to say +on in every guild

#

so I guess kinda it's an announcement

#

So ye

#
 var on = {
    "serverid": message.guild.id,
    "censor": true,
    "servername": message.guild.name
}
connection.query("DELETE FROM censorbot WHERE serverid = " + message.guild.id)
connection.query("INSERT INTO censorbot SET ?", on)
message.delete()
console.log("l")
}    ``` just fyi
nimble merlin
#
             aliases=['Prefix', 'PREFIX'])
@commands.has_permissions(administrator=True)
async def prefix(ctx, *args):
    try:
        prefix = db['prefix']
        prefix.insert(dict(name=ctx.message.
server.name, prefix='{}'.format(args)))``` Right, so this is the start of my prefix command...only issue that I have is how I can get my bot to set the prefix for the server that the command is used in....any leads???
slim heart
#

use a db

nimble merlin
#

I am...but how do I transfer the inputted prefix to change the prefix used on the server???

#

all that you see above you is using a database

slim heart
#

Not sure how to do it in the language ur using, but you should just be able to look for 'prefix' where serverid = serverid and set that to a variable when running a command

#

idk tho

abstract crystal
#

well if you are on rewrite and have read the docs, you'd know that there is a function for that

nimble merlin
#

hmm

#

I am still using async....sorry

slim heart
abstract crystal
nimble merlin
#

My guess is that no-one has a clue....correct???

slim heart
#

Read

#

The

#

Docs

#

๐Ÿ‘Œ

nimble merlin
#

can I find it on the async docs???

slim heart
#

I'm pretty sure Nani made it quite obvious...

nimble merlin
#

or the db docs maybe???

slim heart
#

Well either way, you should have read all of the docs before trying to do something...

nimble merlin
#

Not helpful.....from his context...he is either saying that I need to read the rewrite docs or the db docs

#

I don't use rewrite sooooo....i'll try the db docs

slim heart
nimble merlin
#

what?

#

OK...now i'm just confused....

#

Actually.....I was confused the whole time TBH

abstract crystal
#

@nimble merlin you have two options:

  1. Migrate to rewrite
  2. Write your own custom prefix checking and command finding
ruby dust
#

you admited that you are new to coding, that should have hinted you to go learn more a dozen times

abstract crystal
#

gl m8

nimble merlin
#

Jesus you don't have to be a dick about it

abstract crystal
#

stating facts, i'm sorry

nimble merlin
#

Yea, well then state them in a less "dominant" way

#

Once upon a time, you knew as much as I did

ruby dust
#

now stop being a dick yourself, people are trying their best to help you, a beginner, that refuses to learn by themselves

abstract crystal
#

yes but i went on a voyage on the vast seas of google and tutorials

nimble merlin
#

Like.. talking.. to.. a.. brick.. wall...

ruby dust
#

๐Ÿคฆ

#

I'm out

nimble merlin
#

You know what...forget it...forget..it

ruby dust
#

are you finally going to learn yourself? o.0

#

will that finally happen?

nimble merlin
#

I don't know...only time will tell

#

I'm not a god....I have school and other various concerns about my life to worry about...this isn't a proffession...although, admitadley, I could do more TBH

#

Can we drop this now....it's kinda gotten off-topic

abstract crystal
#

As I stated before and I can't stress this enough times: Do not plunge into bot development, which is not easy, without learning the basics of python like loops and statements...

nimble merlin
#

You done yet?

ruby dust
#

well good for you lol, I have work that takes almost a whole day of my life, and I manage to do like 10 times more than you asking here for help

abstract crystal
#

Get yourself a raspberry pi or something and learn functional programmin

#

pls

nimble merlin
#

Yea, your opinion means nothing to me...like anybody elses...sorry that i'm a Jack Ass but that's just how I am

abstract crystal
#

if you are creating bots I at least expect you to know how to loop a for loop five times

#

enough said

nimble merlin
#

THANK YOU!!! Now we can drop the conversation before the Ban Hammer does it's work

ruby dust
#

I sometimes think you are under 13... just because of the fact that every single message you send has a hint of your emotions

earnest phoenix
#

Well messages should convey emotions

nimble merlin
#

Actually....it's typical for a 10-16 (average) year old to express their emotions like that

#

Emotions are what make is mentally human