#discord-bots
1 messages Β· Page 671 of 1
honestly idk. If they are default emojis I just pass it in as is. "βοΈ"
How do I do it then?
Depends if you can ig
I mostly do it like that
you can't copy emojis in like that
they are default discord emojis
Copy them off the internet
I GOT A NEW ERROR! thats a success in my book, but now i need help with this new one lol
Send
@sage otter if it says channel has no attribute 'send' as the error, what should i do to this piece of code to fix it
Why dont you just send the msg with the channel of the context that was invoked?
You can do \emoji which returns a emoji you can copy and paste, E.g \βοΈ
\π
i could, but sort of like with dyno, i want to be able to specify from one channel another channel to send an announcement to if possible
andy
It will probably say nonetype if you dont add anything
do you know how to subclass on_message in subclassed discord.ext.commands.Bot with it acting as a listener and commands still work?
from disnake.ext import commands
from disnake.ext.commands.bot import Bot
class On_ready(commands.Cog):
@commands.Bot.event()
async def on_ready(self):
print("hi")
def setup(bot: Bot) -> None:
bot.add_cog(On_ready(bot))
wont work, any1 help?
why doesnt this work
@tasks.loop(seconds=75)
async def live_status():
pcount = pc()
Dis = self.client.get_guild(876471014043815966) #Int
activity = discord.Activity(type=discord.ActivityType.watching, name=f'π {pcount}')
await self.client.change_presence(activity=activity)
await asyncio.sleep(15)
activity = discord.Activity(type=discord.ActivityType.watching, name=f'π₯ {Dis.member_count}')
await self.client.change_presence(activity=activity)
await asyncio.sleep(15)
activity = discord.Activity(type=discord.ActivityType.watching, name=f'NOT lowkey#0669')
await self.client.change_presence(activity=activity)
await asyncio.sleep(15)
activity = discord.Activity(type=discord.ActivityType.watching, name=f'City of lights')
await self.client.change_presence(activity=activity)
await asyncio.sleep(15)
activity = discord.Activity(type=discord.ActivityType.watching, name=f'DISCORD INVITE')
await self.client.change_presence(activity=activity)
await asyncio.sleep(15)
tf you doing here
from disnake.ext.commands.bot import Bot
tf you mean?
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
its this, and you dont just import it, you need to pass it through bot.load_extension(...)
bruh 
Its on_ready idk if its case sensitive
@slate swan see this is what i want it to do, and it successfully gets the announcement command, but it wont send because its not getting the channel correctly
My man, I import it to typehint the the bot parameter since Disnake want is, the load extension is in my main file
the class name can be uppercase
My bad and why did you named the class on ready lol
a) its @commands.Bot.listener b) the imports wrong afaik c) incorrect naming conventiosn
I was looking at the class name
!d discord.ext.commands.bot.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
wtf lol
u can copy the unicode for the default ones by typing \:thumbsup: or any emoji name
?
Bro you're confusing between forks
I'm not using the fork made by rapptz
There's allot
there is nothing wrong with the imports at all, it's the event listener im having issues with, and there is no @commands.Bot.listener in disnake
Why not just do ```py
async def on_message(self, message: discord.Message) -> None:
# do stuff here
super().on_message(self, message) # calls the superclasses on_message
So you would end up doing stuff, but then also having a regular on_message?
do commands still work like this?
If you just want commands to work you can just add await self.process_commands(message)
To the on_message
No need for calling the superclasses on_message
So your using disnake and dpy πΆ
Wait nvm
yeah but thats messssssy
I need glasses
Just do what you feel like would work then Β―_(γ)_/Β―
okimii, i decided to switch to what you said, which is just use the context of the channel to send, but now, when i try to mention the role, it wont let me. this is the error i get
how?
role: discord.Role
oh, ok, thanks
Precisely.
now what @sage otter π€£ sorry for bothering you so much btw
How are you using the command
Remove role
ok
IT WORKED
THANK YOU SO MUCH
oh man that is sweet, thanks a ton
@sage otter one more question, its not super important, but the thing you told me to do with the role where i set it role: discord.Role... can i do something similar with the channel, like idk channel : discord.Channel or something like that?
Yes
how would i do it
ok, let me go try that... ill brb
IT WORKED @sage otter I CANNOT THANK YOU ENOUGH
thanks so much for helping me this morning
π
How do I fix this?
member_role = ctx.guild.get_role(916843979411185674)
await ctx.channel.set_permissions(member_role, send_messages=False)
Command raised an exception: InvalidArgument: target parameter must be either Member or Role
yeah it came back as none
I have this for intents tho?
import discord
from discord.ext import commands
from discord import Intents
intents = Intents.all()
intents.members = True
bot = commands.Bot(command_prefix=".", intents=intents)
I got another question if you are willing to try right now
how would i make the role argument optional @sage otter
Default it
how lol
ok, ill try that, thanks
Hey, how can I solve this?
File "main.py", line 19
await ctx.send(f'Banned {member.mention}')
^
IndentationError: unindent does not match any outer indentation level
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
#help-mushroom OOF
@sage otter like this?
How to solve this problem? I typed this and it showed errors:
@lost vine do you know how, in this code, id set role to default or role = None?
I think you should set it to None because the bot can be confused when you set default role because many people will have different roles
how would i do this?
role arg will be None
when you call the command you add the role obj
how would i type it so it doesn't trigger a SyntaxError
@slate swan Can you help me with this?
role = None ig
it will always be None
for this, maybe try context=f'<your stuff here>'
idk for sure though
its a Nonetype arg
so okimii, how would i set it so that sometimes i can set a role to ping, but i dont have to?
idk why both of you are getting syntax errors when its correct
Oh yeah Okimii. Professional helper.
if you want it sometimes you can add a value of None or make kwargs
no
For real
really stupid i think you ment
Omg donβt tell me you're using IDLE
LMAO
I might actually lose it if you are.
I'm using replit
agreed!
keep in mind though, im trying to keep it so that it says its discord.Role
now what...
says it in the error lol
just add the positional arg on front and make all of them kwargs after
i know, but i still want to keep it there when im typing the actual command. Is that possible?
what is the if > < >= <= sign for "under ---" i forgot
wdym?
Are you asking what they are for?
kinda basic its like math lol
Like I even used command prompt to run the program and this error is still there
im asking like which one is it for "under (number)" for if statements because i forgot
check indentations again
Oh
how do that π€£ ?
<
Here is the part
Less than operator.
you add the positional arg on front?
how thoughh
anyone know how to create a paginator with reactions and not buttons
async def banhammer(ctx,member: disnake.Member,reason=None):
see how the arg that is None is in the back
not sure if this will even work but
else: is having an error
if bot.latency * 1000 < 300:
embed = discord.Embed(color=discord.Colour.green())
embed.add_field(name=":WS: Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
await ctx.send(embed=embed)
else:
embed = discord.Embed(color=discord.Colour.red())
embed.add_field(name=":WS: Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
await ctx.send(embed=embed)```
so how would i do this with the ping and stuff
@slate swan @boreal ravine pls help

@slate swan Thank you so much I can now fix my error. Take a cookie
as a gift even when it isn't real lol
Why do you ping random people to help....?
||Cause of simp|| jk
#help-lemon OOF
@tawdry perchpls help
||buddy
||
Why did you pong me..
...
hey can we get attachments url from slash commands?
someone help pls
Have you indented the else statement?
yes
@bot.command(name="ping")
async def pingme(ctx):
# ws ping
if bot.latency * 1000 < 300:
embed = discord.Embed(color=discord.Colour.green())
embed.add_field(name=" Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
await ctx.send(embed=embed)
else:
embed = discord.Embed(color=discord.Colour.red())
embed.add_field(name=" Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
await ctx.send(embed=embed)
thx lol
!paste can you paste your code here so I can view the indent properly @slate swan
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
you need an indent after else:
and your if has to be connected with the else
Command raised an exception: TypeError: Subscripted generics cannot be used with class and instance checks```
!resources before dpy
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
what's your code?
Here is the command: ```py
@commands.command(
name="SetRange",
brief="Choose a lucky number between a range of values."
)
@commands.has_permissions()
async def set_range(self, ctx, *, range):
if range.startswith("random"):
return await self.set_number(
ctx.message,
ctx.channel.id,
range
)
minimum, maximum = [int(float(value)) for value in range.split("-")]
await self.set_number(
ctx.message,
ctx.channel.id,
[minimum, maximum],
range=True
)
await resources.default.embed(
msg=ctx.message,
title=f"**The range has been set to {minimum}-{maximum}**"
)```
range seems to be a normal keyword
try naming your variable something else than range
lmao ihacu

ok where??
which line?
in your function's parameters
this dude looks like he's tryna get spoon fed
and where you use it
ahh so in this part:
async def set_range(self, ctx, *, range):
if range.startswith("random"):```
your if has to be connected with the else
The help embed is becoming a bit too large, I have ~borrowed yeeted a paginator from someones repo that I have used to embeds but how can I paginate a help embed? Current help command ```py
class MyNewHelp(commands.MinimalHelpCommand):
"""Bots help command class"""
async def send_pages(self):
destination = self.get_destination()
for page in self.paginator.pages:
emby = disnake.Embed(description=page)
await destination.send(embed=emby)
everything between if and else has to be on the same indent, one level above the if
im confused, what am i supposed to change because the lines are already togther
I think it should be something else than MinimalHelpCommand
hm?
like PaginatorHelpCommand or smth, I don't know the name
@slate swan here?
there aswell
Where should I look it up?
dn
if bot.latency * 1000 < 300:
embed = discord.Embed(color=discord.Colour.green())
embed.add_field(name=":WS: Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
await ctx.send(embed=embed)
else:
embed = discord.Embed(color=discord.Colour.red())
embed.add_field(name=":WS: Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")```
can you just copy the lines where I need to change "range"?
like this
oh why doesn't this work
every line where you have range
https://paste.pythondiscord.com
can u type it here
but it isnt a variable
how
you want it to be a variable
but variable names can't be keyword names
k let me see
maybe just HelpCommand?
Imma search after it
I saw that used in @unkempt canyon, and thx if you mind to search it up π
the minimalhelpcommand does have a paginator attribute
hi
good news, no errors and the first part works
bad news, no errors but the else: doesn't send an embed 
and what's the issue?
how to convert this
oh well put the ctx.send after the if and else statement
so it will send the embed whatever happens
it's my bad
im bad english sorry for my warnings
oh you use disnake
is disnake very different from dpy?
oh god I found a really complex github repo
oh wow
and he isn't even subclassing the help command
how should I start creating a pagination for help command
I'm gonna cry
I'm new to datetime so I don't know how to convert it to the format I want
I remember when I made my own without subclassing π
my help command still isn't subclassed
oh
and I can tell you the worst part
Do I want to hear it π
I'm storing my commands' data in a .txt file
oh god
I'm grabbing every command's name and description in a text file
I'm outt
and the required permission too
but I have a reload cogs system and the help command only updates when the whole bot restarts 
that's where you see, that sometimes, I can't think straight
Β―_(γ)_/Β―
oh..
Consider looking at this gist
it seems really nice
.bm A really good explanation of help command stuff for discord bot

π₯ 
*Infinite Dad Jokes, ACTIVATE
BOT
Yessiree
I fear for the calendar, its days are numbered.
I fear for the calendar, its days are numbered.
I fear for the calendar, its days are numbered.
I fear for the calendar, its days are numbered.*
@client.event
async def on_message(message):
if message.content.startswith('Infinite Dad Jokes, ACTIVATE'):
await message.channel.send('Yessiree')
if message.author ==client.user:
await message.channel.send(dadjoke.joke)
time.sleep(10)
So basically it's supposed to send out a random dad joke from dadjokes library every 10 seconds, based on responding to it's own messages. But it sends the same dad joke over and over again

it took me a while to realize there was a gif
!blocking
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!
Concurrency in Python
Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.
This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.
To call an async function we can either await it, or run it in an event loop which we get from asyncio.
To create a coroutine that can be used with asyncio we need to define a function using the async keyword:
async def main():
await something_awaitable()
Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function
To run the top level async function from outside the event loop we need to use asyncio.run(), like this:
import asyncio
async def main():
await something_awaitable()
asyncio.run(main())
Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().
To learn more about asyncio and its use, see the asyncio documentation.
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [Whatβs New in 3.10βs Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
ima die while working with that, I can do it, but I will die
Best to make it a custom task as well.
There are some examples so you should be getting started pretty fast :D
I don't understand how asyncio sleep fixes the bot sending the same joke
No it stops the bot from dying since it will actually stop the whole bot.
Please read this.
how can i send a dm to specific user using id?
No you literally pause the bot so you cannot type any commands anymore while that is running. As for the dad joke you'd need to save it in a var to keep sending the same one.
Get the user then .send() on the user object
it's from the dadjokes library
!d discord.ext.commands.Bot.get_user
get_user(id, /)```
Returns a user with the given ID.
can i use bot.get_user?
Yes that is the usage.
!d discord.ext.commands.Bot.fetch_user I recommend this as a backup.
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.
Cache system is kinda flawed.
I know but you need to save the joke you have gotten so you can re-use it.
How can I make the bot send a png picture that's in a specific path?
Use the relative path.
./subfolder/file.png
but what is the function/method called to upload a file image as a message?
It's a kwarg of .send()
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
something like discord.File("")
!d discord.File indeed
file != image though?
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
Huh Disnake doesn't have that? π€
Oh lemme search that doc 1 sec
It's the same as in disnake but discord == disnake
!d disnake.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://docs.disnake.dev/en/latest/api.html#disnake.File "disnake.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://docs.disnake.dev/en/latest/api.html#disnake.File "disnake.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") objects. **Specifying both parameters will lead to an exception**.
class disnake.File(fp, filename=None, *, spoiler=False, description=None)```
A parameter object used for [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send")s.
but this has a description too
disnake IS better lol
but idk where that description is shown
i think it embeds it and makes a description idk
Not much info on it in the docs
!d disnake.File.description
The fileβs description.
New in version 2.3.
Argument of type "str" cannot be assigned to parameter "file" of type "File" in function "send_message"
"str" is incompatible with "File"
Show the code?
The fileβs description.
for file_name in os.listdir("exts\\utils\\imagine_img"):
await inter.response.send_message(file=f"exts\\utils\\imagine_img\\{file_name}")
Where is exts?
you can't do that
why not?
inside "cogs"
file takes an actual File object
isnt it file = disnake.File("")
class disnake.File(fp, filename=None, *, spoiler=False, description=None)```
A parameter object used for [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send")s.
fp == file path
Also sending images quickly will rate limit you pretty quick.
do you mind sending docs of ratelimiting
kinda lazy lol
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
I just send one, since there will only be one image
Sorry question, how do you color text in discord to make it look like code?
thank you my good sir will read them later
Use kwargs files and not file
files (List[File]) β A list of files to upload. Must be a maximum of 10.
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
No documentation found for the requested symbol.
Thankies
I mean tbf we don't see anything you are doing lol
ye
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 413 Payload Too Large (error code: 40005): Request entity too lar
Max 10
max 10 of what?
images?
Images aka files
there is only one image..
Over 8MB?
maybe size then?
Yea
oh so it cant be over what size?
Anything over 8mb is a nono
alright, ty
8mb as panda said ^^
tbf 8mb image is almost 8k lol
google_crawler.crawl(keyword=keyword, max_num=1, max_size=), do I set 8 or 0.8?
I have no idea what this code is.
Module?
class Imagine(commands.Cog):
@commands.slash_command(description="Returning a image with related to the keyword that has been provided")
async def imagine(self, inter: AppCmdInter, keyword: str):
google_crawler = GoogleImageCrawler(storage={"root_dir": "C:\\Users\\truth\\Skrivbordet\\bot\\exts\\utils\\imagine_img"})
google_crawler.crawl(keyword=keyword, max_num=1, max_size=8)
for name in os.listdir("exts\\utils\\imagine_img"):
print(name)
file = disnake.File(f"exts\\utils\\imagine_img\\{name}")
await inter.response.send_message(file=file)
def setup(bot: Bot) -> None:
bot.add_cog(Imagine(bot))
I still have no idea what module this is.
Not sure, set it to 8 if it takes the size in MBs?
OK then, is there a way to have a bot rerun itself?
lemme try
Most likely it will take KB
return max(sz1) <= max(sz2) and min(sz1) <= min(sz2)
TypeError: 'int' object is not iterable
yeah, no idea though I've never used google crawler
class Imagine(commands.Cog):
@commands.slash_command(description="Returning a image with related to the keyword that has been provided")
async def imagine(self, inter: AppCmdInter, keyword: str):
google_crawler = GoogleImageCrawler(storage={"root_dir": "C:\\Users\\truth\\Skrivbordet\\bot\\exts\\utils\\imagine_img"})
google_crawler.crawl(keyword=keyword, max_num=1, max_size=8)
await inter.response.send_message(files=[disnake.File(f"exts\\utils\\imagine_img\\{x}") for x in os.listdir("exts\\utils\\imagine_img")])
def setup(bot: Bot) -> None:
bot.add_cog(Imagine(bot))
still gives the same error lol
max_size don't take a int apparently
Is the file over 8mb?
it can't even download anything atm because of the error
Can you show the module that you are using?
I feel dumb, can't even understand what the error is lol 
from icrawler.builtin import GoogleImageCrawler
!pypi icrawler
Don't worry, you can share the error and the code
This docs is like solve x in nothing or decrypt the answer lol
Oh shit i got it working
is that even shitable
scary
When it works but you don't know why it works 
lol
google_crawler = GoogleImageCrawler(storage={"root_dir": "C:\\Users\\tisgot20evrsen\\OneDrive - Thorengruppen\\Skrivbordet\\bot\\exts\\utils\\imagine_img"})
filters = dict(size='medium')
google_crawler.crawl(keyword=keyword, max_num=1, filters=filters)
``` I did this
same to you
though the issue here is
if the user searches for porn, a porn image will pop up.
lol
So now every channel officially has to be a NSFW channel.
my bad
!d discord.TextChannel.nsfw
If the channel is marked as βnot safe for workβ.
Note
To check if the channel or the guild of that channel are marked as NSFW, consider is_nsfw() instead.
!d discord.ext.commands.is_nsfw
@discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.
This check raises a special exception, [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
Wouldn't work anyways
You are not allowed to use that command here. Please use the #bot-commands channel instead.
Im thinking of downloading a file with every possible nsfw word, and use that to see if the keyword the user enters is not there
or just not care if they send somethign nsfw Β―_(γ)_/Β―
This so impossible
Yeah but ALL the words is basically impossible like a swear filter it just isn't 100%
The Snowgiving 2021 server has 4400 server boosts lol
oof
Lol
Anyone know client.guilds.cache.size in python form from js
!d number of cached guilds
how did you manage to fix it?
will aiosqlite stop database locking in adiscord bot?
with open("file", "w") as f:
json.dump(....,f ,indent=4 )
```now how to delete that (the things u dumped in that file)?
#help-burrito OOF
You're mixing spaces with tabs probably
You can select the spaces and change it manually; tabs and spaces show up differently (spaces show up as dots) a
Or change all indentation to either spaces or tabs (ctrl + shift + p then search for the command)
nope I tried that
ExtensionFailed: Extension raised an error: AttributeError: 'Group' object has no attribute 'cooldown' cooldown not working for group-commands?
or should i use @commands.cooldown() ?
@dejay.cooldown(1)```
dosnt work
or should it be dejay.commands.cooldown()?
How can i make custom help command?!?!?

Ah sorry loll
Things to do while asking for help
1. Code
2. Error
3. A brief explanaion of what you're trying to do```
Did you try running the code
Don't know if this is count's as a discord bot but I'm trying to make a FB chat bot and it won't work.
Nvm f it.,
As far as I remember, i retyped the whole file Use orettier code formatter
Prettier*
This should be pinned
But it wont be pinned unless a staff member is pinged
Awww
Write a whole essay
wait here
look at the pins, they all long as fuck
hold my juice
lol
Iβm about to type a 500 word essay about posting a question and hopefully the mods will like me
A guide for how to ask good questions in our community.
@velvet tinsel
Damn
Imagine reading this
Reading what
Guide to ask questions
Imagine
subclass?
When someone mentions the bot it should send the prefix, but when someone mentions the bot with text it shouldnt say the prefix how would i stop this from happening
in bot
do you mean override?
same shit different terminology
would i do if msg.content == "<@id>"?
yes
okay ty
ik this is off topic but i just saw this color them extension in vsc its actually really good lol
=> https://marketplace.visualstudio.com/items?itemName=kuscamara.electron
very clean ngl
so you know its off topic but you just decided to say it anyway
yeah
very colorful lol
how would i make it so that if it has extra content like eg a command, it wouldnt work
eg. @bot help
you just do this if msg.content == "<@id>"
oh ok tysm
because if they add more shit it wont be equal
just do
bot = commands.Bot(...)
def my_after_invoke(self, coro):
# do stuff
bot.after_invoke(coro)
bot.after_invoke = my_after_invoke
``` or
```py
class Bot(commands.Bot):
def after_invoke(self, coro):
# do stuff
super().after_invoke(coro)
``` this?
tysm
its fine i did it in a similar fashion - ```py
class Bot(commands.Bot):
def after_invoke(self, coro):
# do stuff
super().after_invoke(coro)
any error?
What exactly are you expecting?
after_invoke only simply, sets the after_invoke method of the bot
its okay i just looked at the source code and realised it can take coro arg
What is difference when using command.Cog and commands.Bot
what
Uh.. for cogs you always use commands.Cog, right?
yeah
?
Oh I was just curious was this for cogs as well because it was class
But now I got it
is there a way to get a Member object from their id?
guild.get_member(id)
thx
datetime.fromtimestamp(int(spec_list[counter][2])).strftime('%d/%m/%Y')
is this the correct way to format unix time to a day month year
spec_list[counter][2] is a string for a unix time stamp
Yes
it doesnt work
Ignoring exception in slash command 'ahhistory':
Traceback (most recent call last):
File "C:\Users\Vader\PycharmProjects\pythonProject1\venv\lib\site-packages\disnake\ext\commands\slash_core.py", line 569, in invoke
await self(inter, **kwargs)
File "C:\Users\Vader\PycharmProjects\pythonProject1\venv\lib\site-packages\disnake\ext\commands\base_core.py", line 187, in __call__
return await self.callback(self.cog, interaction, *args, **kwargs)
File "C:\Users\Vader\PycharmProjects\pythonProject1\taskscog.py", line 224, in ah_history
f"{datetime.fromtimestamp(int(spec_list[counter][2])).strftime('%d/%m/%Y')}",
OSError: [Errno 22] Invalid argument
Most likely the timestamp is incorrect
how do you make a bot that stores user information in a json file
Ex. @pine sluice have 5 coins, how can I code it so that it can find how much coins I have by accessing the json file and displaying it using a command?
no the timestamp is just a unix number
Don't store info in a JSON file
Is it in ms or seconds? Is it a decimal?
Use what then?
seconds
A proper database
Try it with ms and see if that works
1589095799115
what should it be
oh
Divide by 1000 and int() it
If you divide it by 1000, you get 5/10/2020, 1:29:59 AM
You can test UNIX timestamps here on discord for example
(int(1589095799115) / 1000) ?
<t:1589095799:F>
<t:1589095799115:F>
:O da future
Yes about 50,000 years in the future
Correct
;-; rn its only <t:1639260727>
wait how did you do that timestamp
<t:TIMESTAMP:FORMAT>
No it's gotta be a UNIX timestamp
<t:20000000000000000>
;-;
<t:20000>
the past
bruh
how can I take the time that's right now
Count
Jk, use this: https://www.epochconverter.com/
<t:1639260930>
Yeah...
ye that's correct?
no my code
That's how you do it
<t:1639261017:F>
that's how it's done in the US too
yeah
strftime('%d/%m/%Y') = month day year yep
that's day month year
descending order
odd
i thought eu does ascending lol
oh wait %d is month
guess i was wrong
https://strftime.org/ @verbal cairn
A quick reference for Python's strftime formatting directives.
it's 2021-12-11 for me π€·
and I live in northern europe
idk ig
all ik is formats are different in other parts of the world lol
whats the problem?
So I have a command and I check if the argument provided is falling under the NSFW content (i have made a list of string myself), and if it does I don't wanna send a message but a response to the slash command that it's nsfw content, do u understand what I mean? Like, when u use slash commands I've seen other bots respond in a way but not through a normal message.
How do you DM everyone with a bot?
and also how do you DM everyone that is online with a bot?
You don't, API limits
no with a very small private server
Ik you can prob do it using a for loop but idk what to do after that
fuck it ill help
I wouldn't
Not sure about other libraries but in discord.py, it's just interaction.response.send_message()
!d discord.Guild.members || py for member in guild.members: #where guild is an instance of `discord.Guild` -> can be gotten by `ctx.guild` or `bot.get_guild(guild_id)` if str(member.status) == "online": #checks if they are online with `discord.Member.status` await member.send("Hello") #await discord.abc.Messageable.send -> same as doing `await ctx.send` seeing as they inherit from `discord.abc.Messageable
property members: List[discord.member.Member]```
A list of members that belong to this guild.
!d discord.Member.status
property status: discord.enums.Status```
The memberβs overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
!d discord.abc.Messageable
class discord.abc.Messageable```
An ABC that details the common operations on a model that can send messages.
The following implement this ABC...
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
@pine sluice all these are links to the docs where you can read more about what I have done here
he said its a private server so i'm giving him the benefit of the doubt
- if he does this on servers his bot will just get kicked
It may be used for ToS breaking purposes as we don't know what he's really doing with it. This falls under the rule that was provided:
Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
can anybody help me?
Ask your question π
so i'm trying to connect to the db but it says connect is undefined , how to define it?
sqlite3
Hey I got a question when a member agrees to rules on a specific channel how do I make the bot say. (member.mention) role has been added message?
from sqlite3 import connect
!d discord.Member.mention || do you have the member instance?
shouldn't use the sqlite3 library in a bot (it's blocking)
use an async wrapper around it such as asqlite
property mention: str```
Returns a string that allows you to mention the member.
worked thanks
Wdym member instance?
do you have your variable with a member stored? like ctx.author or smthin?
Nope but I will do that when I get home and get on my computer
Not a python thing afaik
More dpy
But is related to classes
am I dumb or am I dumb
embed = Embed(color=#20d4b7)
π΄οΈ
makes a comment, how tf am I supposed to add color to my embed
ah so the 0x acts like #?
Get the hex color and add 0x to it
disnake.errors.InteractionTimedOut: Interaction took more than 3 seconds to be responded to. Please defer it using "interaction.response.defer" on the start of your command. Later you may send a response by editing the deferred message using "interaction.edit_original_message"
Note: This might also be caused by a misconfiguration in the components make sure you do not respond twice in case this is a component.
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: InteractionTimedOut: Interaction took more than 3 seconds to be responded to. Please defer it using "interaction.response.defer" on the start of your command. Later you may send a response by editing the deferred message using "interaction.edit_original_message"
Note: This might also be caused by a misconfiguration in the components make sure you do not respond twice in case this is a component.
bruh why did I get these errors? does it take that long to create a embed lmao
if you ever want to add the same color to everything just subclass ctx.send or edit discord.Embed source code
be an alpha
@commands.slash_command(description="Returning a image related to the keyword that has been provided")
async def imagine(self, inter: AppCmdInter, keyword: str):
google_crawler = GoogleImageCrawler(storage={"root_dir": "C:\\Users\\OneDrive - Thorengruppen\\Skrivbordet\\bot\\exts\\utils\\imagine_img"})
filters = dict(size='medium')
google_crawler.crawl(keyword=keyword, max_num=1, filters=filters)
embed = Embed(color=0x20d4b7)
file_name = ""
for name in os.listdir("exts\\utils\\imagine_img"):
file_name += name
file = disnake.File(f"exts\\utils\\imagine_img\\{name}")
embed.set_image(file=file)
if keyword not in NSFW:
await inter.response.send_message(embed=embed)
os.remove(f"exts\\utils\\imagine_img\\{file_name}")
else:
if inter.channel.is_nsfw():
await inter.response.send_message(embed=embed)
os.remove(f"exts\\utils\\imagine_img\\{file_name}")
else:
await inter.response.send_message("NSFW is not allowed in this channel!", ephemeral=True)
this is the code
how to define?
make a variable
how lol
What
by not copy and pasting π
right.
ty - you've literally got 4 undefined variables
i only see 2
reason db c
member is defined
Why is embed = Embed?
you need to use kwargs for defining the embed if that's what you mean
I fixed it though
Yes but what are you defining?
wdym?
embed = Embed(color=0x20d4b7)
Is a embed object
Its disnake.Embed since your using the Embed class from disnake
I obv did
from disnake.embeds import Embed

ImagineπΆ
though I have an issue with sending the embed
embed = Embed(color=0x20d4b7)
file_name = ""
for name in os.listdir("exts\\utils\\imagine_img"):
file_name += name
file = disnake.File(f"exts\\utils\\imagine_img\\{name}")
embed.set_image(file=file)
file.close()
got no error at all, but it sends a empty embed
and the file path is correct since I tried this without the embed, and it sends the image
Whats disnake?
Dpy fork
a dpy fork
u should switch to a newer fork Β―_(γ)_/Β―
Nah i gave up with discord api
Im into web dev now
Hit me up if your bot needs a website
haha I might need a website once the bot is released π€·
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
What am i missing?
how are we supposed to know lool
literally show me how to learn , all these video are just showing how to make a bot , i want some help on that, even if i copy pasted most of it i modified that thing for over 8 hours straight
the point is that you dont just jump straight into discord.py - it is moderately advanced, you need to learn the easy basics before proceeding
π€«
lmao
why is it so hard to make a uptime command in py
its not.
it is
its extremely easy
f"{bot.uptime}" isnt a thing is it?
no
you just do bot.launch_time = datetime.datetime.utcnow() and then ```py
@commands.command()
async def uptime(self, ctx:Context):
delta_uptime = datetime.utcnow() - self.bot.launch_time
hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
minutes, seconds = divmod(remainder, 60)
days, hours = divmod(hours, 24)
return await thebed(ctx, '', f"I've been Up since **{days}** Days, **{hours}** Hours, **{minutes}** Minutes, and **{seconds}** Seconds!")
ignore indents fuck discord
ay thats thw same way i did it
oh
thanks
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'datetime' has no attribute 'utcnow'
try from datetime import datetime
Importing datetime would be good
i imported datetime
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'launch_time'
can someone help me alter my modmail commands so it only allows 1 channel to be opened per person
shoot
Hey @flat flower!
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:
yea sometimes I just forget
ok
I highly suggest using a db for this stuff, you could also not, but I'd like you to for maybe future code
Very nice
you don't want to implement the bad way, always go for the best
best way: add every member to the db that uses the modmail: have a column with a "isAlreadyBusy" boolean thingy in it
if that's true, you can just skip that member
else, create a new modmail
is it possible without a db
yes, but that's a bad way
that would be a json as config file, and if your bot would be used in multiple servers it could possibly corrupt your json, you don't want that
you don't want to do it bad and then rewrite, if you do it good on the first try, you won't have to spend extra time
since if it goes wrong, you'll curse at yourself
no, use an async wrapper of a db
will your bot be used in multiple guilds?
asynpg will be the db for you then
*asyncpg
that's an async wrapper of the postgres db
you'll need to learn basic sql after setting up the db ofc
for setting up a db, I'd suggest you to go to the discord py server, that question gets asked daily there
have a step-by-step guide of how you want things to go, you don't want to set up a db and be like "what's next?"
gl!
How can I make my footer in a embed a link?
How to create on_reaction_add multiple times so that there were no errors?
emb.set_footer(text=f"text",url=f"url")
nope wont work in disnake
disnake?
yeah it's a new fork to dpy
Not really new lol
well maybe not new but it's up-to date
Correct.
Explain?
embed.set_footer(text="Redirect to Wikipedia")
this is what I've got, I want the "redirect to wikipedia" to be a link
I tried doing [thingy](link) but that didnt work
Ah
Idk if footers can do that
Hi, what to put in argument allowed_mentions so the bot cannot ping everyone?
Thats not possible
Yeah i thought so
Nvm I found out
i cant seem to find yellow
and when i put yellow is also said no such color
Yellow isnt a color
Just use a color hex
yesterday when i did that i got told to make an entire db for a color hex
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
You can .bm if you want
Pretty handy
there's no yellow
Try out gold or just find the color hex for yellow
Then do yellow = 0x00000 and replace 000000 with the hexcode
#FFFF00
0xEFFF00
Is a bright yellow
is light_yellow a thing
No
Its red grey blurple green
C:\Users\ADMIN\PycharmProjects\Fluxo\main.py:21: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
embed = discord.Embed(color='0xEFFF00'())
pls spoon feed me on this part
No need for ()
.red() contains the red hex
Its how that works
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Expected discord.Colour, int, or Embed.Empty but received str instead.
hey I just created a script that is working in my console that will print out what I want, how would I go about putting this into discord. It only needs to print something out every maybe 5 minutes or so
do u want it to be a command or just constantly do it every 5 minutes in your specified channel
Remove the ' around it
0x0 is a type of integer
constantly every 5 minutes to a specific channel
In particular a hex
anyone know a 6 digit hex to 8 digit hex converter?
faa61a i need to this be 8
i think you just add two 0s
at the start or end
end
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'FAA61A00' is not defined
oh wait
its going to be 6 because you forgot to add 0x
should be 0xFAA61A
Ah
Whys my slash command instantly saying it failed? There is no error and I havent changed something great in my code only changed a variable
Even if that was the error, This Interaction Failed wouldnt instantly show up but after a few seconds
But it instantly shows up
I also restarted the code and also my discord
Weird I added just a random message being sent at the beginning and now it works!?!?!?
But I dont want that second message
Ok now I removed it and it doesnt work again
I dont understand...?
have you tried doing the command with a user by any chance?
What do you mean
whats the command for?
To start a battle
Takes no arguments
Only /battle
ah i see
It worked before
Until I changed a variable which is only for display purposes
hm
what is this var?
It calculates how many gold or xp you get
Before Ive set both to 0
Now its...
xp_gain = enemy.hp / enemy.damage
gold_gain = enemy.damage * random.randint(2,5)
And as you see in the first Image Ive sent it totally works fine
how do i set category of a command or add a special attribute?
bot.command() # how specify category
i tried using category kwarg
how do i make a slash command?
in my discord bot
this is a very basic "test", but it doesn't do anything
as usual, idk what im doing wrong
@slate swan how make slash command work 
when you put @client.command(), in parenthesis you can put description='...'
ill show an example
@slate swan
brief is like a shortened version of your full description. description is what shows up when you run !help <command>. For this example, just let the ! be your command prefix
yeah
if you want them to have a description
lmao, idk to be honest
its up to you i guess
NP
Keep the description brief
@final iron can you try to help me with my issue
idk how experienced you are
how get this to work 
I have only worked with dpy so I wont be able to help
oops, wrong thing
oh, ok
@client.command()
async def get_meme(ctx):
print("In here")
memes_submissions = await reddit.subreddit('memes')
#memes_submissions = await memes_submissions.hot()
post_to_pick = random.randint(1, 10)
submission = next(x for x in memes_submissions if not x.stickied)
print(submission.url)
await ctx.send(submission.url)``` Anyone know why this isnt working? Its running but wont return anything when I run !get_meme
do you already have a command called coinflip? this error could occur if you have multiple of the same name
how do i add a special attribute on bot.command()?
you should try that, and tell me if it gives you the same error
do you have multiple async def coinflip() commands?
to be honest, im not sure what exactly is causing that error
dont make multiple commands with the same name
yeah
also, how do i add a special attribute to a command in bot.command()
I should be using asyncpraw for a discord bot that gets reddit posts correct?
edit the source code
yes
just say multiple commands? why say async def?
Subclass commands.Command and set the cls kwarg to the subclass in the command deco
Override the init of the command class to set the attribute (remember to super init, though)
whats wrong?
so basically...
im trying to make a slash command, and its not necessarily triggering any errors, more or less its just flat out not working
what lib are you using
here, ill send a screenshot of the libs that go with the slash commands...give me one sec
@boreal ravine could you take a look at this and see if you can see anything wrong with it? ```py
reddit = asyncpraw.Reddit(
user_agent="Hello There)",
client_id="CLIENT_ID",
client_secret="CLIENT_SECRET",
username="USERNAME",
password="PASSWORD",
)
@client.command()
async def get_meme(ctx):
print("In here")
memes_submissions = await reddit.subreddit('memes')
#memes_submissions = await memes_submissions.hot()
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = next(x for x in memes_submissions if not x.stickied)
print(submission.url)
await ctx.send(submission.url)```
@boreal ravine
show me the slash commans
this is the only one ive attempted so far
No idea, haven't really used asyncpraw before. Are there any errors
do you have application commands scopes in your bot?
no, how would i set those
@boreal ravine None, it just wont return a reddit post back to discord. Doesent throw any errors
developer portal > ur bot
ok, im there
ok
now where
try printing memes_submissions
where you click the bot scope, click the application commands scope then re-invite your bot
!d discord.ext.commands.Command
class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.
These are not created manually, instead they are created via the decorator or functional interface.
is it the thing that says bot permissions? @boreal ravine
try it and see
no
^
enable it the same place you enabled the bot scope for your bot
@boreal ravine It just returns "memes"
@boreal ravine the slash command still isn't showing up
sure
show me what it prints
Memes submission: memes
can you show me an ss?
ss? substring?
screenshot
top right
Oh
the one below that
applications.commands?
then re-invite your bot with those scopes



