#discord-bots
1 messages · Page 1076 of 1
it will load all py files from commando
nope not working
welp then its a error in one of your cogs
why is it none type
not in loading them
all of them
in commando.area
Use any other way ig?
i send u the code
lemme see
from discord.ext import commands
import discord
from progress.stats import *
class Area(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
@commands.cooldown(1, 1, commands.BucketType.user)
async def area(self, ctx, arg: int):
try:
stats = Stats(ctx)
if 1 <= arg <= 14:
if arg <= stats.highestArea:
db[stats.userid + 'area'] = arg
await ctx.send(f'**{ctx.author.name}** has moved to **AREA {arg}**')
else:
await ctx.send(f'**{ctx.author.name}** fight more bosses to unlock this area :D')
else:
await ctx.send('404 area not found')
except KeyError: #error handler
await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or not at the latest version. Try using `rpm start`')
def setup(bot):
bot.add_cog(Area(bot))
def setup(bot):
bot.add_cog(Area(bot))
``` this is the problem
@shrewd apex https://paste.pythondiscord.com/evikiniqux
See this after helping him/her
Idk i did all correct idk thus happening
ok
what should it be
await?
or self.bot
Async def
async def setup(bot):
await bot.add_cog(Area(bot))
ok
I also got this error first
Hmm?
import discord
from discord.ext import commands
class anime():
def __init__(self, bot):
self.bot = bot
@commands.command()
async def pie(self ,ctx):
initial = 1
cars = []
await ctx.send("enter number of labels")
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
nov = await bot.wait_for('message', check=check,timeout=5)
while initials<=nov:
await ctx.send("enter the value of pie chart to append")
apens = await bot.wait_for('message', check=check,timeout=5)
cars.append(apens)
initials += 1
await ctx.send(cars)
def setup(bot):
bot.add_cog(anime(bot))
It's working anyway
urs 👆 it wont in 2.0
5 seconds timeout......un-cool
not mine
this should work idk what u are trying to do tho
why dont u do that with matplotlib
It was just a demo code cause i need
I did everything using python first
Now me converting it to command
But me getting errors
ok...
Replit is fool
good morning or afternoon...
uh...
Me on Android no better option
ur code had the errors how is it replits prob?
But it should atleasts show tabs
working now?
Hmmm big problem
hmm
u changed that in all your cogs
Still me getting errors
import discord
from discord.ext import commands
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
class anime():
def __init__(self, bot):
self.bot = bot
@commands.command()
async def pie(self ,ctx):
initial = 1
cars = []
await ctx.send("enter number of labels")
nov = await bot.wait_for('message', check=check,timeout=5)
while initials<=nop:
await ctx.send("enter the value of pie chart to append")
apens = await bot.wait_for('message', check=check,timeout=5)
data.append(apens)
initials = int(initials+1)
await ctx.send(cars)
async def setup(bot):
await bot.add_cog(anime(bot))
nop not defined data not defined
I think me need big Brian
That are Solly mistakes I'll solvebit indentation is like a huge mountain
which line is it giving indent error
@commands.command() line
Anime(commands.Cog)
?
Indentation problem fixed!
But now a new error came
It's says cogs must derive from cog
class anime(commands.Cog)
didnt i say the same
you have many bugs inside the pie function as well, like direct usage of bot variable
😔i just came in the chat so didnt see that
maybe i wasnt clear
await bot.wait_for('message', check=check,timeout=5)
Guys i getting error
It's says bot is not defined
afternoon....same to you....
ctx.bot or self.bot is your deal
Hmm means self.bot.wait_for?
the class name do be anime with a pie chart command
🤣
can anyone tell what does commands.BucketType mean i googled it but some stack overflow answers popped up
!d discord.ext.commands.BucketType read the docs instead
class discord.ext.commands.BucketType```
Specifies a type of bucket for, e.g. a cooldown.
its mostly used as a cooldown specifier, as mentioned
ty
It's accepted in a cooldown deco, telling on what u wanna impose a cooldown. BucketType.guild will make the cooldown work on guilds as a whole, whereas BucketType.user will make the cooldown work on individual users
Imagine discord not sending my message
user*
Me getting this error now
work*
Uh, yea that
read the error...
ooh thanks you explained as i want
hunter's smort
u also smort
I just know what he wanted. I have also had the same issue when I just started with cooldowns since I never understood how they worked
weird
Me not able to solve error....
Ig i should quit making pie command
and start reading the docs
where are you creting the check function? if its outisde the command, you wont be able to use it
ctx variable is not in your check functions' scope why is it outside the pie method?
error is as it says ctx is not defined if u want to put check outside u have to pass ctx as parameter
make a pie instead
pi or pie?
and, sarthak's smort and funny too
pi is an mathematical expression, pie is an eatable
ik 🥲
😔 why would someone ask to make a pi
Damn it’s so funny that I’m still not done with my wm system lol
only if it was true
he was making a pie command...
same thing, pi was derived from pie
it is u pretty smart?
no, you ash and hunter
strange knowledge +1
And stop this convo before I make y'all start hating me, by running the ot command
How do I make my bot to respond to other bots?```
depends if its a comamnd or an event
bot.user generally
Huh
Sadly dpy ignores command messages from other bots
lmao, yeah, since pi completes 3 parts of a circle and a half of a one fourth taken nearly to be 14 (3.14), hence makes a pie, anyways, ill stop
happily you can just override the on_message and prevent it from doing that

You know... gimme some of yr knowledge so that I can also get good marks
can you send me code example?
sure, i dont even need any anymore
Easier then it already is!
Bots have nitro!
Faster then lightning!
@shrewd apex can you send me code example?
*process_commands in 2.0
u can only contact with other bots in on_message event so use that
Process commands in 1.7 too @slate swan
they just move if if message.author.bot line in that method
@bot.event
async def on_message(message):
if message.author.id == bot.user:
#stuff
oops habit from help channel
1.7.3 ->
async def on_message(self, message):
if message.author.bot: return
await self.process_commands(message)
``` 2.0 ->
```py
async def process_command(self, message):
if message.author.bot: return
async def on_message(self, message):
await self.process_commands(message)
they now check the bot condition in different method
how to get the server profile picture of a user in discord.py ?
What the
import discord
from discord.ext import commands
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
class pie(commands.Cog):
def __init__(self, bot):
self.bot = bot
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
@commands.command()
async def pie(self ,ctx):
initial = 1
cars = []
await ctx.send("enter number of labels")
nov = await self.bot.wait_for('message', check=check,timeout=5)
while initials<=nop:
await ctx.send("enter the value of pie chart to append")
apens = await self.bot.wait_for('message', check=check,timeout=5)
data.append(apens)
initials = int(initials+1)
await ctx.send(cars)
async def setup(bot):
await bot.add_cog(pie(bot))
Is it correct now?
eww
Guild.icon_url in 1.7.3
Guild.icon.url in 2.0
inside the command does not mean inside the cog
!d discord.Member.display_avatar
property display_avatar```
Returns the member’s display avatar.
For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.
New in version 2.0.
works?@bot.event async def on_message(ctx): if ctx.author.id == "help":
@shrewd apex
wont work
well i typed it all on phone so nvm the indents
no it doesn't
Ok means I'll do it in @commands.command()
How can I get members from all of the guilds my bot is in?
oh display_avatar
i already fixed all that stuff before in previous chat
!d discord.Client.users
property users```
Returns a list of all the users the bot can see.
just the syntax, even im on phone, might as well see the same as you
why
Want it in numbers tho
!d discord.Client.guilds is also there @slate swan
property guilds```
The guilds that the connected client is a member of.
@commands.command()
async def pie(self ,ctx):
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
initial = 1
cars = []
await ctx.send("enter number of labels")
nov = await self.bot.wait_for('message', check=check,timeout=5)
while initials<=nop:
await ctx.send("enter the value of pie chart to append")
apens = await self.bot.wait_for('message', check=check,timeout=5)
data.append(apens)
initials = int(initials+1)
await ctx.send(cars)
Now?
Hunter, that's users, which willr return User objects
len(bot.users)
!d discord.Client.get_all_members
ping when reply dosent mean u keep pinging me every message
He just wants the number of users smh
Is it correct now?
Nvm
sheesh
run it
yes correct
Ok
Isn't this literally the same as sum([x.members for x in bot.guilds]) or I'm wrong?
you're correct
Thought so
I want to write a bot that deletes a roll from another server when I use command in another server
what should i do?
Uhhh good question
isn't that what get_all_members do?
idk didnt even know that existed
members= []
[members.extend(g.members) for g in bot.guilds]
``` seems noicee
get the role through id and use the delete method on it
and the bot should ne in both the servers
ill go to sleep now good night
gn sweet dreams
gunnite Ashley
what's the time there
can i use it with name?
How fix this?
i told u nop and data was not defined in ur code
Oof
Didn't u just wake up tho
can i use it with name?
can you send me code example?
@shrewd apex
you used a variable before defining it
didnt even sleep
How can I have my !help command not returning a error when arguments are missing, so that I can have for example !help commands and then send a message which shows help for all commands and then also commands like !help moderation, etc
Done!
subclass the HelpCommand class
1:15 pm
yeah u have to fetch the role by name
Damn
Can You sEnd Me Code example pls?
you too you too

!d discord.utils.get
discord.utils.get(iterable, /, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Changed in version 2.0: The `iterable` parameter is now positional-only.
Changed in version 2.0: The `iterable` parameter supports [asynchronous iterable](https://docs.python.org/3/glossary.html#term-asynchronous-iterable "(in Python v3.10)")s...
the good ole UK
ohh 5:45 here
thanke tc
noooo
Anyone?
How can I have my !help command not returning a error when arguments are missing, so that I can have for example !help commands and then send a message which shows help for all commands and then also commands like !help moderation, etc
the role is from another server
so fetch the guild object by id
it was an example ur bot should be in that guild to delete it tho and have perms
yo guys, my free dyno hours on Heroku are out. wha dot I do now?
I think™️ you could also do [member for guild in bot.guilds for member in guild.members]
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
its delete role in server that command used in :/
role_object = discord.utils.get(ctx.message.guild.roles, name="go")
await role_object.delete()
550 hrs without cc registration 1000 with
@shrewd apex
read above ☝️
yeah but what do I do now..
...
make another account? eh
wait for next month or make another acc
create an alt account and host it there and then revert back , ease
and run on that
its only works With iD?
just shorten the code to @shrewd apex @dry quiver
bot.http.delete_role(server_id, role_id) thank me later
Oh so its gonna give me free hours tomorrow again?
Tomorrow is new month isnt it..
yeah
damn ty bro love you so much
lemme try
can i user role_name = ?
so will it just start by itself or should I do git push heroku master again
itself
now what?
they just scale the dyno to 0 and stop the process
You would have to use utils.get to get the role first
but since you're doing that, just use the normal way of deleting role then
🥲
read the docs...
ty legend
lmao i seriously should be studying for maths now...
last thing im gonna do lol
thats why I was here but fine ig
Lmao if I ever make a private wrapper, I would have made it so that u can use raw API methods (like hikari) and then check if the role arg is string. If it is, then use utils.get or smth lmao
Just make my life easier
they have a tiny neat example there
What chapter
sample papers chapters over
Ah
I alwYs procrastinate doing those lmao
just dont wrap the discord api now, its boring
whats problem?
await it
To dm a user what should I use in this code?
async def fm(member): await member.send(“hello”)
await bot.http
I ain't wrapping any API, each of them is already wrapped and boring
create a dmchannel if it doesn't exist
then send
some random api uwu
i agree, funny how discord.py has a get_member_named method but not get_role_named
how ?
member.create.DMchannel?
There's already an API wrapper
send does that for you
That's a Discord endpoint
I know its an api....nvm
how to use this with role_name ?
welp i didn't know that discord knowledge +1
I meant API Wrapper
?
(if I ain't talking about the wrong one)
is it? why is that a normal method working with cache then
how to use this with role_name ?@slate swan
No need
get the role using role name then use the role and get id but at this point u should just use the normal method
don't spam ping, you would first have to use utils.get to get that role object, then use role.id to get its id and use the same method
but
It didn’t dm a user it should
you can just user.send too
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
I did use await member.send(. . .
how to find role id by role name
did u fetch or get the member object
???????
https://some-random-api.ml/
@slate swan this is the API u talking about?
fr, these really are the most useful, I once almost got muted by Danny for showing an example for the http method to send a message
read the previous convo up we told u how to
yes.
i am very newibe to dsicord.py can you send me code exaple pls?
@shrewd apex
http method is not there in docs i didn't find it?
https://github.com/Rapptz/discord.py/blob/7857a845989e421d591c7d231b756433342d00a8/discord/guild.py#L1030 totally not what dpy is using, they just used some logic and utils.find
discord/guild.py line 1030
def get_member_named(self, name: str, /) -> Optional[Member]:```
hello, do you know how to start a python script from a command ?
its not documented
where do I find http methods?
not documented.
wtf
than how did u know 
I know that, I was just saying so. Prolly Danny added it since there's every get for every fetch method
yeah maybe
discord.Member.display_avatar not working
@commands.Cog.listener('on_member_remove')
@commands.guild_only()
async def fm(member):
await member.ban(reason="User Left While Freeloader Mode Was On.")
await member.send(f"`Whoops you left {member.guild.name} while they had freeloader mode enabled, now you've been banned permanently. You can appeal this ban in BA server.")
``` full code ^
digging into the source code is always a noice idea
First send then ban @slate swan
@slate swan pls chek yr pv
k
i don't provide help in dms
https://github.com/Rapptz/discord.py/blob/master/discord/http.py
client.http.do_thing
client.http.add_reaction(channel_id, message_id, emoji)
client.http.remove_reaction(channel_id, message_id, emoji, member_id)
client.http.remove_own_reaction(channel_id, message_id, emoji)
client.http.get_reaction_users(channel_id, message_id, emoji, limit, after=None):
client.http.clear_reactions(channel_id, message_id)
client.http.pin_message(channel_id, message_id)
client.http.unpin_message(channel_id, message_id)
client.http.edit_message(channel_id, message_id, **fields) #fields can include content, etc. Embeds must be to_dict'd
client.http.delete_message(channel_id, message_id, *, reason=None)
thx a lot
And yea, Danny hates it when someone uses the Raw API methods
Can you send me code example of get role id by role name
wait wtf....how did you even use that emoji
yeah he kinda got mad
||forget it, use hikari
https://www.hikari-py.dev/hikari/impl/rest.html||
ikrrr, I dont use dpy anyways, it too shitty
thats a global emoji, the ones which existed 3-4 years ago
He thinks that using Raw API methods isn't "neat" or smth and that instance methods adds to readability
Heard about them, never got them to work tho lmao
BTW Ash, join the API's official server, there's a wrappers channel, which has a few Python wrapper for the API
well they do work, you just join those servers
and to send a message
from discord import http
#considering this is a command uwu
params = http.handle_message_parameters(content="uwu")
await bot.http.send_message(channel_id, params=params)
Requires a mutual server with the user?
is there anything bad using them?
Yes
No, just Danny hates it
❤️
role = discord.utils.get(guild.roles, name="name")
id = role.id
weird
Why tf everyone here has an Anime pfp except me
what would I even want with those wrappers...
you're weird.
cause you are using javathon
hi
U asked to make an API wrapper
ur pfp cool too👍
Hiiii
how to get it from another server that command used in?
uhhhhh no
guild there would be the other guild's instance
imagine having a discord server for discord api
\role or just get all the roles using guild.roles fetch the guild object here
More of, I prefer watching real life series than cartoon series
ok boomer
can you send me code example?
👀
wait no, I just realized what I said, I'm going insane
Lmao
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 1042, in on_connect
await self.sync_commands()
File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 644, in sync_commands
registered_guild_commands[guild_id] = await self.register_commands(
File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 473, in register_commands
prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id)
File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 353, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
``` what does this error mean
U don't have application_commands scope
what do I do now?
Imagine talking in okimii's lang
confirm
can you send me Code example?
They just tryna check if u r sleepy or not
thx
If u fail the captcha, then get some sleep and then come back
whauuhhh
also, this works
guild = bot.get_guild(id)
for role in guild.roles:
print(role)
I just had to mark that I'm a human, no captcha
why.
pls appead get role id with role name to code
pls
Then?
( member for guild in bot.cache.get_guilds_view().values() for member in guild.get_members())
is what i can imagine
yeah, seems correct
thats an actual cache
@shrewd apex
unlike discord.py just returning the guild objects
nop = await self.bot.wait_for('message', check=check,timeout=5)
How can we convert the 'message' into integer?
int(nop.content)
thats a CacheMappingView, of a snowflake to an object
.content also?
Uhhh?
int(nop.content)
nop is a discord.Message instance
Ok
first add a check to see if its a digit
to the same check add
and msg.isdigit()
then
int(nop.content)
Or that
definately not what something dpy uses
CacheMappingViews are Mapping / dict with snowflakes as keys and the related object as values
in hikari ofc
for role in guild.roles:
if role.name == "nme":
rid = role.id
break
@shrewd apex
correct?
Holy command worked but have a weird output
message.content for only the content
for role in guild.roles:
if role.name == "nme":
rid = role.id
break
@shrewd apex
correct?
yeah
That just for content after that a last i did ctx.send(list)
if rid := [role.id for role in guild.roles if role.name == "nme"]:
rid = rid[0]
ease
what shit is this :/
one liner :D
Ye
and faster than a for loop
no there is one extra letter to type
:=
One liners are good for space but hard to read
uh?
efficient
speed is roughly the same tho only gets it completed in a line
Guys i did ctx.send(cars) cause i want to send list but my bot send a weird thing
Can anyone help me?
u are appending message objects in a list
r_id = map(lambda r: r.name== "name", Guild.roles)[0].id
bye.
whats chache? what is stored in it?
So
You told bye 2 times lol
u can't index a map
I dont know what am I doin}
Ok sleep 😴
my bad it needs to be converted in a list first
Hmmm
So it's smth like:
{id_of_the_member: {other attrs}}
right?
Can anyone help me?
cache is um, the CacheImpl class which is Saving all the objects in the cache? isnt it obvious
My bad
:()
it's not always faster only marginally in case it's faster in some cases it might be slower too
(:)
{ id : hikari.Member}
right
both have pros and cons
Oh
Guys ca anyone tell why my bot sending a weird output?
because its a list of message objects as told by Asher
So?
...?
And hikari.Member is the same as discord.Member, except for the methods?
I want to send list?
your wish?
So how to send list?
you are sending the list?
My bot not sending list iys sending a weird
so like recent interactions, command invokes, stuff like that?
Ye
a list of message objects
But
ok i gtg cya
@commands.command()
async def pie(self ,ctx):
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
initial = 1
cars = []
await ctx.send("enter number of labels")
nop = await self.bot.wait_for('message', check=check,timeout=5)
nov = int(nop.content)
while initial<=nov:
await ctx.send("enter the value of pie chart to append")
apens = await self.bot.wait_for('message', check=check,timeout=5)
cars.append(apens)
initial = int(initial+1)
await ctx.send(cars)
Here is my command
bai bai, take care
@robust fulcrum do await ctx.send("\n".join(x.content for x in [list_of_mesages]))
very different for most of the part
name is username, nick is nickname and more explicit namings
the only object you find similar in hikari and dpy is the Embed object
^
Oh, cool
I don't really code bots so I don't really care what lib is better lmao
thats an Library internal
even the Guild object matches up to a certain point, but not really much
just sleep instead 😔
Ngl I like Hikari's impl to use IDs directly
uhhh
Gotta complete a web app, but been procrastinating on the UI since I don't have any idea on wat the UI should look like
Oh Pokemon Ash?
you would like their cache settings more, you can choose what and how much data to cache
O
@robust fulcrum
jesus
ah ic
Stop this before I do the ot command
off topic
what's the ot command
hikari docs are kinda nice
ohh
ty
only when you are able to find what you need lmao
indeed
!ot
search button
*the busted search button
what does that command do?
does work for me
since its hosted on GitHub pages, its normal for it to not work sometimes
Ngl bot making is fun only when u r new to it. Once u learn the lib, u start to realize that bot making is boring
type !ot in the #bot-commands
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
i said bot commands
yessir
u had one job
It's an indicator that the current convo isn't according to the topic of the channel and that it should be taken to an OT channel
I hate github co-pilot with all my hate now
Never used it
same happend with me👀
I prefer coding myself, rather than some AI coding for me
oh
I experienced it last year
same, I sometimes dont even know why I got instellisense installed
uninstall it
How can I do like
if hi is between some letters like:
123412hi1492
The bot would still respond
Rather than if message.content.startswith
Intellisense != Co Pilot...
if "hi" in message.content
I know, sir
and you can use words
am not a computer
keeps responding to "high" "while" and more stuff
I prefer using coding symbols rather than words with people who understand those
They said so
Ikik
lazy
you dont see 'em so idc
And for if message author id == 1 2 3 ?
(ฅ`・ω・´)っ=
What did u ping me with and then deleted?
if message.author.id == 1234567890:
...
I did see the edit
me too
Oof so many errors
Hunter Hunter
Hunter x hunter
x.content for x in cars
why [cars]?????
Not [cars]
What
I prefer my current VSC theme
_-_
boomer
That does look like a good theme tho
ic, u also started copying okimii
what is that?
no?
Lemme see if I can get the name
okie
That's what he likes to say to me lmao
will never use it from today
Smh vscode.dev not working on mobile
Nice theme ngl
its ew
But tbh, these designer themes start to become boring after a few days
indeed
@jaunty venture gonna tell you once I get on my laptop
okok np
dark dimmed? I only see monokai dimmed tbh
Never tried it. Tbh I hardly change themes
weird theme I love the default one
I hate all vsc themes
IDLE exists
I can sense someone coming to tell to go to #editors-ides
And it also has Dark Mode!
oh god
Stating the facts
(:
Now i can make a pie chart command!
I thought it would be hard task
Yep
Be sure to use run_in_executor!
Where?
Ash just realized she said the opposite
Oh cool
I dont even know if that was the opposite...of what I wanted to say, I just deleted it
U wanted to say "Boomer smile, smile being on the right side instead of left" but said the opposite
Idk
btw how to get ctx author text channel id?
ctx.message.author.channel.id?
ctx.guild.channel.id?
ctx.channel.id?
ctx.message.channel.id?
or what?
try ctx.channel.id

…
....
ayu all the way fam
fira code too
I made my own ayu then lost it cuz I didn't backup
Nice theme
@commands.command()
async def pie(self ,ctx):
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
initial = 1
cars = []
await ctx.send("enter number of labels")
nop = await self.bot.wait_for('message', check=check,timeout=5)
nov = int(nop.content)
while initial<=nov:
await ctx.send("enter the value of pie chart to append")
apens = await self.bot.wait_for('message', check=check,timeout=5)
cars.append(apens)
initial = int(initial+1)
initials = 1
data = []
await ctx.send("enter number of data")
nops = await self.bot.wait_for('message', check=check,timeout=5)
novs = int(nops.content)
while initials<=novs:
await ctx.send("enter the values of labels according to order!")
apenss = await self.bot.wait_for('message', check=check,timeout=5)
data.append(apenss)
initials = int(initials+1)
await ctx.send("\n".join(x.content for x in cars))
await ctx.send("\n".join(x.content for x in data))
Guys this is my code and i am getting error can anyone help me?
It took u more than 5 seconds to respond
Well
?
The error says otherwise. Prolly the message didn't pass the check function?
Hmm maybe my internet connection slow
@maiden fable is there any error handler for it?
try except
before the wait for
#discord-bots message (here's the example)
it works like this:
try:
nop = await self.bot.wait_for
except asyncio.TimeoutError:
return await ctx.send("Whoops, u took ages to answer")
K
!e
my_num = 2
my_string = "a"
try:
var = my_num+my_string
except TypeError as e:
print(e)
always get ignored
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
unsupported operand type(s) for +: 'int' and 'str'
Hmm i should work on pie chart now
Its okay, I also get ignored many times lol
nobody ignores you, Hunter, everybody loves you ❤️
Guys how can I assign ```py
await ctx.send("\n".join(p.content for p in data))
you just assign like you do for a normal variable
Hmm do i have to put paranthesis
nope
K
parantheses here will give a generator object?
u have to use [] for list
str.join should be fine with a generator
Guys is there any package to make discord.py fast?
Why do you think it's slow?
IS IT slow?
Sometimes
pip install discord.py[speed]
How to edit a message
rewrite the source code
I sent an embed with msg variable and then used await msg.edit(. . .
Says ’Message’ object has no attribute ‘edit_message’
You're using .edit_message(), not edit() as shown in the error
too smart
How will that effect the speed?
i think they can use uvloop
what's that
not sure if discord.py has something similar inbuilt
if he codes better than Danny, by good programming
oh lol u mean whole discord.py
most of the hosts use linux, and not windows, better for production.
bruh I said source code
Bruh
🤦
if os.name != "nt":
import uvloop
uvloop.install()``` you can simply check if the os is not windows and install it
Imagine self host on windows
read the message i just sent
why isn't it for windows too
Maybe there dev uses mac
so what
that was a joke
goodn't one
hello, do you know how to start a python script/and close it from another script? tks
Mind telling me what u wanna do?
totally not expecting a bot from another bot
I think they dk about relative imports
import discord
from discord.ext import commands
from matplotlib import pyplot as plt
import numpy as np
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
class pie(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def pie(self ,ctx):
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
initial = 1
cars = []
await ctx.send("enter number of labels")
nop = await self.bot.wait_for('message', check=check,timeout=5)
nov = int(nop.content)
while initial<=nov:
await ctx.send("enter the value of pie chart to append")
apens = await self.bot.wait_for('message', check=check,timeout=5)
cars.append(apens)
initial = int(initial+1)
initials = 1
data = []
await ctx.send("enter number of data")
nops = await self.bot.wait_for('message', check=check,timeout=5)
novs = int(nops.content)
while initials<=novs:
await ctx.send("enter the values of labels according to order!")
apenss = await self.bot.wait_for('message', check=check,timeout=5)
data.append(apenss)
initials = int(initials+1)
fig = plt.figure(figsize =(10, 7))
plt.pie(data, labels = cars)
plt.savefig("chart.png")
await ctx.send(file=discord.File("chart.png"))
async def setup(bot):
await bot.add_cog(pie(bot))
Guys how to fix this error
float(message.content)
shards :thumbsdown_tone5:
copy script, change token part, start from bot :thumbsup_tone5:
Wait
Ok
Mind scrolling the traceback up?
Sent
repit 💀
froggy meh
?
Pepe*
Lol
Again a timeout error
I know. he's my inspirator
Lmao
Oof
fix the errors.
you have to do
.content while converting to float
you cant pass in the whole Message object
Done that was a timeout error
?
code
And can you help me with a variable
How can I put the list in a varibable which I get from input?
dont use replit for discord bots
await ctx.send("\n".join(p.content for p in data))
How can I assign it a variable
Why
they use shared ips
Ik but me on Android
which can cause bots to get ratelimited for no reason
that doesnt matter
I have no other option
u want to assign ctx.send?
uwu_string_that_that_could_have_been_possible_if_you_knew_basic_python = \n".join(p.content for p in data)
Ok
"
Ye
Nice variable name
making discord bots is not a beginner friendly project
Try try but never cry!
I still made a good one
How can i remove new line one thing from it
?
""
thanks
Ok
if u like shooting urself in the foot, then go for it :)
my first bot I also thought was good
one year later I wanted to rewrite it but didn't even bother cuz it sucked
just use js instead.
@slate swan ```py
cars = (p.content for p in cars)
data = (c.content for c in data)
It's says a generator error
Here is my initializing:
class BasicCommands(commands.Cog):
def __int__(self, client):
self.client: commands.InteractionBot = client
And I am having an error BasicCommands have no object client in this area:
embed = disnake.Embed(title='SLOGAN', description='Give a slogan for your company.', color=disnake.Color.gold())
embed.set_footer(text='You have 60 seconds to answer.')
emsg: disnake.Message = await inter.send(embed=embed)
try:
slogan: disnake.Message = await self.client.wait_for(event='on_message', check=lambda msg: msg.author == inter.author and msg.channel == inter.channel, timeout=60.0)
except asyncio.TimeoutError:
embed.set_footer(text='Question Expired.')
await emsg.edit(embed=embed)
return
Pls help I have no idea I never got this error before.
I am having the error in wait for section.
an iterable comprehension in parenthese like that creates a generator object, whereas one wrapped in square brackes produces a list of values @robust fulcrum
Possible to respond to a button interaction inside a command?
you likely want [p.content for p ...] rather than (p.content for p ...)
Its saying basiccommands object have no attribute client
Pls help me ;-;
@vocal plover
I don't normally ping random people but I am in hurry and I want to fix this
Can you pls help
you misspelled __init__ as __int__
lmao
Oh nvm
__int__ converts the object to an int
@vocal plover thank you so much
when int(object) is called
But how can I do such a stupid typo
thats a cruel error tbf, since the function just never gets called and you get an unrelated error
I am like the worst programmer error.
Tbh it's the same as Python but with some minute differences (acc to me), like braces instead of indent and some function name case difference
we've all been there lol, that one dumb error where you just are dumbfounded by how you did it
And even python dont tell me that I did a typo.
I never had any difficulty picking up JS after doing Python
Your code was logically wrong but not syntactically wrong
as i say, horrible error to debug
fun fact, i spent two and a half hours wondering wtf my code wasn't working, turns out i entered port=456 instead of port=465
typos are the worst errors
I had to read that 3 times to see the difference lmao
Aa... so okay it worked but it still doesn't do what I want
Its not saving data to companies.json
but ima check for more typos first
How to fix this?
I recently had an error where I was comparing datetime objects and something was executing multiple times when it wasn't meant to, it turns out my CPU frequency was too high for the precision of a datetime object, so the comparison returned true multiple times, that was absolutely miserable to debug
god
If I wasn't aware of that type of error I don't think I'd ever have solved it tbh
It's so obscure
Pls anyone help
c is an integer
in the list comp
Cars?
bro why would i be talking about cars
No
Its name of list
import discord
from discord.ext import commands
from matplotlib import pyplot as plt
import numpy as np
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
class pie(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def pie(self ,ctx):
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
initial = 1
cars = []
await ctx.send("enter number of labels")
nop = await self.bot.wait_for('message', check=check,timeout=20)
nov = int(nop.content)
while initial<=nov:
await ctx.send("enter the value of pie chart to append")
apens = await self.bot.wait_for('message', check=check,timeout=20)
cars.append(apens)
initial = int(initial+1)
initials = 1
data = []
await ctx.send("enter number of data")
nops = await self.bot.wait_for('message', check=check,timeout=20)
novs = int(nops.content)
while initials<=novs:
await ctx.send("enter the values of labels according to order!")
apenss = await self.bot.wait_for('message', check=check,timeout=20)
apenss = int(apenss.content)
data.append(apenss)
initials = int(initials+1)
cars = [p.content for p in cars]
data = [c.content for c in data]
fig = plt.figure(figsize =(10, 7))
plt.pie(data, labels = cars)
plt.savefig("chart.png")
await ctx.send(file=discord.File("chart.png"))
async def setup(bot):
await bot.add_cog(pie(bot))
do print(data) before the list comp
apenss = int(apenss.content) data.append(apenss)
My command still doesn't work, I am sorry if I did some stupid typos again.
@ commands.slash_command(name='startup', description='Creates a company, you can only have one company at a time.', dm_permission=False)
async def startup_cmd(self, inter: disnake.AppCommandInter, company_name: str):
with open('Database\\companies.json', 'r') as f:
companies: dict = json.load(f)
if company_name.upper() in companies:
await inter.send('Sorry for this, but another company already exists with that name. So please choose a different name for your company.', ephemeral=True)
return
elif any(inter.author.name == nms['OWNER'] for nms in companies.values()):
await inter.send('You already have a company. If you want to close your company.', ephemeral=True)
return
else:
embed = disnake.Embed(title='SLOGAN', description='Give a slogan for your company.', color=disnake.Color.gold())
embed.set_footer(text='You have 60 seconds to answer.')
emsg: disnake.Message = await inter.send(embed=embed)
try:
slogan: disnake.Message = await self.client.wait_for('on_message', check=lambda msg: msg.author == inter.author and msg.channel == inter.channel, timeout=60.0)
except asyncio.TimeoutError:
embed.set_footer(text='Question Expired.')
await emsg.edit(embed=embed)
return
companies[company_name.upper()] = {'SLOGAN': slogan, 'OWNER': inter.author.name}
with open('Database\\companies.json', 'w') as f:
json.dump(companies, f, indent=4)
you are adding integers to data
@robust fulcrum try to remove the data = [c.content for c in data] list comp
well, what errors are raised?
what is the desired output
show the line where is does that
But it doesn't
companies[company_name.upper()] = {'SLOGAN': slogan, 'OWNER': inter.author.name}
with open('Database\\companies.json', 'w') as f:
json.dump(companies, f, indent=4)
!d json.dump
json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)```
Serialize *obj* as a JSON formatted stream to *fp* (a `.write()`-supporting [file-like object](https://docs.python.org/3/glossary.html#term-file-like-object)) using this [conversion table](https://docs.python.org/3/library/json.html#py-to-json-table).
If *skipkeys* is true (default: `False`), then dict keys that are not of a basic type ([`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`int`](https://docs.python.org/3/library/functions.html#int "int"), [`float`](https://docs.python.org/3/library/functions.html#float "float"), [`bool`](https://docs.python.org/3/library/functions.html#bool "bool"), `None`) will be skipped instead of raising a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError").
The [`json`](https://docs.python.org/3/library/json.html#module-json "json: Encode and decode the JSON format.") module always produces [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") objects, not [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. Therefore, `fp.write()` must support [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") input.
If *ensure\_ascii* is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If *ensure\_ascii* is false, these characters will be output as-is.
ash gonna take it from here i gotta be in this call
the path is correct?
I'm going to sleep too.
async def main():
async with bot:
#await bot.load_extension('commando.')
await bot.load_extension('commando.area') #done
await bot.load_extension('commando.boss')
await bot.load_extension('commando.cooldown') #done
await bot.load_extension('commando.craft') #done
await bot.load_extension('commando.daily')
await bot.load_extension('commando.eat') #done
await bot.load_extension('commando.help') #done
await bot.load_extension('commando.hunt') #done
await bot.load_extension('commando.mine') #done
await bot.load_extension('commando.open')
await bot.load_extension('commando.profile') #done
await bot.load_extension('commando.ready') #done
await bot.load_extension('commando.reload') #done
await bot.load_extension('commando.short') #done
await bot.load_extension('commando.start')
await bot.start(os.getenv('TOKEN'))
asyncio.run(main())
@slate swan how can I put a list in variable like you told first but that not worked
why doing it manually?
its 1128pm here
i wanna do checkflist
4:29pm for me
Hmm my mind is going to balst today because if pie chart comamnd
Hard to make
I havwnt slept for 2 days and a half, so bye fr now
gg
go get some sleep =.=
How can I get the id of the message sent by the bot when the command is used?
ids = list()
@bot.event
async def on_message(message: discord.message):
if message.author.id = bot.user.id:
ids.append(message.id)```
help
https://media.discordapp.net/attachments/971701505948282890/981217653077213294/chart.png
Guys my bot is sending me wrong response it's sending me message info but it should send the labels
Can anyone help me pls!
Do message.content instead of message wherever u r passing the msg object
Ah, instead of cars, do [x.content for x in cars]

consider this setup https://github.com/Tvrsier/BaseBot
Base bot setup for discord.py and relative forks. Contribute to Tvrsier/BaseBot development by creating an account on GitHub.
If the user uses ,rm 1hr
And await asyncio.sleep(.) takes seconds
How can I make it so that if user uses 1hr it sleeps for 1hr and do stuff
Same for day and seconds?
uhm you know time is constant...
1 minute is 60 seconds, 1 hour is 60 minutes, 1 day is 24 hours, 1 week is 7 days, and so goes on...
In simple words
This commands function is to dm the user after the time the user told
You'll have to do a little bit of parsing
To convert different times to seconds
hint: check the last letter for the unit (m for minutes, h for hours, d for days)
you can use a loop
Yo @sick birch u ever used the RPC API?
discord RPC is in (indefinite) closed beta access
I know, but a few modules (like pypresence in Python) are using named pipes to set custom presence (the same API as RPC just not using the ws)
Well I was tryna figure out if the large_image key supports GIFs
For some reason it shows blank space like this one:
!e
def timeConverter(time: str) ->int:
MULTIPLIER = {'m': 60, 'h': 60*60, 'd': 24*60*60}
unit, time_unit = time[:-1], time[-1]
return unit*MULTIPLIER[time_unit]
print(timeConverter("3m"))
it doesnt
duh
lmao
Thought so, but a person in the pypresence server is like: You can use a bd plugin to show animated RPC
And the bd plugin also seems to use the same named pipes as pypresence
istg if anyone here says that bd is against ToS cz ik it is
Hunter tell me if i'm stupid or what
Uh bro
for the unit, don't u think u should do time[-1]
import os
async def main():
async with bot:
(await bot.load_extension(f"commando.{file[:-3]}") for file in os.listdir("commando/") if file.endswith(".py"))
await bot.start(os.getenv('TOKEN'))
!e
time = "60m"
print(time[:-1])
print(time[-1])
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
001 | 60
002 | m
See lol
!e
def timeConverter(time: str) ->int:
MULTIPLIER = {'m': 60, 'h': 60*60, 'd': 24*60*60}
unit, time_unit = time[:-1], time[-1]
return int(unit)*MULTIPLIER[time_unit]
print(timeConverter("3m"))
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
180
HAHAHA
I'M STUPID
That was an easy fix...
yeah too much days spent on javascript...
Lmao
I've to do it cuz my tutor is making a project for a website and he ask me to help sometimes
(I had to modify a part of a library too i was like "please someone kill me")
Haha the code I am reading is worse but won't share it here since its an innocent bd plugin
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.

I am waiting for the time when the channel name changes to #discord-api to also include help regarding the Discord RPC API and stuff
you could ask in the discord dev server?
Lmao after that he just ghosts me
no comments, maybe you're just having a bay day 😔
You will not know what a bad day is until you play ranked on LoL 
lmao
we already talked about today, so its equivalent
That is why I don't like to grind games since I already have enough on my plate to stress about
Uh, we don't talk about that, that hardly happens but its the worst when that happens
lmao my luck is damn bad i grind to a certain rank or trophies and i am like last game and then i will leave after that i get wrecked for 10 games in a row
@unkempt canyon handles our stuff pretty well. What do you mean exactly by
i want the most secure server protection?
It all depends on your internet connection tbh. JS and Python hardly have any performance differences, if not the same speed, in discord bots
how to get embed in your message like that
>
>
Can I make a bot that logins with my main account and joins a server with invite code
Nope. That is self botting and you will have your account completely annihilated
using userid and giving ur bot acc or botting ur user acc is breach of discord tos
I'm only using it for a fake account, what do you mean by annihilated
Deleted User#0102736674903028865293
.wa short annihilated
destroyed completely
That is what I mean
how do i get user input in a discord bot
You mean immediatly ?
a bit of delay ig
Like commands?
I would recommend looking into the discord.ext.Commands extension if that’s the case as that gives you a lot of utilities to work with.
Congratulations'
you just set the link and it will get displayed?
Yea the same link u use in embeds
mhm nice
Oh fr?
Haha yea
Rookie question here: Does non asyncio database jam the discord bot? (when making queries)
Yes it can
yea but its soo minute that no one cares
jiffy
Yea that
it shouldnt be used tho as it can still block your bot making it miss a hb making the connection zombified
agreed
and it can make your bot respond slower in some cases
Is there any other way to customise a public bot's picture and image
await edit(*, username=..., avatar=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the current profile of the client.
Note
To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.10)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.10)") is given through the use of `fp.read()`.
The only image formats supported for uploading is JPEG and PNG.
Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned...
idk what to do at this point ._.
quit making discord bots download music from spotify
na its funny 😄
it's also breaking the terms of service of spotify
How to implement slash commands
U didn’t show your code. But by reading the error i can see that u forgot to out ”await” before ”HTTPClient.get”
Hey anyone know how to ping a ip address bc im trying to make it a cmd for my bot (:
Idk a cool cmd ig (:
Not tryna have some skid bot lmao
damn that sucks
guess it can be come harmful ?
Yeah.
Yeah but you can ping a ip to the point theres 5 ms
?
I just thought it would be a cool cmd but thanks for the help.
Pinging an IP repeatedly doesn't change the latency
Are you checking for latency or uptime or something like that? What are you trying to do exactly
Yes please, more info would be helpful
not uptime. What's it called
Just to check the latency
if the server is down or not


