#discord-bots
1 messages ยท Page 53 of 1
๐
whats it not bad for then?
@slate swan ๐
for using a bad editor
the only issue is the python version, which can be configured too
Btw do you know any good way for making help comand?
yes
!custom-help
Custom help commands in discord.py
To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

Finally i made my first python package
Check my github
would be a module
and where is a package
What?
perspective_api_wrapper?
Ye
burh ok
good morning mr master32
morning
one can't install it.. + no requirements setup
you need to create a setup.py for it to be installable
Python Create offers generators and instructions on using Python optimally. Get help writing your code with the tools we offer.
I used poetry ;-;
And i tested my module by downloading
well whatever
noone downloads a module to use it, pip installing is the preferred way
and poetry wraps pip
means my module is not downloadable using pip?
Guys how can I make a button that purges messages on click?
try it and see, can you import it after installing
I'm participating in PyWeek with Asher and... I don't know almost anything about working in team... I only worked with complete noobs those didnt do anything when was in programming school, we didn't even get familiar with branches...
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Changed in version 2.0: The `reason` keyword-only parameter was added.
Examples
Deleting botโs messages...
Btw i installed the module using pip on replit
So means it works?
Will it be
interaction.channel.purge()?
how did you install it
Yes
pip install [my package name]
did you upload the package to pypi?
how do i make this work?
!d discord.Role.members
property members```
Returns all the members with this role.
can u explain it to me in a psuedocode?
role # is a discord.Role
list_of_members = role.members
Yep
I did poetry publish to upload
whats the name?
perspective_api_wrapper_python
long name cuz the other names were already used
!pypi perspective_api_wrapper_python
How to send message on button click?
Ah i did a api
It should be an api
don't really need to use such a long namespace lol
could have used py-perspective or something
Should I change now?
you can if you wish to
But long for me
I need to change on GitHub too
Lazy ๐ฆฅ
How can I send message message on button click in dpy V2?
๐ฟi haven't published my library yet cause its its nothing close to complete
Which?
interaction.channel.send
discord api wrapper
๐
U overwrite callback method
Ok
And i how can I delete the button message when i click btn?
There is a million of them and 3 are boing used
!d discord.Interaction.message
The message that sent this interaction.
!d discord.Interaction.delete_original_response ?
await delete_original_response()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the original interaction response message.
This is a lower level interface to [`InteractionMessage.delete()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.delete "discord.InteractionMessage.delete") in case you do not want to fetch the message and save an HTTP request.
What is hikari
anime a discord api wrapper
*thousands
95% of which are forks
Oh god
nextcord isnt planning to stay as a fork either, they are doing a complete rewrite
Yea, I mean Itโ s a nice project for urself so good luck
yea, ty
Is urs a fork?
no
nope, im making it from scratch
Thats dope
Is it open source?
Why does this happen?
(sending command) part
After a few seconds, it says application failed to respond. But it responds appropriately
code?
@commands.slash_command(name="8ball", description="Answers random questions")
async def ping(self, inter, question):
responses = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.",
"Donโt count on it.", "It is certain.", "It is decidedly so.", "Most likely.", "My reply is no.", "My sources say no.",
"Outlook not so good.", "Outlook good.", "Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.",
"Yes.", "Yes โ definitely.", "You may rely on it."]
embed = disnake.Embed(title="", description="", colour = disnake.Colour.random())
embed.add_field(name=f" Question: *{question}*",
value=f" Answer: *{random.choice(responses)}*")
await inter.channel.send(embed=embed)
Ahh, wait..
8ball async def ping
https://github.com/sarthhh/asuka
yes but I haven't pushed any changes from a week, ill push it all at once when the models are ready
my bad
Well, I'm starting out so I'm not very familiar with how things work just yet. I'll try that
@worn onyx you need to use await: await client.load_extension
where to put?
Replace client.load_extension('jishaku') with await client.load_extension('jishaku')
Basically just add await
https://cdn.discordapp.com/attachments/381965515721146390/1011938925566238780/unknown.png
https://cdn.discordapp.com/attachments/381965515721146390/1011938925885001778/unknown.png
https://cdn.discordapp.com/attachments/381965515721146390/1011938926216359997/unknown.png
everything is fine , why emojis cant able to load ??????????????????????????????????
bug ๐ฎ
Haha LUC, that's weird
wot ?
I saw it in the dpy server too, lemme try to find a solution
oh lol , ok ok hehe
installed jsk but still showing jsk command not found how to solve?
I've been on 10 different sites and haven't found a thing so far
@commands.slash_command(name="purge", description="Purges 'X' amount of messages in a Text Channel")
@commands.has_any_role("Shuma")
async def purge(self, inter, purge: int):
try:
await inter.channel.purge(limit=1 + purge)
await inter.send(f"{purge} messages, succesfully purged!", delete_after=5)
except:
await inter.send(f"Failed to delete {purge} messages. You are not eligible to use this command!")
I want to make the bot send a custom response when the sender doesn't have the "specified" role cited in the @commands.has_any_role() decorator. How do I do that?
I tried using error handlers but it just sent interaction failed when I tried it on one of my test servers without the "Shuma" role.
Do I have to use if/elif statements for that? If it's overly complicated, I'd probably just hold it off
If it's not that hard to do, pls tell me what to do. I'm still starting out.
@rocky trench
What is jsk? I never told you to install that
you need to use the slash command error handler
what library do you use?
Disnake
gimme a moment ill look up for the event in docs
Sure. Thx
jsk/jishaku is a debugging extension for Discord.py
!pip jishaku
Alright
@worn onyx it's impossible for me to tell you what is causing the issue at the moment, I haven't seen the code for the command
!d disnake.ext.commands.Bot.on_slash_command_error
await on_slash_command_error(interaction, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The default slash command error handler provided by the bot.
By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.10)") however it could be overridden to have a different implementation.
This only fires if you do not specify any listeners for slash command error.
you need to use this event
ALr. Gotchu! Thanks for the help
A discord.py extension including useful tools for bot development and debugging.
did you load the jishaku extension?
await bot.load_extension("jishaku")
Slowwwwwww
how to degrade discordpy?
just do pip install discord.py
pip install discord.py==1.7.3 I don't remember "exact version" operator, might be single =
it's == but just doing pip install installs the latest version
are u taking part in pyweek๐
@shrewd apex u know how to make nsfw cmds?
lol
but question is why would I go to discord for NSFW 
i have to make in my bot could u plz tell me?
i don't think this even the right channel we need like a NSFW channel ig but u can use some NSFW lib or api wrapper or the api it's self i think ||nhentai has one||
i hope i don't get warned or something ๐
Why do you know about this asher

.
ryuga zeffo are u two taking part in pyweek ๐
Maybe I would if I were at home
oh ic 
probably not
๐ฃ
oooh pyweek
yep
Might be a good time to have motivation to do coding again

But no clue how to make a game
well it's making a game so it's gonna be interesting
Yeah never joined pyweek before
i never did either
this is gonna be like my second try at making a game with python first was codejam
You made a game for the codejam?
yep we made a chess game
What library did you guys use
Oh heck if it's a game jam I'm definitely not participating
๐
Does this decorator work with slash commands?
@commands.has_guild_permissions(ban_members=True)
I think it doesn't
Yes
or do i need to use app_commands
Well try it ig
oh yeah it didn't work for me but maybe I was doing something wrong
(I was)

how to put this in timestamp
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
Does someone know when i'm running this script, it is written the name of my guild but 2 times like :
guild
guild
```for guild in self.bot.guilds:
print(guild)```
how to send avatar people who join?
@bot.event
async def on_member_join(member):
channel = bot.get_channel(1007988538312241173)
embed = disnake.Embed(title="NOWY UลปYTKOWNIK", description=f"Witamy {member.mention} na serwerze **{channel.guild.name}**", colour=0xF0C43F)```
member.display_avatar.url @slate swan
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.
are there any examples in these dossiers at all?
wdym?
dossiers? who is that?
documentation
there are enough examples there. If you understand how they work everything else is pretty easy to understand
where are examples?
i didnt see
Guys if i disable a button . Is it possible to enable it?
yes
button.disabled = True disables it
button.disabled = False enables it
@silk fulcrum can u code it?
code what?
avatar in embed
Like i want that when i click the button it disables the last button and does not disable all buttons
How can I do it?
Just do
ctx.author.display_avatar()
so can u send me HELPFUL link beacude i don't see any help in this documentation zero examples
do .disabled = True for only the last button?
Oh the it will be member.
and also .display_avatar.url
Button function name?
Like my button function name is lastbtn
so it will be
lastbtn.disabled = True?
hi navi mann
where is ashley
here is embed generator if you need for something https://cog-creators.github.io/discord-embed-sandbox/
if you can't figure out what to do, go learn python
no
if your button is the last element of the view, you can do view.children[-1]
Why are there so many anime pfps and why do they all know each other
no
said by a cat living in ukraine KEKW
Out of pocket
why u looking for her from like 2 days 
you have anything against anime?
alr getting ot better stop
cuz she is gone?
that's me too :(
many PPL are gone sarth oki ashley
No?
some random dude out there :someone help me
await ctx.send('hello world')
```its not working
then what is the problem?
it not in async function
๐คฃ
EXACTLY
send?
I never said there was one?
ooh nice i needed this
lmao why didnt u ask me
i didn't even know it existed
๐ณ
now it saves time for me to run code again and again to check styles
i tried some embed generator before
there are just too long, there is better way of writing the same thing and 10x shorter
anyone know some pikachu???
uhm couldn't you've just searched in google? I found it like that
its like asking people to imagine something new
you cant imagine something you have never saw before lol
idk too lazy as soon as I think i have embed design's to do i lose all motivation
lol
cheeks :lmao:
bruh same but with like almost everything
just gotta split tasks into smaller ones
fantasy
fantasy is still based on something we saw before๐
for a better example
its like imagining new colour
light-orange-purple-green-blue-white-cyan-yellow-black
they are not new ๐
it's like only 256**3 possibilities
how u imagine new
sure
maybe there is some colour we cant see due to our cone cells
completely
topic?
HIIIIIIIIII
braindead
#ot3-discord-bots?
maybe its just a species colourblind and none of us know
I love python!
I love python too!
AHEM
the people here dont like gif and pic unrelated to codes, so....
!ototototototototot
of your gist
or what do u expect
ik
stop:/ like really
People when emoji 
Are you gonna cry because I sent SpongeBob?
spongebob is hot
u are going to cry cuz im calling mod
jkjk but stop plss
Ong
uhm... well... like a dpy2.0 guide to create a bot or to migrate to 2.0 and also how to create bot with cogs and stuff like db, aiohttp sessions etc (like to put it into setup_hook)

Whatโs wrong with using emojis
never gonna give you up, always gonna let you ban yourself
its not wrong with using that
excessive usage is the problem =.=
nice, would have been helpful, bug ok your wish
time to return to the dead
The more you tell me to stop I will keep using them
idk, it looked... ugly
and grammar mistakes as noid said
Okay cya
what? where? why?
๐ฅฒ byebye
why not ask
how? what? where? who? when? why?
what where when
how doesnโt fit
u can make one it would be nice i can chip in too if u want
in russia we have a show called like that
we can even add a smol section how to not use json and make a SQL pool instead
i never made anything like that, I had very small experience with git, and I'm Russian, so that's why grammar is a problem. Of course I don't mind making it, but idk if I could without any knowledge
i made a minecraft plugin, works nice
oh wait who asked...
neither did i tho i have experience with git grammar not a problem for me
cool I'll make one once i get home from gym
but how do u play it
sounds good
idk i only played Minecraft creative mode to battle friendz
i play minecraft always everyday
but not the single player
i tried to beat it... but im too lazy
i am the last person who u would ever want to play video games with except supercell and pokemon
i play single player everyday :D
why?
clash royale?
idk i never played any other games
brawl stars
lol
yes and coc and bw
what is bw brawl stars?
yep
to think that im brawl stars og kekw
but i quit like last year
its getting p2w now
i quit bw 2 years ago
lol i played before 2019
i have star shelly
i have geometry dash, minesweeper and chess :lol:
minesweeper ah yes the classic
Where the discord.py
so.. when are we making the gist @shrewd apex ? If we are
like 1-2 hrs later
I got banned for speaking off topic in #ot0-psvmโs-eternal-disapproval
skill issue
I also got banned for speaking off topic here
believes
Itโs true
ok, waitin'
u can start if u are free rn
I'll start on it in some time u can start with the explanation part and all ig
well not like completely free, but sure I'll start
๐
are we just gonna like make it in 2 our files and combine somehow? or branches if that is even possible? not familiar with team work at all
-1 gives the last element ig and 1 gives first?
yes, -1 gives last element, and counting in programming starts from 0, so first element would be 0
Oops i forgot
i think prs in gist is possible
wait lemme check
Can we add a animated emoji to a button in dpy?
who is prs :blobpain:
why not?
I thought we can't
Have never seen it so doubt it
I never saw
anyone know what this means? I never had this error before and everything used to work fine
Guys why i getting this error?
dont even know as I think I am not even using that
but whenever my bot goes online it spams that in the consolke
Pls help me anyone
shaw your callback
class Help(discord.ui.View):
def __init__(self):
super().__init__(timeout=180)
self.page = 1
@discord.ui.button(label=None,style=discord.ButtonStyle.gray,row=0,emoji=":left:")
async def left(self,interaction:discord.Interaction,button:discord.ui.Button):
if self.page == 1:
btn = self.children[0]
btn.disabled = True
label is None by default but whatever
I just did but idk
Whats the error in it?
I got no error in console
It just does that
It not got
see: you only disable button in the view, but to update it in the message you need to edit it
Ong
Oh
Ooops i forgot
Let me try
so you would need await interaction.edit_original_response(content="page 1", view=self)
!d discord.InteractionResponse.send_message
await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a message.
yes
tysm
Still i getting same error
button gets disabled?
Nop
I got this traceback now
Unknown webhook ๐คฏ
looks like weird error
hey
Start what
thats my job to respond here quickly
I am starved of human interaction sorry
What should I do now?
i know sm basic python and would like to build a bot
Fix it
no idea actually
Learn more python
Should I reach dpy server?
๐คฆโโ๏ธ
Do you know what a class is?
probably.... if you aren't afraid of being slaughtered
its me, mario
i can see u r new here, pls don't play with me
u r new here @slate swan
I got banned a long while ago
Do you think me meat animal?
for them yes no
I am not new to the python discord
I have had multiple accounts and I have been banned a few times
prove :haHAA:
For what reason?
Speaking off topic and also insulting mods (troll)
uhm @slate swan, make sure you know at least half of this list, of course it would be better to know everything that is listed there, but no beginners like learning a lot https://gist.github.com/Ash-02014/426ec7974f705303a2363c739dd82309#requirements-to-start-making-bots-with-python
tysm
They told me this
Let me guess: using followup before responding to an interaction?
that's a no
lemme join ya conversation
I got this reply
Your probably want interaction.response.edit_message
can see that in you
Damn
it would depend what you're parsing
@slate swan hey
Hello misty
can u help me with the code for displaying members with a certain role
good morning friends
its discord.Role.members but how do i proceed with it?
hows it going over here
Good morning dearest pal
gm
You mean enemies
!d discord.Role.members
property members```
Returns all the members with this role.
Im joking good morning robin kek
umm yes i said the same thing, but how do i code it
can u give me a pseudocode
You can probably iterate through it or smth idk
hmm
Idk if it returns a list of member objects or smth
You could probably use filter or a list comp on it
What this guy said ^^
I like filter personally because js user
( ๐คฎ )
@bot.command()
async def role_members(ctx: Context, role: Role) -> None:
await ctx.send("\n".join(role.members))
this is bare minimum i would say
alr thanks
How do I mute pings on servers
Cause I hate getting pings from servers which Iโm only in for the emotes
Because the obviously have to ping everyone all the time
In a Server of over 500k people
right click > mute server
Iโm on mobile
click and hold?
Itโs muted finally
I get happy thinking someone want to talk to me but then itโs just some useless ping
if its for push notifications
Playing with my feelings ๐ฏ
๐ณ
Damn imagine having to contact staff to get your message whitelisted
u pinged the wrong guy lol
oh sorry
Nice.... pseudocode
https://media.discordapp.net/attachments/381965515721146390/1011996299710713936/IMG_20220824_192105.jpg
Guys how can I fix this error?
its bare bones either way its something everyone can do, i just gave him ideas
thats doesnt mean its bad
C# >> c++
Thats called a low level language, a language that doesnt have much abstractions
Why make high level language
hi! i tried to delete messages but i wont wrok
my code:
async def clear(message):
if message.content.startswith('!delete'):
await message.purge()```
message.delete()
๐ญ
ok ill try
If you wanna purge messages there are arguments you need
because some programs use languages like that and they give better concepts when programming e.g segfaults, memory leaks and memory allocation and cant forget about their speed either
Wait what the fuck
what
what did i do?
That is the most abstract way to make a command I have seen in a while
ok
I think you may need to learn discord.py again
message.delete doesnt work
How can I call an asynchronous function indefinitely?
asyncio.run?
Having a low amount of abstractions doesnt mean the language is horrible , its just a more tedious job
How do I implement a custom cooldown depending on what the user does within the command? is that even possible
eg. random example: he clicks a button saying he wants a cooldown of 5mins then the command will be in cooldown in 5
Where did you learn discord.py from
World Wide Web
๐ญ
define "indefinitely"
bruh I literally was typing that I saw that noid was here
what about me๐
the callback what's in the callback if a callback takes more than 3secs u have to defer it
wha
what about me being here?
im thinking of deferring everywhere, cus... everything might happen...
Whats defer?
class Help(discord.ui.View):
def __init__(self):
super().__init__(timeout=180)
self.page = 1
@discord.ui.button(label=None,style=discord.ButtonStyle.gray,row=0,emoji=":left:")
async def left(self,interaction:discord.Interaction,button:discord.ui.Button):
if self.page == 1:
btn = self.children[0]
btn.disabled = True
await interaction.response.edit_message(content="page 1", view=self)
Here is my code
u are pretty genius
kek funniest joke ive seen today
huh, funny joke
i wonder if dpys webhook interaction abstraction can get you limited from the api
Whats meaning of defer?
me?
no just wondering, maybe you can answer that lol
deferring everywhere isn't necessary tho simply more work
deferring makes you able to respond to an interaction not in 3 secs but in 15 mins
imagine waiting 15 mins
Tf it is
It's better that i should close my coding ide and play games
yes close your phone and get on PC
yo i have been using replit but i decided to move on to vsc. I wrote the basics first to see whether it will work or not and it aint working, i watched few yt videos and yeah it aint working ;-;
Hey @cerulean shale! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
bruh
How do I have custom cooldown for different users? e.g a user has a differnet job than another user
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="/")
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Game("Hi senpai!"))
print("I am ready to rock!!!")
@bot.command()
async def ping(ctx):
await ctx.send(f"My current latency is {round(bot.latency * 1000, 1)} ms.")
bot.run("test bot token -_-")
iirc, since discord.py uses webhooks to send messages after responding to an interaction, if you would like to get the webhook many times e.g in a loop, youre vulnerable to getting HTTP 404 codes and in one part of the Discord API documentation, they said something along the lines: "if you try to get a webhook many times, you will get limited from the API".
idk why but it is stopping ;-;
its not bad but uses the worst prefix that causes ui collision /
what discord.py version?
not 2.0
and how can you confirm that?
um, shouldnt we like go to his git and install it from the link?
You can do pip show
Not anymore
py -m pip install -U discord.py
Version 2.0 is now on PyPi
py -m
my point was, what evidence does he have to know that his version isnt 2.0 when it was recently released on pypi
it depends
i didnt know that tbh
How to I make it so the bot deafens it self when it joins the channel
Maybe not because they're using python which might be using Microsoft's alias
py and python are for windows
huh
await guild.me.edit(deaf=True) ?
pip show
The question still isnt pointed at you kek
print(discord.__version__)
^
Lmao Iโ m just messing, ik what u meant
I think you guys are missing my point by a long run, he said "not 2.0" but never provided approval on which method he used.
the code works both on 2.0 and 1.7
py -m pip install -U discord.py i did this btw
pip show
Jkjk
!d discord.Intents.members
Whether guild member related events are enabled.
This corresponds to the following events...
yes
What isnt?
?tag idw
This is not a Modmail thread.
!d discord.Intents.message_content meaning, i was correct, you are using 2.0 and not passing the intent on IDENTIFY aka you never passed the intent into the initializer of your bot
Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:
โข The message was sent by the client
โข The message was sent in direct messages
โข The message mentions the client
This applies to the following events...
.
...
Also, instead of {round(bot.latency * 1000, 1)} do {bot.latency * 1000:.1f}
It's shorter and it does the same thing
U ran the wrong file?
I saw you say "pwease ๐๐" on the dpy server Master32
how you gonna get out of that
and what
Busted
no ;-;
Send code
then he wonders why he got banned kek
did he
ask him
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="?")
@bot.event
async def on_ready():
print("I am ready to rock!!!")
@bot.command()
async def ping(ctx):
await ctx.send(f"My current latency is {bot.latency * 1000:.1f} ms.")
bot.run("token")
i got banned by RDanny for spamming mentions in thread called spam
not for saying pwease
kek
cough cough
ight ight
You must pass an intents object, one with message_content enabled for the command, too
OH
Lmfao wtf
why doesn't it show the error
you think I know? it's just in danny's code
Y is it called spam if u get banned for spamming
i dont remember who's ping was i spamming
(@)Owner ๐
but for some reason i think that was RDanny or my alt
definetly not
thats a channel for spam baits
lol
I see no point
it's not a good server anyway
lots of stuff in life has no point ๐
me
life doesnt have a point lol
well, but there are good helpers
like sgtlaggy for example
I sometimes get helped there and dont get helped here
there is no point/meaning in life as everyone doesnt want the samething they just want the best for themselves giving life a meaning that can only be defined by yourself
without requiring server permissions
oh
self_deafen
OH
property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
uh what's the docs for the bot user
!d discord.ClientUser
class discord.ClientUser```
Represents your Discord user.
x == y Checks if two users are equal.
x != y Checks if two users are not equal.
hash(x) Return the userโs hash.
str(x) Returns the userโs name with discriminator.
in a guild
in a guild, its Guild.me, and it returns a Member object
and editing it's state doesn't require any permissions
YOOOOOOOOOOOO IT WORKS FINALLY AFTER USING INTENTS!!!!
!d discord.Member.edit I'm not sure if this shows self_deafen
await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the memberโs data.
Depending on the parameter passed, this requires different permissions listed below...
I HAD THEM ENABLED BUT DIDNT THINK THEY WERE THAT NECESSARY
kek
youre welcome lol
no need to shout
happiness
wish i were happy, i wake up with severe back pain
async def bro():
variable_list = [
'hallo kinder',
'https://tenor.com/view/kny-hello-chat-giyuu-tomioka-levitate-gif-23115905',
'ihr opfer',
'hdf',
]
channel = bot.get_channel(985970666643816498)
await channel.send({random.choice(variable_list)})
bro.start()``` why doesnt this work? :( no error
it just doesnt work
kek
you're asking a task to start itself
and you should also check if Bot.get_channel returns None
just use the http method directly
bro
how would i do it correctly?
bot.http.send_message(id, "whatever")
smh
should i take notes for everything, like if i have a very brief python tutorial and a book that introduce python to a programmer. Should i take notes for both or only for very brief python tutorial?
start the task after the bot is ready
thanks
it depends, i mostly dont take notes but i take it easy so i process the given information correctly but thats just for me
U should probably create a python file and play with stuff u learn in there
how would it look alike in the on_ready? sry for being dumb
tbh you need practice more than keeping notes, you can try codewars and other stuff.
because you can also google the things you aren't able to get to work anytime but skills.... you need to develop yourself
start the task using bro.start() in your on_ready
and inside the bro task, add await bot.wait_until_ready()
ok, language i was learning was cpp, and i was confused should i take notes for The Tour of cpp and for learncpp.com
thanks
same applies for any language
so bro.start() await bot.wait_until_ready()?
hey guys
sry bad indent
it says command already exists when it doesnt
i mean its a life skill, to know how you learn for example
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.
๎บง
thats not true
how do i rectify it?
@silk fulcrum sire come to my rescue
bro.start will be inside on_ready
wait_until_ready will be inside bro
end goal is to go very deep into low level stuffs
oh okay thanks
bruh I just did only mentions so this channel wont annoy me and now he pings me
i personally would like to learn cpp, but i do think i know about low level stuff especially from the experience of learning rust
i would honestly still go for rust over cpp tbh
i like cpp, soo
thats nice
rust is better in terms of low-levelled features like memory management and general programming practices. but uk, everyone has their own choice
after becoming good in cpp, i will improve my knowledge in asm
yeah its sorta of a mix of low level and high level making it "mid level" abstraction wise
guys!!!!!!!!
there's already a default help command that discord.py provides
if you want a custom help cmd check this out
!custom-help
Custom help commands in discord.py
To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000
personally if i were to used a fully compiled language i would use rust, but the only language im leaning to fully learn right now is Elixir
I'll start java after 6-7 months
sorry i was in wrong channel, ๐คฆ
don't worry, its #ot3
dont worry, it happens 
Ooh so u mean I can't use help? As a command? I need to put in some other name?
check the link in the embed
^
im going to start learnimg languages like java and cpp next year as my next years class teaches about programming with languages like cpp, java and python
thats cool, ๐im on a drop preparing for college
next year im going to 11th grade lol
currently learning about the basics of electricity
we had python in our 9-12
thats interesting, the only pain im getting this year is physics and next year im taking chemistry

chemistry is pain
im too lazy to learn things, so it is
whilst calculation based stuff like maths or physics is lowkey easy for me
thats a good way of describing that you posses something called a "skill issue".
it was disnake.guild.change_voice_state(self_deaf=True)
this is a suggestion, not an error
just run it, you'll see that the problem will be gone
this has to do with vs code which doesn't check for new installed packages every millisecond, so you could just reopen the file and vs code will check again
ohk, new to vsc ;-;
yo how can you enable and disable stuff? like i got a listener where if someone sends imagine text the bot will reply with i cant even imagine text
so what do you want to enable/disable?
does anyone know why Nayu's name comes up twice?
await cursor.execute('SELECT level, xp, user FROM levels WHERE guild = ? ORDER BY level DESC, xp DESC LIMIT 10',(ctx.guild.id,))
data=await cursor.fetchall()
if data:
em=nextcord.Embed(title='Server Leaderboard',color=0xfd9fa1)
count=0
for table in data:
count+=1
member=ctx.guild.get_member(table[2])
em.add_field(name=f'{count}. {member}',value= f'Level-**{table[0]}** | XP-**{table[1]}**',inline=False)
await ctx.send(embed=em)
imagine text
like i should be able to decide whether the bot can send that things or not, for example i am ricky and the bot replies hi ricky, i am dad.
understood?
Do you have two different entries for that person in the database table
if checks?
To check. Just print your data variable as a debug method.
How can I create a text channel with permissions?
Does somebody know how I add a option to my slash command?
Example:
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a โsecretโ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
@slate swan ^ overwrites kwarg
@sage otter
maybe u know?
No, I have touched slash commands once.
๐ /
depends on what library you use, you can just add arguments inside the command callback in discord.py
๐ โโ๏ธ
How can I like get the id of that channel which just got created?
Assign it to a variable and access it
x = . . .
x.id?
Yea
hey @slate swan i found a better way to this
AttributeError: โstrโ object has no attribute โidโ
client.remove_command("help")
it works just by this
Gimme a min
@discord.ui.button(label='Support', style=discord.ButtonStyle.grey, custom_id='persistent_view:green')
async def green(self, interaction: discord.Interaction, button: discord.ui.Button):
overwrites = {
interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False, view_channel=False),
interaction.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True),
client.author: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True)
}
ticket = await interaction.guild.create_text_channel(name=client.author, reason="Ticket Creation", overwrites=overwrites)
await interaction.response.send_message(f"Creanted a ticket <#{ticket.id}>", ephemeral=True)
id = ticket.id
channel = await client.fetch_channel(id)
embed = discord.Embed(title="New ticket created by {client.author}", description=f"{interaction.author} Please wait for support staff to arrive here and help you\nTill then vote for us **[here](https://top.gg/servers/{interaction.guild.id})**", color=discord.Colour.dark_theme())
embed.set_footer(text=interaction.guild.name)
await channel.send(content="{interaction.user.mention}", embed=embed)
Extra redundant line of code. Just set it to None in your bot constructor.
@sage otter ^
Do you mind if see the full error.
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
await item.callback(interaction)
File "c:\Users\User\Desktop\ACLib\bot.py", line 55, in green
ticket = await interaction.guild.create_text_channel(name=client.author, reason="Ticket Creation", overwrites=overwrites)
File "C:\Python310\lib\site-packages\discord\guild.py", line 1309, in create_text_channel
data = await self._create_channel(
File "C:\Python310\lib\site-packages\discord\guild.py", line 1175, in _create_channel
payload = {'allow': allow.value, 'deny': deny.value, 'id': target.id}
AttributeError: 'str' object has no attribute 'id'
This is a problem with your overwrites
One of your overwrite targets are a string and not a Member or Role
So if I want to set perms for a user what should I use
The Iโd or name?
id*
The user's member object for that guild
Lemme try rq
I am making a sqlite database economy bot now I am want to make that it adds 5 cookies in each message event.
btw the currency name in cookies
So I have no Idea how to do that
here is my code done till now
@bot.event
async def on_ready():
con = sqlite3.connect("jar.sqlite")
cur = con.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS jar (
user_id INTERGER, cookies INTERGER)""")
print("Bot is Now Online")
@bot.event
async def on_message(message):
if message.author.bot:
return
author = message.author
con = sqlite3.connect("jar.sqlite")
cur = con.cursor()
cur.execute(f"SELECT user_id FROM jar WHERE user_id = {author.id}")
result = cur.fetchone()
if result is None:
sql = ("INSERT INTO jar(user_id, cookies) VALUES(?, ?)")
val = (author.id, 0)
cur.execute(sql, val)
con.commit()
cur.close()
con.close()
await bot.process_commands(message)
@bot.command()
async def jar(ctx):
con = sqlite3.connect("jar.sqlite")
cur = con.cursor()
cur.execute(f"SELECT cookies FROM jar WHERE user_id = {ctx.author.id}")
bal = cur.fetchone()
try:
cookies = bal(0)
except:
cookies = 0
await ctx.author.send(f"You have {cookies}")
Thatโs gonna be a lotta database interaction if itโs for every single message a person sends.
You should be using an asynchronous sqlite library like aiosqlite or something
And also you should open a database connection once and use it as a bot variable
I am using sqllite3
Is that so bad?!?!!
awww... I am useless
I use sqlite!!!
that's evil!!!
I don't deserve to live
aiosqlite is similar to sqlite3
One noticeable different I have noticed is that also aiosqlite.Cursor objects support using with
so can u help me out with my current situation?
pls
switch to aiosqlite
I don't have energy to switch to a different lib now
?!!?!?!?!?
will my current code work there?
or I have to again rewrite it?
no, aiosqlite is async, you'll need to add await and async everywhere

after looking at the code for 1 hour i still can't figure out what's the matter here
@commands.Cog.listener()
async def on_member_join(self,member):
print("member joined")
guild = self.client.get_guild(guildid)
channel = guild.get_channel(999084968766619688)
embed = discord.Embed(title=None,description=f"someone just joined")
now = datetime.datetime.now()
tem = now.strftime("%Y-%m-%d %H:%M:%S %p")
embed.set_footer(text=tem,icon_url=thumbnail)
embed.set_thumbnail(url=member.avatar_url)
await channel.send(embed=embed)```
it's printing the member joined but it's not sending the message in the channel
Can I view my aiosqlite database in db browser?
wdym?
I wanna view it
can someone spot the error here?
that's just a library, sqlite is a database itself, you can view it anyway, either you use sqlite, aiosqlite or some other language
self.client ๐ญ
hmmm... okay
why people name Bot instances with client
time to kill all of my code
it's just
lol idk i've been using dpy for 2 years and i never named my bot bot always client
2 years an you write such tr... weird code?
I mean itโs just a variable. You can name it whatever you want.
what's weird?
and as long as it works it doesn't matter, btw any idea why it ain't working๐
Can't find the channel maybe?
using datetime.datetime.utcnow() when discord.utils.utcnow() exists (well this is not a big deal, just less importing)
i will add in a change to make it so it only triggers when a member joins in a specific channel, that's just base code
nope
do you have an error handler?
never knew 'bout this
it should print in the terminal right ๐
what?
do you have an error handler
nope
hm wery weird
what's difference between sqlite and aiosqlite?
the classic method to find the culprit
like features or what??
lol, i'll try that
Where are you defining guildid?
And why are you not using member.guild
in a variable, i want to make sure it only triggers when a member joins a specific guild, i know it won't work, but i will add that later
I think thereโs a lot of things wrong there and without specific exceptions iโm not gonna dredge through it all with you
thats not the better, but just a way to do it.
aiosqlite is async
which doesnt block event loop for your bot
more like f"<t:{discord.utils.utcnow().astimezone().timestamp()}:R>"
aiosqlite is the async driver
sqlite3 is the standard driver with blocking -io operations
thanks for the answer
more like utils.format_dt
ohh... the main reason in it blocks the loop.
hmmm
discord.utils.format_dt(discord.utils.utcnow(), "R")
i downloaded retro theme for youtube :kek:
yeah, usually for a short unnoticable time, but can be bad for bigger bots
using aiosqlite is better anyways
what's better for bigger bots?
asyncpg
that's for bigger bots, use your sqlite
no need
postgres will be overkill for you
In future my bot can have memory like of 2 gb
finally, it was embed.set_thumbnail(url=member.avatar_url)
dpy 1.7 ๐ฟ
who still uses it
aiosqlite if you wanna stay with sqlite database
else, use aiomysql ( with mysql ) or asyncpg ( with postgresql)
I know I am sounding kind of stupid
Thatโs not really weird per say. Rather he just doesnโt know.
dude im using 2.0
in 2 years? ok, probably
avatar_url doesnโt exist in 2.0
okay!!!!! I will stick with sql
how is it avatar_url then?
Avatars are assets in 2.0
i recently switched to 2.0 idiot
I donโt quite remember him saying he had 2 years in bot development.
all of them are sql databases :p
oh that was the error bruh
sorry I mean sqlite. typing error
@sage otter
ah yes, aiosqlite would be good, you would nust have to add some awaits to your sqlite3 code and you're all setup!
Idk then. I guess it is weird.
Idrc tho. Whatever works, works I guess.
?tag itworks
This is not a Modmail thread.
why:(
RoboDanny doesnโt exist here. ๐ญ
I am gonna ping lemon
because in this server they probably dont add underdeveloped bots
imagine allowing everyone to ban joe and kick lemon
what?
import discord
import http
import aiohttp
from discord.utils import get
from discord.ext import commands
from aiohttp import ClientSession
class Chatbot(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(self, message):
cmdChannel = self.bot.get_channel(1008668481484500992)
inp = message.content
if message.author == self.bot.user:
return
elif message.channel.id != cmdChannel.id:
return
else:
await message.channel.typing()
async with aiohttp.ClientSession() as cs:
async with cs.get(f'https://api.popcat.xyz/chatbot?msg={inp}&owner=Ricky&botname=Estelle') as r:
res = await r.json()
await message.reply(f"{res['response']}")
async def setup(bot):
await bot.add_cog(Chatbot(bot))
can anyone explain? new to this vsc ;-;
async def main():
for file in os.listdir('./cogs'):
if file.endswith('.py'):
await bot.load_extension(f'cogs.{file[:-3]}')
print(f'{file} cog is working!')
how to get user avatar url in dpy 2.0? since member.avatar_url doesn't work anymore
This server only has bots that serve a good purpose and have a good efficient code base e.g the ones they have created @unkempt canyon for example
!d discord.Member.display_avatar.url
No documentation found for the requested symbol.
gah
!d discord.Asset.url
you understood
property url```
Returns the underlying URL of the asset.
member.avatar.url
display_avatar to not get error if user has default avatar
anyone? ๐ฅฒ
master pls ๐ ๐
@cerulean shale do not create a session in on_message async with aiohttp.ClientSession() as cs:
that is just complete trash
reminds me of anime girls saying senpai for some weird reason
you need only one
XD
i havent watched anime in a few lmao
pls explain master, i am too dumb
๐คค
its already 10:10 pm rn ;-;
ayo ๐
down bad bro
Save it as an attribute in the cog and close it in the cog_unload method
๐ค
well if that is only for one cog then yes
i'd save in setup_hook
Or as a bot attr and close it in the close method
i have so many client sessions in other cogs too
someone ever used tornado?
๐
Then do what other master said
other master :lmao:
so much masters who is the real master
Iโve heard of it
I mean Iโd say RDanny is a pretty well put together bot. The code isnโt really dirty and it pretty much has all the features a normal guild needs as far as versatility. Itโs made by the person who created the library so you know, I wouldnโt expect any less.
@strong ibexgimme back my nitro
Iโm โtheโ master
Master Oogway ๐
anyways what should i do to fix my issue?
Today we received reports of a phishing campaign targeting PyPI users. This is the first known phishing attack against PyPI.
Weโre publishing the details here to raise awareness of what is likely an ongoing threat.
183
162
already answered
i was thinking of using it instead of aiohttp for an api wrapper
but i really can't find any difference between them on internet
stay safe people
๐ฅบ
Ok I know nothing about tornado. I thought it was an equivalent of asyncio
pls explain master ๐ฅบ
or else give me some docs to read ;-;
you mean trio?
No I thought tornado was like asyncio and trio
oh nvm its another async lib
do I? 
yeah lol
change it to Master Oogway
๐
btw docs pls ๐ฅฒ
TheMaster69
done
i was also thinking of NeverGonnaGiveYouUp
AWWWWWW WHERE'S MASTER OOGWAY AT???
oh , no its a web framework and can be used as an alternative to aiohttp
!pip tornado
