#discord-bots
1 messages · Page 630 of 1
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
Getting items in on_ready is not recommeneded.
the command does nothing and if I try changing it to slash.slash it tells me it's missing ctx still
tnx very
damn people still dont use forks tf
doesn't slash take an inter
I use disnake so i don't have all these issues lol
How can I get the number of messages sent by a user in a discord server and store it in a list?
userMessages = []
user = discord.utils.find(lambda m: m.id== j, channel.guild.members)
async for message in channel.history(limit = 100000):
if message.author == user:
userMessages.append(message.content)
print(len(userMessages))
I'm currently using this code but it is too slow
a better way is logging the messages using the on_message event
how exactly can I do that?
can someone help me
so the function is reducing balance its just its not adding value in the column
hm = 1
@golden.command()
async def coin(ctx):
conn = sqlite3.connect('test.sql')
c = conn.cursor()
amount = 80
player = ctx.author
c.execute(f"UPDATE data SET balance = balance-{amount} WHERE ID = {player.id}")
c.execute(f"UPDATE data SET golden_coin = golden_coin+{hm} WHERE ID = {player.id}")
conn.commit()
await ctx.send('Golden-Coin Was Successfully Added In Your Inventory')
just log them, the key would be the id of the author and the value would be a set of the user's messages
may i ask why
he wants it on the spot
on_message only works for every new message
I don't actually know how to do that
its the server's fault if they didnt invite it before. as the owner of the bot, we have to take care so that we dont get rate limited
yeah thats true
wut
because I'm using this in a slash command
Logging messages for no good reason is against the TOS.
then use channel.history ig
If you log commands, that's fine. But you still need to have a privacy policy and terms of use for your bot.
async for message in channel.history(limit = 100000):
thats a massive amount though
yeah I just did that for testing
For each 100 messages a request is made. This number can easily ratelimit the bot.
yeah I'll set that to 5000 or less , but still this is too slow
it is taking 20 sec to calculate for single user
5,000 means 50 requests at once.
ratelimit
so what slowing this is the limit?
i would say to not do it at all, there is a reason no big bot does it
hm but it is necessary for my bot
If your bot is for public use, I don't recommend doing such a thing at all.
If only 2 users used the command at once, your bot will get ratelimited very quickly.
also i wonder why add such a useless thing, if they can just use the search bar
this is what actually I'm making
Then go with what @sullen shoal said and store user's messages count.
What’s the problem?
but then what about all the previous messages?
say goodbye to em

wao😂
check out this bot this bot can calculate previous messages too
so why cant my bot do that?😅
no I want to calculate how many messages a user have sent
count=50, check=lambda m: m.author.id == 12345
You need to first get the messages.
Store messages counter on on_message event
how exactly?😅
use on_message event, then figure how you want to store it ?
any api references?
on_message said it thrice
make a dict, increase the message count of each user on message and save the items of the dict to your database every 20 minutes or so
all that for a single command?
yes?
hm , thanks for help , I'll try that
you just check if the member has the required message amount on his interaction
how exactlyyyyy?
😅 thats exactly what I want to do
Im not here to give any code, you got the docs
its some basic algorithm shit, idk why someone would need help with that
I have read the docs , it said use history
devs nowadays
help pls
that's exactly what I was trying to do
and I was getting the expected result but lil bit slow
if you want your bot to be repeatedly ratelimited and then finally get banned, please use TextChannel.history
How do I get the category count of a server?
okah
!d discord.Guild.categories
property categories: List[discord.channel.CategoryChannel]```
A list of categories that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
Okay thank you
soo the command is reducing the value in the user's balance
its just its not adding more value in the column
hm = 1
@golden.command()
async def coin(ctx):
conn = sqlite3.connect('test.sql')
c = conn.cursor()
amount = 80
player = ctx.author
c.execute(f"UPDATE data SET balance = balance-{amount} WHERE ID = {player.id}")
c.execute(f"UPDATE data SET golden_coin = +{hm} WHERE ID = {player.id}")
conn.commit()
await ctx.send('Golden-Coin Was Successfully Added In Your Inventory')```
help please
"-{amount}"
can someone explain what this means?
this keeps happening randomly and i have to turn the bot back on
you must be doing some really weird stuff if you get websocket errors
what kind of weird like in commands or in cofig?
idk
Is there a way to get the description of a server?
ok thx for the help i guess
!d discord.Guild.description
The guild’s description.
Okay thank you
i hope sticks isnt actuallly doing discord.Guild.description in their code
Lmao no I’m not
post it on Stack Overflow, looks all Java to me
please tell me how
Tell what?
hey man that looks like ruby mixed with c++ and java to me
Probably just a shitpost. I doubt he was being serious
oops
It was a joke.
thank god
Kind of. I was translating "It's all greek to me" into programmer language.
can you please give me a hint , I just couldn't figure it out , I have been studying docs but cant find anything
I don't want to store mew messages , I just want number of messages that are already been sent
Hey @slate swan!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Hey, i'm making a json API with synchronization with my discord bot, i make the code but the API list dont update, semeone can help me? (if needs the code please DM me)
how can we get user banners?
?
I mean googling is not hard
user.banner.url # the URL of the banner```
ty
ig
discord.Embed(add_field(name = "test",value="other test",inline=False)) idk how to add fields to embeds
Stop pinging me please, you can just ask
And no.
Unless they have it connected to their discord
🤷♂️
Embed().add_field()
^ you can check it out
ty can it be like Embed().add_field().add_field()?
Yeah
That’s what I said.
Oh, connected. I missed that. My apologies.
https://stackoverflow.com/questions/66157012/discord-py-getting-info-about-user-connected-accounts start off from here
How do i change colors of an embed?
You add the hex of the color
can you give me an example please
default = 0
teal = 0x1abc9c
dark_teal = 0x11806a
green = 0x2ecc71
dark_green = 0x1f8b4c
blue = 0x3498db
dark_blue = 0x206694
purple = 0x9b59b6
dark_purple = 0x71368a
magenta = 0xe91e63
dark_magenta = 0xad1457
gold = 0xf1c40f
dark_gold = 0xc27c0e
orange = 0xe67e22
dark_orange = 0xa84300
red = 0xe74c3c
dark_red = 0x992d22
lighter_grey = 0x95a5a6
dark_grey = 0x607d8b
light_grey = 0x979c9f
ok do i dodiscord.Embed().Colour("0xe74c3c")?
em = discord.Embed(title="",description="",color=0x1abc9c)
ok ty
Yw
Not self bots
No need
Yes need
You can just do discord.Colors.insert_color_here()
But using hex is recommended if there is no good colors
Thats the point
I mean I use it 😭
Same
But still, it’s faster and more efficient than searching up a hex
Just .bm it
I hate hex
.bm fine.

That was deprecated
Can’t even access that info on there.
Read the post
Anytime you try to access discord.Profile attributes you will always get None
It’s a discord limitation
I hate it when you’re about to do something fun and then it says: Against ToS
I nearly broke the TOS of many websites
Scratch: tried to exploit a GitHub code
Discord: nearly self botted myself
Various websites: tried to break in
And some GitHub resps
😳

how can i make the bot do an action on a message the bot has sent itself?
So I have a currency command that converts currency and stuff and when I try to run my bot, it gives me this error, what do I do? https://mystb.in/UnderstandingFullGuitar.python
You wrote kclient by accident
Change it to client
You can use emojis from different servers in your bots, right?
Oh oops
Ok
I don't
Oh sweet
how do i make it that the bot reacts to a message sent by itself?
just use on_message
remove the the two lines where it returns when the message is from itself
ok
It’s giving me this error now
Why did you put “kumo”
LearnPython(None)
There is no Bot.kumo lmao
True tho
ask without asking to ask
im newbie in Python
@client.command()
async def setdelay(ctx, seconds: int):
await ctx.channel.edit(slowmode_delay=seconds)
await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")
then practice python first
add please embed
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
So instead of kumo there, it would just be c = await self.client.currency_conversion(_from, to, value)?
Well idk your code
then you send that with
await ctx.send(embed=embed)
how do i make the bot react to a message?
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
yep
Ohh I still don't understand
thought of that after this message
😦
AttributeError: 'Message' object has no attribute 'add_emoji'
oh typo
my bot tells me this discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji i use await message.add_reaction("👍")
you have to add the unicode emoji i believe?
unicode? what is that?
.add_reaction("U+1F44D") still doesnt work
If emoji is built in in discord you can use :emoji_name:
I don’t think you can
It’s only unicode afaik
oh yeah that only works for messages
ok i found some website where you can copy unicode
There is a tutorial
Go to your bot's settings on the dev portal, go to OAuth -> General -> Default Authorization Link and config from there
can someone help me ?
this code doesn't work
Code:
@bot.command()
async def captcha(ctx):
user = (ctx.author.id)
if captcha == '1':
await ctx.send(f'Aby się zweryfikować patrz dm')
await ctx.send(f'Jeżeli wiadomość nie przychodzi zgłoś się do Dewelopera')
embed = Embed(title = 'Captcha', color=998514)
embed.description = f'aby się zweryfikować napisz co tu jest napisane'
embed.set_image(url="attachment:captchafiles/captcha1.png")
embed.set_footer(icon_url=ctx.author.avatar_url, text=f"{ctx.author.name}#{ctx.author.discriminator}")
await user.send(embed)
if captcha == '2':
embed = Embed(title='Captcha', color=998514)
embed.description = f'aby się zweryfikować napisz co tu jest napisane'
embed.set_image(url="attachment:captchafiles/captcha2.png")
embed.set_footer(icon_url=ctx.author.avatar_url, text=f"{ctx.author.name}#{ctx.author.discriminator}")
await user.send(embed)
I use random, discord.py
files are correct
and variable too
def FunFact():
return random.choice(FunFacts)
FunFact()
print(FunFacts)
This works. However when trying to call if from my discord script. Nothing is printed.
@client.event
async def on_message(message):
openers = "hello", "hi", "hey"
username = str(message.author).split("#")[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f"{username}: {user_message} ({channel})")
if message.author == client.user:
return
if user_message.lower() in openers:
await message.channel.send(f"Hello {username} lets get started!")
time.sleep(1.0)
await message.channel.send("What would you like to talk about? Weather, Nutrition, Jokes or Facts?")
if user_message.lower() in choiceJoke:
FunFact()
Fact = FunFact()
print(Fact)
await message.channel.send(Fact)
time.sleep(1.0)
await message.channel.send("What would you like to talk about? Weather, Nutrition, Jokes or Facts?")```
Why does the function not work when called from the discord bot
"Doesnt work" error?
Do you have on_message event
Hey @worthy moat!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
if captcha == "1": it needs something to work like u need to add a parameter or add wait_for("message")
.d discord.wait_for
U need to define captcha aswell
Wait
thats the all thing for captcha
random1_2 = ['1', '2']
captcha = (random.choice(random1_2))
I think he Has got the on_message event in code
mmm
Remove ()
.
ok
How can I make a bot wait 60 seconds before running on_typing again?
captcha = random.choice(random1_2)
await sleep(60)
Its says undefined name "sleep"
U need to import it
still doesn't work
What do I import exactly? import sleep?
No
from asyncio.tasks import sleep
If anyone can help with this. It makes no sense. A working functions simple just doesnt work if ran though the discord code block
still doesn't work
Did u define funfacts?
FunFacts is the returned fact from FunFact. I know bad naming xd
Error?
As i said. The code works outside of the discord code block. However inside it prints nothing and discord errors that it cant send a blank message
npe
Mmmm
Make a list
opener = []
I even tried having the Function in the same script. Control C code outside of the discord. It works. Control C code into the discord block. No return
However discord bot functions are supposed to work exactly like this so
Maybe u forgot something tho
Its literally just calling a function. I dont know how much else i could miss lol
hi i have a question. is it still possible to make a custom music bot or youtube wiped their whole discord api support
I say lol but im crying inside

Try to remove "s" from FunFacts
wym by discord api support
Cant you just import asyncio
def FunFact():
return random.choice(FunFacts)
FunFact()
print(FunFacts)
Its agaisnt yt TOS you can check spotify
That works aswell
Well its not erroring but now its just not at all running sleep(60)
Easier
okimii being pro 😄
I'm not sure they had any support in the first place
Add await
Its await asyncio.sleep(60) cuz its a coroutine
No u
I did lol
:| mmm
I added await but I dont have asyncio, Ill try that
Then your doing nothing

@cerulean osprey btw dont use time.sleep() as its not async and will stop your whole bot so use asyncio.sleep() as its async
not pro people calling me toxic because I stated the obvious

Youll get use to it
Gotcha, well asyncio.sleep() is making replit yell at me with red underlining 
Show
await asyncio.sleep(60)
Show the full code
no need to await i think
You do
@client.event
async def on_typing(channel, user, when):
if channel.id == 909685766244945921:
await channel.send(f'Woah, {user.mention}! Before you send your message, just be warned, you will be softbanned if you message here!')
await asyncio.sleep(60)
oh
Let me check
Wut abt
No need
f 😦
As its just pointing at the asyncio.sleep()
It might help 🤔idk
It works already, Im talking abt asyncio.sleep()
type hinting doesn’t do anything at run time.
Exactly
from asyncio.tasks import sleep
No just import asyncio
It’s just to help your IDE and documentation.
okimii being smort
That works aswell
More efficient
Still didnt work sadly
No your smorter
Weird
no your smorter 

What are you trying to do again?
U got any errors?
Make the bot wait 60 seconds before running on_typing
No
cooldown?
Something like that ye
its an event sorry
And who said sleeping it would not allow the event to be triggered again?
Your just making it delay after the command is invoked
That defeats the whole point of async programming
make a check and check every 60 seconds if a variable is True
I meant again
^
Make the bot wait 60 seconds before running on_typing again
yay tylerr
Consider making your own throttling for this.
make a check to see if a variable is True. If it is, send the message, switch it to False, wait 60 seconds before True.
Use commands.cooldown(0,0) i think it is
these are for commands
It's an event, won't work 😦
Not events
stroke
How would I go abt doing that?
a = False
await asyncio.sleep(60)
a = True
if a:
stuff
a = False
else:
something idk
I dont know I quick coded it :/
It has to be in a async function
didn't bother doing that 😦
Or it will just say await blah blah blah is not in a async function
fine
That was happends when you do a global var with await
@client.event
async def on_ready():
a = False
time.sleep(60)
a = True
if a:
stuff
a = False
else:
something idk
logic
...or not
Did you know asyncio.sleep only sleeps the async function right
damn im stupid
And its client.event
ahhhh
And i don't recommend doing it on ready
I mean time.sleep() would work?
Ok now it just waits 60 seconds before doing it 
ok
just move it to the back of the code
Its not async so it will just delay your bot
move the false stuff to the back?
Why would delay your bot
smort
idk my code sucks I only use logic 😦
Seems about right
Still doesnt wait for 60 seconds 
I cant think of something
@client.event
async def on_typing(channel, user, when):
if channel.id == 909685766244945921:
a = True
if a:
await channel.send(f'Woah, {user.mention}! Before you send your message, just be warned, you will be softbanned if you message here!')
a = False
await asyncio.sleep(60)
a = True
else:
return
``` prob did it wrong but this what I did
Just realized you cant use asyncio.sleep in a command just too delay a response or something but not the command as the command will still be invoked
You can only sleep a command with the cooldown decorator which doesnt work for commands
But its not a command 
Thats the point i cant think of delaying a event
Damn alr, thanks for trying
Your welcome
@velvet tinsel can you think a way of delaying a event cuz i cant tbh
Do you know tyler
huh
I think you replied to the wrong message 
I found asyncio.sleep() and time.sleep()
No it doesnt stop the event or command from being invoked 
yeah i dont think there is any
Never heard of it
!d asyncio.Lock
class asyncio.Lock```
Implements a mutex lock for asyncio tasks. Not thread-safe.
An asyncio lock can be used to guarantee exclusive access to a shared resource.
The preferred way to use a Lock is an [`async with`](https://docs.python.org/3/reference/compound_stmts.html#async-with) statement:
```py
lock = asyncio.Lock()
# ... later
async with lock:
# access shared state
```...
me neither
I see
I love how it just says: NOT THREAD SAFE
I'll get on my computer and see if I can write a quick example
prob a bad example but here it only prints the second time if the lock is released
And the lock is only released after waiting 5 seconds
What is that ide?
This isn't an IDE its the ipython repl thing
The wut😭
Its like how you type python in your terminal and a repl pops up
Depends on how the terminal is customized i'd say
I mean I do use neovim though, so my IDE basically looks like that as well
Thats cool,never heard of that ide before
Should check it out, very productive although it's a unconventional IDE compared to what I assume you usually use
You probably know what i use 
Vscode?
Yes
Ah yea then its gonna be pretty much wildly different
How?🤔
Its a lot more minimal then Vscode and there isn't really and clickables
You have to do everything you want on the keyboard
Ah i see
can someone help me ?
this code doesn't work
Code:
@bot.command()
async def captcha(ctx):
user = (ctx.author.id)
if captcha == '1':
await ctx.send(f'Aby się zweryfikować patrz dm')
await ctx.send(f'Jeżeli wiadomość nie przychodzi zgłoś się do Dewelopera')
embed = Embed(title = 'Captcha', color=998514)
embed.description = f'aby się zweryfikować napisz co tu jest napisane'
embed.set_image(url="attachment:captchafiles/captcha1.png")
embed.set_footer(icon_url=ctx.author.avatar_url, text=f"{ctx.author.name}#{ctx.author.discriminator}")
await user.send(embed)
if captcha == '2':
embed = Embed(title='Captcha', color=998514)
embed.description = f'aby się zweryfikować napisz co tu jest napisane'
embed.set_image(url="attachment:captchafiles/captcha2.png")
embed.set_footer(icon_url=ctx.author.avatar_url, text=f"{ctx.author.name}#{ctx.author.discriminator}")
await user.send(embed)
I use random, discord.py
files are correct
and variable too
Use del
ok i'll try

@client.command()
async def hi(ctx):
await ctx.message.delete()
has_perms = False
for role in ctx.author.roles:
if role.name == "Sr. Admin" or role.name == "Admin" or role.name == "Jr. Admin" or role.name == "Sr. Mod" or role.name == "Mod" or role.permissions.administrator:
has_perms = True
if has_perms:
if "ticket" in ctx.channel.name:
db = await aiosqlite.connect('database.db')
cursor = await db.execute("SELECT user_ids FROM tickets WHERE user_ids=?", (ctx.author.id,))
rows = await cursor.fetchone()
if rows is None:
cursor = await db.execute('INSERT INTO tickets VALUES (?,?);', (ctx.author.id, 1))
await db.commit()
await db.close()
await ctx.send(f'{ctx.author.mention} will be assisting you today.')
return
else:
cursor = await db.execute('UPDATE tickets SET number=number + ? WHERE user_ids=?', (1, ctx.author.id))
await db.commit()
await db.close()
await ctx.send(f'{ctx.author.mention} will be assisting you today.')
return
else:
await ctx.send(f"{ctx.author.mention}, this isn't a ticket!", delete_after=5)
return
else:
await ctx.send(f"{ctx.author.mention}, you don't have permission!", delete_after=5)
return``` The ```py
else:
await ctx.send(f"{ctx.author.mention}, you don't have permission!", delete_after=5)``` meaning I don't have permissions, which I do.
that's right?
for i in banList:
if i['Player'] == player:
print(i)
del i
break
I think so
the pop works here?
Dont really know never done it
oh
I think its
del banlist[i]
ok i'll try again lmao
returns this error
Yeah i figured
Idrk because i wouldn't use a dict as a db as it always gets cleared after you restart your terminal
nested dict?
like this? i did not understand
show how banList looks like
ok,
data = { "player":"randomName123", "why":"hacks lmao", "staff":"staffName123" }
hmm, it shows that i is a dict in your error and banList is a list not a dict
but this is only the ban data, the ban is saved in a table like this:
Datastore = {"userData":moneyData, "bans":banList}
show your banList it should be a list as in the error
@visual island my ban list looks like this
what, your error says its list
and this is data isn't it? Not banList
I just showed you how the banlist is
In the disnake support server it says when your going to download disnake to delete dpy and leave disnake why is that so?
Maybe name errors?
Idk does it work
Yeah perfectly i just guessed maybe naming errors
As it works as normal and as intended
Maybe
Yeah
What?
They say not to forget to uninstall dpy but no reason is given and i will like to know why?
Because disnake has different things than discord.py
But that shouldn't matter
You access disnake things through disnake and you access discord.py things through discord
equenos
What about him?
Srry I meant to send that in google chrome search engine
Happens all the time
im using replit and their database. for some reason when i reset my database and initialize some data into it, i have to rerun my code 2 more times before it pulls the data out correctly
anyone heard of this before?
@client.command()
async def mute(ctx, member: discord.Member, time=None, *, reason=None):
format = datetime.now(tz=pytz.timezone('America/Tijuana'))
formatted = format.strftime("%I:%M %p")
b = DT.datetime.now().timestamp()
modlogs = client.get_channel(872909569196707870)
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM mutes')
rows = await cursor.fetchall()
muted = discord.utils.get(ctx.guild.roles, name="Muted")
farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
if ctx.message.author.guild_permissions.administrator:
if member is None:
e = await ctx.reply('You must mention someone to mute!')
await asyncio.sleep(5)
await e.delete()
await ctx.message.delete()
return
if time is None:
a = await ctx.reply('Please state a time for a timed mute or a reason for a permanent mute!')
await asyncio.sleep(5)
await a.delete()
await ctx.message.delete()
return
if reason is None:
if time[-1] in ['s', 'm', 'h', 'd']:```
So, when I use
.mute @hollow agate Spam Bot
It thinks that it's `if time[-1] in ['s', 'm', 'h', 'd']:` thing, what's the best way to fix this?
Repl is very buggy and there's really no way to determine what's causing it. I would suggest you invest in a half-decent hosting.
Depends what you need it for really
If its a server scale bot you would be fine but if you choose to expand to multiserver that would be ideal
Hi
@bot.listen("on_message")
async def o(ctx):
if ctx.reference == "D":
await ctx.channel.send("Thanks for the reply!")
```So I want my discord bot to say Something when someone replies to my bot's msgs except it must be specifically a "D". So far this is my code, which obviously doesnt work. How can I fix this?
does anyone know how to get rid of the inbuilt help command?
Yes I know
i made am embedded help command myself but dont know how to get rid of the othher 1
help_command = None
bot.remove_command("help")
Both work
thanks guys
Yw
Yow
Like the message starts with a d?
Nah already fixed
Alr
But thanks for trying to help tho
Yw ig
Yw?
Yw=Your welcome
Ohhh
I'll use them for the good then
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
client = commands.Bot(command_prefix='#', intents = discord.Intents.all())
@commands.command()
async def bruh(ctx):
await ctx.send(file=discord.File('text.txt'))
client.run('token')```
I want my Discord bot send a text file but I got error command not found
Can I know what's wrong here? Thanks
Yeah
Yeah that file=discord.File() doesn't work for me too lol
To this day I still don't know how to fix it
from discord.ext.commands import bot```
Thats not a thing iirc
No need for that import
Ohhh
Command not found
And dont call your bot instance client
Is it in a cog?
Not no file or directory
Wow
Because if its not its @client.command()
Now I know,I can now live happily
Forgot you named your bot instance client
I don't know what a cog is :v
I just copied and pasted codes from other places cause I don't know anything about coding
Sad
Just saying you shouldn't as dpy isnt beginner friendly and you must know python for it
Sometime I might learn how to code seriously
But no plan for now
Anyway, thanks for the help
Alr yw
Cogs are useful for organizing your commands into separate files. You can learn how to use them in this repository. https://github.com/ScopesCodez/discordpy-cogs
i installed discord and checked the list and it was there but i import discord into vsc and it says Import "discord" could not be resolved
ive coded before on windows 10 is it a problem if im on 11?
It's an issue with Visual Studio Code. Just reload the window and it will work. If you're on windows, click ctrl + p then, choose Developer: window reload.
It's a new issue with visual studio code; it's not with Windows at all.
I believe ctrl p opens the commands list? Anyhow, to get away from this hassle, just restart visual studio code.
actually, you only need to restart the language server 😄
python.analysis.restartLanguageServer
I haven't thought of that. Will try it in the morning. Thank you!
got sick of restarting my terminal lol
So it was an LSP problem? Back when I used VSC I just switched the python interpreter and that seemed to fix it, although I might have experienced a different issue then what is happening here
im tryna use channel.send for a png but it just says "channel" is not defined. ik what it means but how do i define it?
@client.command()
async def someone(ctx, member: discord.Member, time: typing.Optional[TimeConverter] = None, *, reason=None):
format = datetime.now(tz=pytz.timezone('America/Tijuana'))
formatted = format.strftime("%I:%M %p")
b = DT.datetime.now().timestamp()
modlogs = client.get_channel(872909569196707870)
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM mutes')
rows = await cursor.fetchall()
muted = discord.utils.get(ctx.guild.roles, name="Muted")
farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
if ctx.message.author.guild_permissions.administrator:
if member is None:
e = await ctx.reply('You must mention someone to mute!')
await asyncio.sleep(5)
await e.delete()
await ctx.message.delete()
return
if time is None:
e = await ctx.reply('You must state a time/reason!')
await asyncio.sleep(5)
await e.delete()
await ctx.message.delete()
return
else:
if time == 0:
await ctx.reply(reason)``` When i run the command
.mute @hollow agate Spam Bot
it returns reason as `Bot`, how would I make the reason be the full reason rather than the reason after the first word?
Try adding another word after "Bot", and if it's included in the reason then, "Spam" is taken as the time.
Could I get an example?
Just add an extra word to the reason.
Is there any way around this?
I want it to be just a simple command rather than be annoying if you feel me.
.mute @hollow agate Testing Stuff
rather than
.mute @hollow agate Testing Testing Stuff
What's the difference in both of those 🤨
so i was trying to make a chatbot. it works, but it shows all of this.
someone said you have to index list and dict but idk how to do that im rlly new
any help? im using code with swastik's code btw
Which API u using?
how do i check? i think its randomstuff
yeah
Seems like the API returns a dict, which means you can do dict["key"] to get the value of key
So if I wanted message, I would do data["message"]
Although, since the dict is inside of a list you first need to access the first element
Which you would do again with square brackets
Indexes start at 0
would you like me to show my code?
There's Testing Testing which is quite a big inconvenience.
So u wanna limit the number of a single word in a str to 1?
from prsaw import RandomStuff
bot = commands.Bot(command_prefix=">")
api_key = "my api key"
rs = RandomStuff(async_mode = True, api_key = api_key)
@bot.event
async def on_message(message):
if bot.user == message.author:
return
if message.channel.id == chennel id:
response = await rs.get_ai_response(message.content)
await message.reply(response)
await bot.process_commands(message)
TOKEN = "my token"
bot.run(TOKEN)```
Is there a way to get access to a users Custom Status? I‘m not talking about the Online, brb, dnd, offline Statusses. I‘m talking about those where you can input an emoji aswell. Can I ger acces to that status by a bot?
Yea, just do what I said earlier
!d discord.Member.activity
property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
!d discord.CustomActivity
class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.
x == y Checks if two activities are equal.
x != y Checks if two activities are not equal.
hash(x) Returns the activity’s hash.
str(x) Returns the custom status text.
New in version 1.3.
isnt this only the „Playing/watching“ thing?
No, CustomActivity represents the status thing
What language is rs?
Rust
Oops, forgot to go to off topic channel
but thank you
Could I see what you mean?
Like, u want to change Hi Hi Hi There to Hi there and Test Test to Test?
No? I want to change Test Test to Test Test :P
bruh what
Am i tripping?
Oml.
Test Test == Test Test
!e print("hello world".title())
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
Hello World
this?
How is that even a thing 

Just asking how would you?
@client.command()
async def someone(ctx, member: discord.Member, time: typing.Optional[TimeConverter] = None, *, reason=None):
format = datetime.now(tz=pytz.timezone('America/Tijuana'))
formatted = format.strftime("%I:%M %p")
b = DT.datetime.now().timestamp()
modlogs = client.get_channel(872909569196707870)
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM mutes')
rows = await cursor.fetchall()
muted = discord.utils.get(ctx.guild.roles, name="Muted")
farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
if ctx.message.author.guild_permissions.administrator:
if member is None:
e = await ctx.reply('You must mention someone to mute!')
await asyncio.sleep(5)
await e.delete()
await ctx.message.delete()
return
if time is None:
e = await ctx.reply('You must state a time/reason!')
await asyncio.sleep(5)
await e.delete()
await ctx.message.delete()
return
else:
if time == 0:
await ctx.reply(reason)``` Is my code currently. I want the reason to just be `Spam Bot`
For this command to work, you do
.mute @hollow agate Spam Bot
It then puts `Bot` as the reason, so I'm confused on how I can make `Spam` be included into the reason somehow.
run a for loop
Where and with what?
!d str.count using this
str.count(sub[, start[, end]])```
Return the number of non-overlapping occurrences of substring *sub* in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation.
i was talking to okimii
Ah
!e
print("Hello World!".lower().capitalize())
@brave vessel :white_check_mark: Your eval job has completed with return code 0.
Hello world!
this converts title case to sentence case ^^
oh wait you weren't asking how to do that lol
Huh? They wanted to know how to prevent repeated words lol
Yeah
sorry, I got confused
Exactly, xd
so u also want to prevent repeated words?
Well, not exactly. I guess.
Never used it
Read what I put here.
!e print("Hi Hi Hi There".count("Hi"))
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
3
Time is removing the Spam and I somehow need make it to where it's not removed.
O
first of all
I suggest not making a connection to your database on each command @hollow agate
Because Spam is being consumed by the time arg
You really can't fix it ngl
Is this a bad thing for a server that is in a singular server? I haven't noticed anything.
Is there no way around this or a different way?
How like this?
for word in sentence:
if word == word:
word.replace(word,"")
No
M- welp.
nope, wait
What if its unknown?
Ofc slash commands are there tho
How does Dyno and other bigger bots do it? I know they don't use python, but there must be a way.
unknown.....?
Alr
They have custom private wrappers
Like what if you have random words and random amounts?
So I don't really know how they do it, but it's related to some typing annotations related
wait
Amount can't be random
what's happening?
No like amount of the same str
the reason you are putting is going into the time argument?
Because he's skipping the time arg in the command execution, yes
Not talking to you sorry
Nah nvm
so why not typehint to int?
What would that do? I don't think that would prevent it consuming the reason, but instead it would return the same string, instead of converting to int
Anyways I'mma go play some CoD, catch y'all later
wait one second
Good luck on the dubs
dang typing code on mobile is so ficking annoying
hold up, for your time argument, why are you doing typing.Optional and =None?
Ikr
I got till here
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content('$typewrite ') ```
I want the bot to type a message in a specified channel.
Would go like this: "$typewrite (channel) (message)
client.get.channel()
Tbf, I don't really know. Previously someone told me I needed both.
---ش---
isn't it get_channel?
You can do
await client.get_channel(id).send("idk")
Yeah i realized while i was typing
nvm i forgot how to do it
if message.content.startswith("$typewrite")
With freecodecamp ofc you will
but im still gonna do it
And then the await client.get command would go afterwards?
||not for you||
He can do ```if message.content == "smth":
Works the same
is shortest code but not strong
Wdym by strong
Goodluck
how to resolve this?
AttributeError: 'Member' object has no attribute 'VoiceState'```
discord py version is getting updates and your code got not work some day .
Doesnt have a attr too it,check spelling or docs
Who is gonna use dpy someday?
what'
tokhm dari bya iran
The Member object doesnt have a attr with VoiceState
You do not remove =None
Check spelling or docs
wait, changing to vsc
Don't really know about vc relates stuff
Okie
hm i will do it when im on my pc, mobile sucks
No
how to resolve this
File "D:\acrella\bot.py", line 1373, in <module>
bot.notes[guild.id] = {}
AttributeError: 'Bot' object has no attribute 'notes'
[Finished in 2.7s]```
¯_(ツ)_/¯
@slate swan the full error would be better
neverminddd
@slate swan uhmm how did you get notes
i did it wrong
File "C:\Users\Bruh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
im silly, it was bot.notes = {}
that isn't the full traceback
Please provide the full traceback for your exception in order to help us identify your issue.
A full traceback could look like:
Traceback (most recent call last):
File "tiny", line 3, in
do_something()
File "tiny", line 2, in do_something
a = 6 / b
ZeroDivisionError: division by zero
The best way to read your traceback is bottom to top.
• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).
To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.
hm = 1
@blue.command()
async def ticket(ctx):
conn = sqlite3.connect('test.sql')
c = conn.cursor()
amount = 150
player = ctx.author
c.execute(f"UPDATE data SET balance = balance-{amount} WHERE ID = {player.id}")
c.execute(f"UPDATE data SET blue_ticket = +{hm} WHERE ID = {player.id}")
conn.commit()
conn.close()
await ctx.send('Item Purchased Successfully')```
sooo the command is removing balance and adding 1 item in the column its just used repeatedly its not more than 1 value help please
any1?
elaborate please
Don't use f strings for this.
sooo when someone buys an item it doesnt updates the column of blue_ticket
i purchased item 5 times and the value in the column is 1
hmmm then how I make the bot to edit the column of the author's inventory or balance
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
ty
event must be "message"
why it give An error occurred: Command raised an exception: AttributeError: 'Utility' object has no attribute 'member'
it's because "Utility" has no attribute called "member" and you still used it
I don't see anything. You may have not sent the full code.
i take member : discord.Member for it
Hello! By chance, does anyone know why I am receiving a AttributeError: 'Command' object has no attribute 'CommandNotFound' error when I copied it exactly from a tutorial video. I am trying to add an error message that responds to the user that types a command that is not programmed into the bot (yet, optionally). Here is the code that I have for example.
ok.
you copied it from a YT tutorial. right.
you shouldnt copy paste
did i need to def smtg(member)?
exactly.
you wont learn anything that way
I'm looking into it
from discord.ext import commands
TOKEN = '(token)'
client = commands.Bot(command_prefix = 'it')
client.remove_command('help')
@client.event
async def on_ready():
print('{0.user} is now online!'.format(client))
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send(f'This is not a command. If you have an idea for a command, you can tell Finami and suggest it!')
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! `{round(client.latency * 1000)}ms`')
@client.command()
async def info(ctx):
await ctx.send(f'I am a bot created by Finami! He uses Python so that I can output any command that you do!')
@client.command()
async def isee(ctx):
await ctx.send(f'https://tenor.com/9uWN.gif')
@client.command()
async def help(ctx):
await ctx.send(f'If you have ran into a problem with your device and are looking for troubleshooting assistance, check out [#908222838706667560](/guild/267624335836053506/channel/908222838706667560/) to check out how I work, what I can do and what I cannot do. Then, move over to the [#907920566349090876](/guild/267624335836053506/channel/907920566349090876/) channel and open a new ticket to request assistance!')
@client.command()
async def commands(ctx):
await ctx.send(f'ping\ninfo\nisee\nhelp\nspecs\ncommands (This is what you are looking at right now. -_-)')
@client.command()
async def specs(ctx):
await ctx.send(f'My personal PC:\nIntel i5-6600\nNvidia GTX 1060 (3 GB version)\n8 GB DDR3 2133 Mhz RAM\n4 TB HDD\n1 TB SSD\n250 GB SSD')
client.run(TOKEN)```
Yes, that is correct.
ok tq
well i think yep i need def
def setup(client):
client.add_cog(utility(client))
Ok? I'm pretty sure that there is still a way that allows the attribute to work.
I think you need to add that
Fine, I'll help you.
next time don't just copy off a tutorial
added on last line
i cant copy whole file right
I don't think it's command.CommandNotFound, that YT vid is old
Right, thats what I was thinking as well since it is old.
use an isinstance
wait you did
The error is due to the command you registered named “commands”
Yeah I did.
Change the name of that to something else
use a getattr
Oh gotcha.
wait, it's not the fact that there's no getattr?
did it work?
Oh gotcha. Which should I change?
Is it one of the commands that I have programmed and its confused?
Error is telling me that commands is a Command object thus it should be due to the command the user registered under the name “commands”
just pass the func name to name kwarg in the decorator
ah~
Oh yep.
and change the func name to _commands or something
ok.
remove it then
wait, crap, I have it to take the info from the discord.ext and import the commands module.
WHT?
I was looking at the wrong bit of the StackOverflow question
Then I use the commands module to tell me to use this prefix.
you can just disable it
you don't need to fully remove it
"Commands in a cog are still methods of an instance of the cog. The first argument passed to them is always the instance"
hmmm
I can't change like any of them that uses commands
i think thats not the problem
Ok
Do you understand what I'm telling you to do?
You have a command that is named “commands”, I'm asking you to rename it which would then fix the error you are getting
that was the only solution i could find
I do understand, its just that I can't do that because its the name for one of the modules that are required for me to use the commands on my bot.
Gotcha. ok
yea its ok
Look at your client.command(), stuff you'll find one that decorates a function of which is named “commands” rename it to something else
you can try it out to see if it works. If not, I don't really know :/
That's shadowing the commands module which is causing the error, like I said earlier
Fixed it. Gotcha.
👍
happy days
I'll have to add an exception in order for me to format the word "commands" to use it as a command on my server or something.
No you can just pass an alias to the command decorator
The alias would be “commands”
oh ok. I don't think I have heard of that element before but of course, I learned python from MC and learning it from a text book which has different elements than a video or a book that is involved with programming a discord bot.
The command decorator, E.g @command() can take an aliases keyword-argument. This is a list of strings which would be the aliases to set for the command. Likewise if i wanted a command to have an alias of commands I’d pass [”commands”] to the aliases keyword-argument
Gotcha. Does that require me to create strings in order for it to work?
Yes, if you take a look at the bottom of the message I just sent you can see me doing that
Gotcha. Ok Thank you for the help!
hi, is there a way to get the raw annotations of the argument given? For example i have a command:
async def a(ctx, arg, arg2):
and if I invoked it like a 1 hi, can I somehow get {arg: 1, arg2: "hi"} from the Context?
Have you tried Context.args or Context.kwargs?
!d discord.ext.commands.Context.args
The list of transformed arguments that were passed into the command. If this is accessed during the on_command_error() event then this list could be incomplete.
how to get bot avatar url?, used bot not client, arl tried
bot.user.avatar_url
ah, but that doesn't show the argument name
?
Good evening I want to put on the mnm that the bot sends to Ticket to have an emoji 🔒 and go and close it but it does not do why does it not have the emoji?
it's a bit complicated but I'll find something for you
Args are in order of the function signature, so just pair with inspect.Signature
What do you mean "doesn't have the emoji"?
:lock: is a standard emoji, meaning every user (including bots) has it
okayy thanks
yes
👍
it must work i think
yes....why ?
declare a variable with that code as the value
I think there's a specific way to do that in code
🔒
🤷♂️
You literally do :lock:
That's it
ok
Or unicode or whatever fancy way, but :lock: will work too
oh and also, I have the first image in donation.py and second in main.py and this both prints the same id which is 1889934034768? Python also makes the a to the same value of LT where it should not
idk
wht u mean?
oh nvm i get it
what does Literal_ do again?
it's my custom class, but if you mean typing.Literal it typehinted the arg to be exact one of the values you give there
yes now?
show the code for the class please.
async def close(reaction, user):
if reaction.message.channel.name.startswith("ticket"):
if(reaction.emoji == "👋"):
await reaction.message.channel.delete()```
no, use wait_for()
where
I forgot how to use the !d command 😢
what am I doing
from ext.errors import UnexpectedArgument
class LiteralMeta(type):
"""A metaclass for custom Literal"""
def __getitem__(self, item):
self.values = item
return self
class Literal(metaclass=LiteralMeta):
"""A class for custom Literal"""
@classmethod
async def convert(cls, ctx, argument):
"""Converts the argument to any of the exact value given"""
if argument in cls.values:
return argument
raise UnexpectedArgument(f"\"{argument}\" is not a valid argument. "
f"Possible argument(s): {', '.join(cls.values)}")
``` not much
what to see from there most of all?
an answer with 8 upvotes and a green tick
damn that looks complicated. I dont think there's an id attribute
java sucks
ot
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
what id attribute?
ty
I assume that's what you wanted

print(a.id). doubt it though.
async def close(reaction, user):
if reaction.message.channel.name.startswith("ticket"):
wait_for ('reaction')
await reaction.message.channel.delete()
this ??? who ?
no, no...read the docs
What is "ty" ||(i'am brazilian)||
thank you
idk 😦 ask stack
it sucks
oh ty
I know how it feels
What you tryna do?
did you use LiteralMeta
just trying to create roughly the same thing as typing.Literal
damn
but why tho 

I'm not using v2.0 so typing.Literal isn't supported yet
*and don't force me to use 2.0
use 2.0
no u
or just read the code for typing.literal
😭
do you think I will make 100 codes just for one thing?
....yes? 🤣
No idk the answer, try claiming a help channel 😦
okay wait
is it possible to make an account a bot
No
thats where you are wrong
Don't tell me u writing 100 lines 😐
nah
Not u
Self Botting is against ToS, so I didn't talk about it (:
nah
I know my answers, thanks
19
Oh, hmm. That's viable
guess who just got banned from anime subreddit
you?
self botting is against the ToS of discord.
yeah "viable"
Fun fact: There are OT channels for these sorta talks
Better than writing 100 lines tho
!ot
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
is there any other library for making discord bots other than discord.py
yeah
Its using the ID of the metaclass
pycord, disnake (i think) and nextcord...these are a few
i forgot the name tho
those are forks of discord.py
: |
i will never understand typing stuff ¯\_(ツ)_/¯
How do I make my bot down like be invisible
change_presence I think 😦
it will go down eventually
Oh ok
it'll go down soon
ihl shfrkrg rsjpijs sojf
Hmm ok then
how do i get the profile pic url of the message author?
str(message.author.avatar_url)
ok
Wrong
Wrong for 2.0
If u r using 2.0, then message.author.avatar.url
ok ty
Yea
how do i start a thread on a message?
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
pass per to 15
Ignoring exception in on_ready
Traceback (most recent call last):
File "d:\dittttbeta\env\lib\site-packages\discord\client.py", line 359, in _run_event
await coro(*args, **kwargs)
File "d:\dittttbeta\database\prefix.py", line 19, in on_ready
await aiopg.create_pool("dbname=prefix user=postgres password=083806637610")
File "d:\dittttbeta\env\lib\site-packages\aiopg\pool.py", line 296, in from_pool_fill
await self._fill_free_pool(False)
File "d:\dittttbeta\env\lib\site-packages\aiopg\pool.py", line 332, in _fill_free_pool
conn = await connect(
File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 65, in connect
connection = Connection(
File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 746, in __init__
self._loop.add_reader(self._fileno, self._ready, self._weakref) # type: ignore
File "C:\Users\andan\.pyenv\pyenv-win\versions\3.9.6\lib\asyncio\events.py", line 504, in add_reader
raise NotImplementedError
NotImplementedError
Exception ignored in: <function Connection.__del__ at 0x0000020EC7AE2040>
Traceback (most recent call last):
File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 1140, in __del__
self.close()
File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 961, in close
self._close()
File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 945, in _close
self._loop.remove_reader(self._fileno)
File "C:\Users\andan\.pyenv\pyenv-win\versions\3.9.6\lib\asyncio\events.py", line 507, in remove_reader
raise NotImplementedError
NotImplementedError:```
why is this?
how do i add a timestamp to an Embed?
!d discord.Embed.timestamp
The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.
@opal skiff ^
ok ty
Ok thanks
await message.channel.send(embed=discord.Embed(color=0xe74c3c,title="Poll",description=message.content.replace("T!poll",""),author=message.author).set_author(name=message.author,icon_url=message.author.avatar_url).timestamp(datetime.datetime)) it doesnt work
ok ty
TypeError: '_EmptyEmbed' object is not callable i get this error with discord.Embed.timestamp(datetime.datetime.now())
oh wait
what's the code you put?
await message.channel.send(embed=discord.Embed(color=0xe74c3c,title="Poll",description=message.content.replace("T!poll",""),author=message.author).set_author(name=message.author,icon_url=message.author.avatar_url).timestamp(datetime.datetime.now()))
<@&831776746206265384>
is this for a command?
Thanks 👍
yes
can i see the whole command? Just curious
should @unkempt canyon filters the link and auto ban them?
await message.delete()
awaitpoll = True
await message.channel.send(embed=discord.Embed(color=0xe74c3c,title="Poll",description=message.content.replace("T!poll",""),author=message.author).set_author(name=message.author,icon_url=message.author.avatar_url).timestamp(datetime.datetime.now()))```
is there any way to get from last command specific message part?
oh and if message.author == client.user: if awaitpoll: awaitpoll = False await message.add_reaction("👍") await message.add_reaction("👎")
whats your bot prefix?
It does, that just happened to be a link we haven't blacklisted yet
T!
so why aren't you using the dpy's commands?
oh i see
idk i just like it more to code without it
It's been blacklisted now btw. Thanks for the ping
👍
don't use on_message event for commands
it's not efficient
i´m fine with that actually
