#development
1 messages ยท Page 386 of 1
๐คฆ
How to refer to a package
How do you except to a file fully being logged by requiring it
lol
Thats what you are doig
7
Requiring a file and logging it
No shit its undefined
...
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
Is the file a function?
module.exports = function () {
request("https://bts.net.pl/random_image/api", function(err, link) {
return link.body;
});
} ```
You realize
That if you export it of a file
<somefile>.somefunc()
Is what you want
?
Change module.exports = function()
To
exports.<somenameforthefunction> = function()
Give it a name, and then
Wherever you are requiring it
<somefile>.thatFunctionofYours()
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?
i do know
Then why use brackets on request
i dont know if i should choose snekfetch or request
Either way youre still doing it wrong
i could use snekfetch
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
im trying to fetch what it says on https://bts.net.pl/random_image/api/
And you could act on that ๐คท๐ผโโ๏ธ
how To get the bot online on koltin?
[emojis]
[no u]
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?
ywah maybe
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....
do you know python?
have u done any projects before?
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
what dataset
you know...dataset....the database "language" (I guess you could call it?)
owo theres actually a lib called dataset
yes
https://dataset.readthedocs.io/en/latest/ you can refer to the docs
I have literally no-clue how to set it up or how to integrate it into my commands
oh ok....thanks...I guess ๐
well i use mongo (yaml and json if that counts)
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
JSON isnt good for databases, but its ok for config. im moving over to yaml for config now though cos it looks better
using nosql database and storing json in files are a different thing
ok
For anyone that has made them before, are database commands like "economy" (based) commands and customizable prefix's easy???
yes if u know how to work with databases and all
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???
that isnt a hard goal though, once you manage it youll understand basic insert and getting data
ok
oh ok lol
I don't have a database yet...do I need one or can I just do that inside of the code???
you need one
ok...
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???
why do I always see you asking a question with at least 3 question marks at the end...?
idk....
anyway, what is missing before table.insert as it's giving me an error
if you know obviosuly...
I only know SQLite3
oh....i'm using dataset
Does anyone else know what should be placed infront of table.insert?
m?invert @ruby dust
Ah sorry

I have not seen the channel sorry
hellllloooooo???????? What do I need to place infront of table.insert to make it function in a command?
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...
have you defined table var?
no
well there you go
table.insert => This isn't Lua
table = something_here
no, it's dataset
it would've been a lot easier if you would just go with SQLite3
ok
it's already on sqlite3
wait, SQLite3 is a language???
You didn't know SQL is a language
SQL => Structured Query Language
you start with import sqlite3, make any sense?
I start with import dataset but yea...it makes sense
lol ๐
then you continue with _DB = dataset.connect('sqlite:///./database.db')
I'm using dataset for the last time...
oh lord, dataset is so difficult compared with sqlite3
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 ๐ฉ
inserting discord.Member class is not a good idea
ID is a better option since is unique
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...
ohhhh
ok...so I change that to ctx.message.author.id
oh lol
I just spotted a typo as well lol ๐
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..
not rly
hmmmm
how could I add more to the balance variable then?
or should 500 be a string???
No
That part is ok
You need to specify which column should update function search for the id
ok
Aka. Look at the docs
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
@elfin ledge copy it from here: http://discordapp.com/developers/applications/me
my question why ids different
maybe you were copying wrong id
yes
then you were copying it from another bot/user
it's impossible sorry
top id is if i copy bot user
or you have created that app very early
there you go
lemme just calculate sth
first ID: '2016-07-29 18:01:55.559000'
second ID: '2016-07-29 17:23:18.928000'
creation dates
when the bot gets approved then you can have it
you wait
so i don't need to do any thing
no
for now
just wondering
my bots starting to get to a certain size which requires shards where would the best place to learn about that be?
which language?
discord.js
probbs the library docs
https://anidiots.guide/information/understanding-sharding.html heres a good one for js then
or that ^
My bots code is 925 lines long....I should probably learn how to shard it....any hints for tutorials for d.py async???
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??
also what are you doing on async lul
lol
use rewrite, async is feature locked
You should probs use a CMD handler
like?
Idk google
async2rewrite - Automagically converts discord.py async-branch code to rewrite-branch code.
Idk python
lul
and you dont use sharding until you get to at least 2500 servers
oh....fair enough
@abstract crystal u sharder at 1k
shhh
lol
*I sharded
i have work intensive commands, that has nothing to do with sharding
lol
@abstract crystal Your bot will be broke by the time you reach 2500 servers because you didn't shard in time
damn then it already broke
lol ๐
Just make sure db allows lots of connections lol
Adding 1 a doesn't change shit from hsving 0
It'll all crash when I reach 2 shards
Soon โข 750 guilds needed
lul dont mind me client = AutoShardedBot(command_prefix=get_prefix, shard_count=3)
python -m async2rewrite ollie.py so I did this...but nothing happened
when a bot is sharded
does it split the server equally
or
does it do like 2500 one shards 100 servers another
how does it split
It can be a random amount on each
does it balance the servers tho
so @abstract crystal how do I use async2rewrite???
I've seen a bot have 3k servers with 1.3k on one and 1.7k on another
ohhhhh Ik now...thanks ๐
Discord why u not make docs for mobile
Official fix: use a desktop
huh, what da ya know...async2rewrite works...brilliant
why would u use docs on mobile
it missed a few things tho...I see that it does that normally
rewrite is evolving
so yea
join discord.py server for updates (you can find it in README.md in discord.py GH)
k
Cus im not at my computer
โ Request desktop site
what does @dusk verge.command change to in rewrite???
lol...theres actually a bot called bot lol
look. at. the. docs.
o. k
is it dangerous to shard your bot too early??
no, but it's useless
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?
when I try to run my bot, it gives this error message: from discord.ext.commands import AutoShardedBot ImportError: cannot import name 'AutoShardedBot'
yea exacly
let me reiterate myself: did you update discord.py to rewrite?
I have...into a different file, however, I am not yet going to use that file
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
ok
in rewrite?
in python
pip install -U git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py
ohhh, yea, when I did that...it installed all that I needed BTW
it installed async
what, when i did pip install discord.py[rewrite]...the rewrite bit is there for a reason
yes, but it does not serve any purpose since is not defined in setup.py in extras:
oh
only thing that'd work is discord.py[voice]
do your research first
๐ณ
from discord.ext.commands import AutoShardedBot anyway, why doesn't this work???
or do you not know?
Because you don't have rewrite installed
oh ok...would it work on async code but with rewrite installed???
no
oh...fair enough
oh...ok...
How do people customize the display of their bots library like shown in the image?
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.... ๐
css my friend, css
yeah btw, where do people do that css edit in their dbl page?
long desc
@ruby dust long description
to make it look better
hmm
oops..I read that wrong lol
just wondering what sort of time scale for bot approval and is there a notification or do i need to keep an eye?
soo, how do I actually edit the info provided?
@elfin ledge they generally start approving soon
@elfin ledge you get notified by bot
@elfin ledge luca will message you if it gets denied or accepted
thx
lol 3 mentions
lol
Weird
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???
- no tutorial
- messa around with inspect for a while and you'll find it
ok
try right-clicking on the library name and clicking inspect and hope you find the selector in the css
thats how I did it
ยฏ_(ใ)_/ยฏ
does somebody have a say command they could quickly test my bot with?
want to see if it still responds to other bots
oh..it's actually pretty easy TBH...thanks! Great help ๐
@edgy vale I can use my eval to check. Just need your bots name and help command
wait nvm that doesnt work if its muted haha
o lol
should i ping the mod that muted my bot if i fixed it?
i checked with my other bot
mk then go ahead
@uncut slate hey i fixed my bot (@earnest phoenix) responding to other bots
I broke it....๐

<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???
yea, but what stops it from replacing it on the bots actual page instead of the description
why do you want to rename the lib you are using. You haven't even modified it, are you trying to dishonor the author?
oh, so should I change %20discord.py... with something else?
no you leave it as it is
soooo
discord.py
whatever
...
OML......this is difficult...there must be another way that doesn't use inspect cos copying that and hoping doesn't work
how do i dm someone with jda
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.
My bot was declined if i fixed the issue can it get reavaluated
yes
how do i resubmit
you just add the bot like normal
does anyone know the resolution to my issue???
What's wrong with this 'purge10': (msg) => { if (msg.guild.member(msg.author).hasPermission('MANAGE_MESSAGES')) msg.channel.fetchMessages(10).then(msgs => msgs.delete()) },
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
!say Hi
Why isnโt it working
Cause you cant use bots in here
Oh
how do i use bulkDelete? @tepid laurel
Oops
Call it on a channel and pass either an amount to delete, a collection etc
im gonna guess this msg.channel.bulkDelete() ?
Np
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?
I would just do if it isnโt then return the message
And hasPermission is deprecated
@trim plinth How do I get uptime in hours minutes and seconds
you have to do that yourself
ffs
- basic math
- there are probably 30000 npm modules that do that
sff
not very quick maths
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.
@nimble merlin ```html
<style>
p {
color: #FFFFFF;
}
</style>
Pretty sure that's how.
ok
And for any other text fields, just change p with the tag.
ok ๐
How can I make an ms response in Discord.py?
@gilded blaze discord.js?
@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)
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;
what's that class for?
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
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
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)
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)
@tepid laurel d.js v12 has a structures class which allows you to extend classes already made
Lmao thats a nice one they did
@cold harness use aiohttp lib for accesing the web
In the docs you can find an example
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, " ")}"
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.
is there any way to tell if a channel is nsfw in discord.py without rewrite
i am considering it
does anyone know if asyncios subprocess functions have a universal_newlines argument?
actually fuck
nvm
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...
yes, but the only difference is that you don't have to pass_context anymore since it defaults to true
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
I just typed pip install discord and got what I needed... I think, at least
I guess that just installs both rewrite and async, but idk
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```
missing comma
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?
channel = bot.get_channel(channel_id)
await channel.send(content)
ok...thank you
please read the rewrite docs
it will be better for everyone rather than asking here constantly
good point....I probably should...
it's not that different from async, but it has some changes in the code
ik....lol
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?
Um... I don't understand what this means... Can someone explain it to me?
User doesn't exist
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
if you are using rewrite, why are you looking up the async docs?
i'm not...i'm not switching for a few more days
well async is pretty outdated and will probably never receive any updates, so you have your chance to switch libs while you still can
ik...like I said i'm switching in a few days....do you know the answer to the question?
if I'm gonna look for an answer then I will find it in async docs, which you failed anyway
ยฏ_(ใ)_/ยฏ
You know what never mind
```IF EXISTS (SELECT * FROM censorbot WHERE serverid = + message.guild.id +)
INSERT INTO censorbot SET ?
what's wrong with this...
How do I list arguments provided in a command without either of these happening:
Quick question
go on?
Are you sure you know python
no....it's just a hobbie...the only decent way to learn it is to do it
that's my opinion anyway
oh ok...
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?
Don't encode unicode
yeah, like I'm doing that intentionally..
What are you trying to do
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
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
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...
Why not log the command in your message event
Lmao
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
has anyone had any issue with my bot?
?
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....
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
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?
ok...so how do I use the dbl bot object?
o.0
yea...we both know that I am completely new and an absolute noob
you don't have to rub it in a bit.... ๐
prefix is a part of your bot, nothing to do with dbl
that screenshot is from the dbl docs
ik
are you listing your own prefix?
then you need to fetch the bot object
GET /api/bots/:id
OK
aliases=['BotInfo', 'BOTINFO', 'Botinfo'])
async def botinfo(ctx, user: discord.Member):
GET /api/bots/:id``` it's probably wrong....
oh wait ik
oh dear...
I need to define it right?
should I just give him a tutorial courses for api or can we just forget this ever happened?
You choose
seriously... you aren't going to get anywhere, go learn python and API
ouch.....
you'll get more knowledge from there than here
or
lmgtfy is an annoying piece of shit
the python library
lol
idk if it has implemented getting
DBL-Python-Library - A simple API wrapper for discordbots.org written in Python
k
Steps to get bot info in python:
- Pleaseeee useee async (aiohttp) but if you insist fine use requests, just remember that they are not asynchronous
- Make a request to GET BOT api endpoint (
/api/bots/insert_bot_id_here) - Parse JSON request to a dict object with
data = your_request_var.json() - Read data from the dict:
short_description = data['shortdesc']
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???
idk....what should be there then????
try it
ok
you'll se that get does not exist
oh yea....idk why I put that in there
k
info = requests.get(/api/bots/423889279630966787) my guess is to make that a string
yes
k
that would be good
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
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']```
nvm...theres no terminal output so I assume it worked
i guess
I haven't assigned an output so it probably is right
~>bal
is there a way to create a bot in java
yes
can u give me a link where I can learn
I'm comfortable w/ java but idk the discord-specific stuff
JDA - Java wrapper for the popular chat & VOIP service: Discord https://discordapp.com
thx
@proven shale if you making a Bot. Like a standard one I'd heavily recommend JDA utilities
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
wat are you logging?
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.
help
and you want us to help you how?
idk what to do
a nice guy is now using my bot token
and save my bot
he is good
@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?
because i made changes to a channel (set the nsfw) but it doesn't seem to reflect https://please.zbot.me/GinQjk7U.png
only updates after i restart the bot
it should update ofc
latest commit
yeah whats up
try msg.channel === client.channels.get(msg.channel.id) next time this happens
alright
or wait can you reproduce it?
hmm im not sure
is there anyone else you know on latest master
maybe they could try it
im not sure if its just an issue with me or if it is a lib issue tho
i think space is using latest master somewhere
how would this be an issue with you?
oh did you disable any WS events?
look up which
"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 
haha no problem 
i remember i got some breaking methods as i disbaled GUILD_MEMBERS_CHUNK or smth i couldn't fetch any members anymore

oh shit hahahaha
@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?
Yea you shouldnt disable that event
it is related
Because basecally you fetch members but ignore tge result snd then d.js timeout
@austere meadow henlo
ping
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
what is the comand prefix for tonkku
it's a mention
l
@lime cave
Anyone uses the pool class coming with the pg lib for nodejs? How would I go about setting the current schema?
^ figured it out
hey someone set their bots library to Luki.js how could i set mine to my custom library?
You don't
wut is Luki.js then?
But that bot is certified
You can do it on any bot
Put it on other
https://google.is-a-shit.host/sSTJwzbP.png then inspect element on the other box
and then do this: https://google.is-a-shit.host/ZPvuoBvI.png
@clear tulip
and save
input validation plz
and there's your proof/validation
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)
ill try it momentarily
java
just ask the question, no need to ask to ask
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????
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?
What if it hasn't got a server count
exactly
on the site it says N/A
lol ๐
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
ur not catching promise rejections
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
try { // thing } catch(err) { // thing }
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????
Use the #312614469819826177
old
IK how to post it....
Oh?
Oh wait it's a command ur doing
yes
<Client>.guilds.size should work
i'm in async BTW
if ur getting guild size from dbl
I want it like this
u can just do
He's making a botinfo command
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 + '>' + "" 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}>' '' 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
discord.pyyyy
oh
ok
|| means or in plain English and python
so embed.add_field(name='Servers:', value=servers || 'No Server Count')
oh...
use or if ur in python
oh ok lol
or for py
|| for js
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???
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 + '>' + "" 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}>' '' 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
oh god...
embed.add_field(name='Owner(s):', value=', '.join([f'<@{id}>' '' for id in owners]) if certified else ', '.join([f'<@{id}>' for id in owners]))why are you so overcomplicating thigs...
idk...deal with it
as long as it works...I don't give a fuck
Anyway, how do I get my bot to say this if there is no server count
is there an if and else statement that I can do to check if the bot has a server count???
what would I be checking for...as in would it be if: server_count == ' '????
String that are empty are usually ''
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 + '>' + "" 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}>' '' 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
Hello, does anyone know what I did wrong???
oh lol
no
don't do that in python
if you want to check if string is not empty do if some_string:
@nimble merlin
do you want to print server count if it exists?
nope
i'd do it like this: ```python
embed.add_field(name='Servers:', value=servers if servers else "No server count")
ah ok...thanks alot for the help ๐
if you get a key error then you should do servers = data.get("server_count", "")
ok
can someone help me host my bot 24/7?
It worked..thanks alot....that was a real help ๐
@edgy needle $$$, use vpsdime, vultr, digitalocean, linode or scaleway
are they free?
nothing is free
nope
i made my bot for free
hosting is never free
^
if you have github educational pack you can get 50$ free credit for digitalocean, but you must be a student
^
can i just lie?
nope
You have to give legal documents as far as ik
and if you lie, you could get prosicuted
oh
for fraud
well if you have a students id or any other verification that you are a student
you'll be fine
im trying heroku
good luck, heroku is not 24/7
#sudlufe
^
you only get so many credits per day
Your best chances are to invest a few $$$ a month into a decent VPS
credits?
I will wait until either my bot gets a higher server count or I get a job in April
server has to be offline for x amount of hours per day
yes?
how do a command run if the author has a spesific role
(sorry for bad england)
And my bot is scripted in java
sorry i don't know jda, you should check documentation of your discord lib
oh ok
also will servers = data.get("server_count", "") work in a java script as a variable?
rip
lol
i need a server count script that works for java
^
they are kinda old
@edgy needle posting server count or getting server count 
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
i need it to get the server count and show it
@edgy needle show it where?
client.guilds.size
lemme try it
'GitHub'(if github else "No GitHub repo")) What would be wrong with this???
Github is a variable right
yes
crap
hmmmm 
Heroku 24/7 worked i dont need to pay
my friend @edgy needle
so you can do something like value=github or "No GitHub repo"
no (one eyed....)
it tries the github variable first
ik...but I want it to be a hyperlink
k
Like a []() style link?
At least my bot is online when my pc is off
oh...erm...yea...kinda hold on
embed.add_field(name='GitHub:', value='GitHub'(if github else "No GitHub repo"))
value=f"[GitHub]({github_link_var})" if github_link_var else "No GitHub repo"
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
Well.....i'm a dumb ass when it comes to coding soooooo
if isinstance(ctx.channel, discord.DMChannel):
return
```is this a good way to check if the command was ran in DM? (discord.py-rewrite)
alright thanks
@slim heart that is not good code for global announcements
That will spam the API
ik i'm just tryna add all the guilds to a mysql row ๐ข
so you're not trying to do global announcements anymore?
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
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???
use a db
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
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
well if you are on rewrite and have read the docs, you'd know that there is a function for that


My guess is that no-one has a clue....correct???
can I find it on the async docs???
I'm pretty sure Nani made it quite obvious...
or the db docs maybe???
Well either way, you should have read all of the docs before trying to do something...
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

what?
OK...now i'm just confused....
Actually.....I was confused the whole time TBH
@nimble merlin you have two options:
- Migrate to rewrite
- Write your own custom prefix checking and command finding
you admited that you are new to coding, that should have hinted you to go learn more a dozen times
gl m8
Jesus you don't have to be a dick about it
stating facts, i'm sorry
Yea, well then state them in a less "dominant" way
Once upon a time, you knew as much as I did
now stop being a dick yourself, people are trying their best to help you, a beginner, that refuses to learn by themselves
yes but i went on a voyage on the vast seas of google and tutorials
Like.. talking.. to.. a.. brick.. wall...
You know what...forget it...forget..it
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
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...
You done yet?
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
Yea, your opinion means nothing to me...like anybody elses...sorry that i'm a Jack Ass but that's just how I am
if you are creating bots I at least expect you to know how to loop a for loop five times
enough said
THANK YOU!!! Now we can drop the conversation before the Ban Hammer does it's work
I sometimes think you are under 13... just because of the fact that every single message you send has a hint of your emotions
Well messages should convey emotions



