#Basic Pycord Help (Quick Questions Only)
1 messages · Page 92 of 1
why not just message.author.roles?
This doesn't work
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User \AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 399, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\Projects\server\bot.py", line 45, in on_message
message.author.roles and not "text" in message.content.lower():
AttributeError: 'User' object has no attribute 'roles'```
Do is not None, not not is None
Or just do if message.guild, that already does is not None implicitly
Or just do
if message.guild, that already doesis not Noneimplicitly
More likeNoneis a falsy value, and guild objects aren't
Is the member not in the guild? Might want to check that first. Or change it to a fetch
If you're in a dm guild will be None
Yeah, I know, but None is a falsy value, that's why this works
yes
The error appears when the role is issued and removed on the server and sending a message with the role
I don't understand, an error is thrown every time something happens on the server
"something happens"?
Someone enters and exits the voice channel, any role is removed and given
The error I posted above appears
All because of this part of the code
Without it, everything works as before
Is that the up to date version of your code?
Wdym?
Is this the code that your bot's running or did you change it since then
Code:
@client.event
async def on_message(message):
if message.guild and discord.utils.get(message.guild.roles, id=1131159247879680021) in \
message.author.roles and not "text" in message.content.lower():
await message.delete()
await message.channel.send("Wrong form.", delete_after=10.0)
I don't think its Replits issue (Will be not using Replit soon)
But the command is not showing the limit option in the command
Can you show your pip list
.tag slashnoshow
Application Commands Not Showing Up?
- Uninstall libraries that conflict with the
discordnamespace (e.g.discord.py). - Invite your bot with the
application.commandsscope. - Load cogs before
bot.run()(e.g. not inon_ready). - Do not override
on_connect. - Update to the newest version of
py-cord(see?tag install). - Turn off
User Settings > Accessibility > Chat Input > Use legacy chat input. - Share your code and errors.
Also Ensure that you do not have multiple of the same bot running.
I think replit sometimes can glitch and keep an old program running
I'm quite new to python in general, but have programmed a few basic commands into my bot. right now I'm having issues implementing a 1-day cooldown into a couple commands. I try to add a cooldown according to the pycord documentation, which only includes 2 parameters, but things I read elsewhere ( I think from last year's API redesign) refer to a third parameter that pycord docs do not. I also might be missing something completely basic... a nudge in the right direction would be much appreciated.
discord.Option is giving some sort of error, what error is that?
That is not how you create the slash command group
yes it is
should be commands.cooldown instead of economy.cooldown
I've added like 7 different slash commands this way... not saying you're wrong
commands refers to discord.ext.commands
Does both works?
?
from discord.ext import commands
^
add that ^^
yes
should I be doing things the way Zerv referenced?
before I continue diving down this rabbit hole of coding, I mean.
no?
Okay, just wanted to be sure... like I said very new to coding, didn't know if that was a best practice thing or something
Thank you very much for your help, I'm getting different errors now, so progress is happening, I'll be back if I need help

Can't see command
Says pip is not a command
add python folder to path variable
How?
try pip3 list
Doesn't work
^
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.8/site-packages/discord/client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/discord/bot.py", line 1164, in on_connect
await self.sync_commands()
File "/home/ubuntu/.local/lib/python3.8/site-packages/discord/bot.py", line 738, in sync_commands
app_cmds = await self.register_commands(
File "/home/ubuntu/.local/lib/python3.8/site-packages/discord/bot.py", line 531, in register_commands
prefetched_commands = await self._bot.http.get_guild_commands(
File "/home/ubuntu/.local/lib/python3.8/site-packages/discord/http.py", line 365, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
i made my bot use cogs and it worked on a smaller version but now i put it on the main version and it gives me this
google just says enable applications.commands but i already had slash commands so idk why it broke
re invite the bot with application cmds scope in guilds
🤔
Ensure that the bot is in all guilds with the IDs in guild_ids and debug_guilds
Package Version
----------------- ---------------------
aiohttp 3.7.4.post0
async-timeout 3.0.1
attrs 22.1.0
chardet 4.0.0
idna 3.3
multidict 6.0.2
pip 23.2
py-cord 2.4.1.dev85+gd519e951
setuptools 57.4.0
style 1.1.0
typing_extensions 4.3.0
update 0.0.1
yarl 1.8.1```
And you are sure that you are not in a DM?
@client.event
async def on_message(message):
member = await message.guild.fetch_member(message.author.id)
if not member:
return
if message.guild and discord.utils.get(message.guild.roles, id=1131159247879680021) in member.roles and not "text" in message.content.lower():
await message.delete()
await message.channel.send("Wrong form.", delete_after=10.0)```
can you try this @candid coral
Yes
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 399, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\Projects\server\bot.py", line 44, in on_message
member = await message.guild.fetch_member(message.author.id)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\guild.py", line 2034, in fetch_member
data = await self._state.http.get_member(self.id, member_id)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 367, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10013): Unknown User```
New error ✨
Appears under the same conditions as I described above
Then I will move it all to my PC
@client.event
async def on_message(message):
try:
member = await message.guild.fetch_member(message.author.id)
except:
pass
if not member:
return
if message.guild and discord.utils.get(message.guild.roles, id=1131159247879680021) in member.roles and not "text" in message.content.lower():
await message.delete()
await message.channel.send("Wrong form.", delete_after=10.0)```
@candid coral
don't use bare except 
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 399, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\Projects\server\bot.py", line 48, in on_message
if not member:
UnboundLocalError: local variable 'member' referenced before assignment```
Are you by chance testing in a private channel?
Do you mean the bot doesn't have access to it?
He has admin permission
Nevermind then
I'm confused...
Do you mind creating a help thread and showing all of your code. minus commands
Consider @client.event and Cogs?
all events. Cogs minus the commands
so only if you have other stuff in the cog
There are only commands
ok then just the main file with all of the events and set up code
Why not? I don't care what the actual exception is here
you could save a whole 2 lines by returning in the except instead of using an if statement 😎
Pop
@client.event
async def on_message(message):
member = None
try:
member = await message.guild.fetch_member(message.author.id)
except:
pass
if not member:
return
if message.guild and discord.utils.get(message.guild.roles, id=1131159247879680021) in member.roles and not "text" in message.content.lower():
await message.delete()
await message.channel.send("Wrong form.", delete_after=10.0)```
@candid coral
mypy is complaining
NoneType cannot be casted to Optional[Member]
Then you write it
oops I forgot the /j
This might not be the right place to ask but.
Is there a way I can get the date someone left the server my bot is in?
Oh you want a if message.guild above all of that actually
not natively
You can in on_member_leave but not if they already left
This would work with what I've got setup thx
how does this work
i want to have a group of items
like a list of items with back button that gives me another set of items to add in my view
that's the base class for ui elements
use ui.Button or ui.Select instead
i use those as of now but i need a way to wrap up multiple ui.Item in one group so i can change/switch with a button which set of items i need
how can i achieve that?
i dont want to switch views everytime i want to go back to previous set of items?
how would i check if a user (by id of user) has an role
Hi guys, if i pass parameters through the view like in the attachment will it cause some troubles like two peoples using this view with different param and it mixing it up?
https://docs.pycord.dev/en/stable/api/ui_kit.html#discord.ui.View.remove_item
https://docs.pycord.dev/en/stable/api/ui_kit.html#discord.ui.View.add_item
However it would just be easier to have 2 different views. ext.pages could help with this too.
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, timeout. Methods cls View.from_message, def add_item, def...
First, User refers to an entire discord account. Member refers to a profile per guild.
You would need to get the guild and then the member via https://docs.pycord.dev/en/master/api/models.html#discord.Guild.get_member
Then check https://docs.pycord.dev/en/master/api/models.html#discord.Member.roles
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
.rtfm bot.get_guild
To get the guild by id ^
No because you are creating a new instance of the view (or should be). I suggest you read up on OOP (object oriented programing)
Is there a way to add one more button in bot profile? Not just invite to server
Possibly via the activity ("Now Playing: ...")
But no way to do it easily
Ty so much
nono like dyno bot. It have one more button
I will look in a couple minutes
okay
The extra button is a built in discord feature. I dont think it is public for all bots and It would only be able to be used to buy premium through discord. You could not make it do whatever you wanted.
ahhh okay
How can I send a ephemeral message when someone click the button?
Just set ephemeral = True in interaction.response.send_message
await interaction.response.send_message("blank", view=MyView2(), ephemeral=True)
this is my code but still not working
when i set ephemeral to False i see bot is responding to it self
Sorry, I have to go. If you could post the entire callback to the button that would be great. Someone else should be here to help in a bit.
Somehow my problem solved, but thanks anyway
I'm using on_message to read every message, but it only can see my messages and its self
Do you have the message intent enabled both in the bot and in the developer portal?
Yes i have all of the intents enabled
and you do set the intent in you bot?
like discord.Intents.all() or something that includes messages?
Yes discord.Intents.all()
What happens when other users send a message? Do you get an error, or just nothing?
Just nothing
Can you show how you create the Bot object?
Also show the contents of your event
Ok ill put it in a pastebin
Why would user.mutual_guilds not be showing all the guilds I have in common with the bot?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
you have intents here and here?
Its becuase its passing in intents through the abot class to the discord.Bot class from a differnet file. The one in all caps is from another file
Why are you getting message.channel when you can just do message.channel.send?
^ When I have the message content intent and the guild members intent
Where?
Line 44
await bot.get_channel(message.channel.id).send(f"Message by {message.author.name} translated\n{content}\n{translated}")
You’re getting the channel you already have

I didnt notice that
I think I've fixed it, it wasnt an issue with my code. It was an issue with the config.json file im getting data from
button event handler ?
yes
yes
i tried it the problem is timeout in view
i remove all items from the view on_timeout function
so if i have 2 or more view the timeout of the first view affects the 2nd view and removes all components from message
and that is why i don't use that way
and im currently make it work by adding and removing items
What about it?
Check in the dev portal. You might have forgot to save or something.
somthing like this in pycord?
You can try calling view.stop() on the view before switching.
This should cancel the timeout
like i have some view variables that i want to access can i still access them even after i stop it?
You should still be able to. That way would only work for having 2 views though. Not changing the components of the original.
I dont think there is a public class for it. All components have the row kwarg that allows tlyou to order the components.
im in need of more than 2 views tho that why i thought if i have some way to wrap up certain group of components together i can just add them to the main view instead of adding each component individually
I meant 2+ views.
Changing the components of a view constantly just does not make a lot of sense. It makes more sense to create a new one than remove then add.
i will try it thank you
Can the components of multiple active and persistent views have the same custom_id? As long as they refer to the same class it should be ok, right?
using custom id
I have seen that in the documentation you can set the default permissions when creating the group but I don't understand how it works. I only know how to do it in the method itself.
ban = SlashCommandGroup("ban", "Commands for ban a user from the server",
guild_only=True,
permissions=["administrator", "ban_members"])
In def
@guild_only()
@ban.command(name="add", description="Ban a user from the server")
@discord.default_permissions(
administrator=True,
ban_members=True
)
def metod
.rtfm on_button_click
Target not found, try again and make sure to check your spelling.
Everything goes through on_interaction
if i use
@commands.Cog.listener()
async def on_interaction(self, interaction):
if "custom_id" in str(interaction.data):
...
it will mix all buttons callbacks toghether
Do I have to use discord.Option(int) or will a simple int also do the job?
both should work
ok, but obviously Option should be used when passing a choice or autocomplete or description etc
can i have an answer pls
The intention of the component system is to use callbacks, not handle them through events
How to add options?
Here's the slash options example.
thanks
Is it possible to have different command descriptions for dms and guilds?
nope
😢
Look at the example
Here's the confirm example.
what's the best way to add checks in a cog to all commands?
using cog_check
and how can I use the commands.checks in there?
Attributes description, qualified_name. Methods cls Cog.listener, def bot_check, def bot_check_once, async cog_after_invoke, async cog_before_invoke, def cog_check, async cog_command_error, def cog...
like commands.has_role
commands.has_role(...).predicate will return a function which you can call
so basically
ok thanks
return await commands.has_role(...).predicate(ctx)
I was looking for that
smth on those lines
It works. Thanks!
So many problems from one call message.author.roles...
I think I'll create a support ticket
Because of this, the bot does not respond to commands. I'M ANGRY
😠
You need to call process commands if you override on_message
How can i do this?
.rtfm process_command
^
Should I just insert await client.process_commands(message)?
.tias
It works, thank you a lot
What is the best way to store time information?
unix time as an int or a string
someone worked with odm beania?
I recently decided to start learning it
Is there a way to use a discord.Option with a bridge command?
how would I go about doing that? currently I have this
@bridge.bridge_command(name="test")
async def test_command(self,
ctx: CustomContext,
user: Option(
User,
description="Target User",
required=False,
) = None):
This is currently not working when i use the non-slash command and I get this error Converting to "Option" failed for parameter "user"
what is CustomContext?
And User?
CustomContext is just
class CustomContext(BridgeExtContext):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.chain_id = uuid.uuid4().hex
and user is discord.User so "from discord import User"
Try using the decorator version
@discord.option("seconds", choices=range(1, 11))
async def wait(ctx: bridge.BridgeContext, seconds: int = 5):
Brige has always been buggy tho
awesome! it worked thx for the help
Can you use FlagConverters in slash commands to avoid duplicating sets of args across several commands?
When I try to do this, I encounter a...
TypeError: Flag.__init__() got an unexpected keyword argument 'name'
anyone ever done a on error, send webhook to channel?
This thread is meant for general help.
If you need deeper library help, please create an own thread.
Keep the #help-rules in mind, or you might not receive any help.
not first
is it possible to execute an async function in a cog (which is in an extension) when it is loaded?
asyncio.run?
Is there any examples or anything of how to create options in cogs tried a couple examples and none are working
thanks
thank you very much!
however I also have to wait for the bot to be ready and when I execute bot.wait_until_ready() I get an error RuntimeError: Task got Future <Future pending> attached to a different loop
this is an asyncio error and I can't manage to solve it
i think i will make a thread for this
New General help huh
I want to make a terminal / console command but i do not know how i can manage to get this to work.
I want to make a simple terminal command that sends a message in a specific channel. Any solutions for this?
Yes
python3 main.py
are you joking?
ocess_commands
if message.author.bot:
AttributeError: 'Command' object has no attribute 'author'
is there a way to manually raise a commands.CommandError? i forgot if it's possible or not and i'm not sure how to do so in the api docs, trying to make my error handlers rn
Is there a way to access to a message's view?
message.components (req. message content intent, btw)
it has ActionRow instance, not the View itself
ActionRows have the buttons and selects
Yes, exactly. But I'd like to access the View to call the stop() method to stop the view
how can i format a date to be like " blank days ago"
(datetime.now() - old_date).days to get the days
doesnt work
duration = (dt.now() - author.joined_at).days
I think you need to use datetime.now(timezone.utc) of course add the timezone import from datetime
um ok
doesnt work
sup guys, whats the best practice when using OptionChoices with a lot of options without hard coding it? is there an example anywhere? couldnt find one https://docs.pycord.dev/en/master/api.html?highlight=choices#discord.OptionChoice
this isnt the place to ask that as that's not related to pycord.
Is this related to my question or something else?
Something else
^
^
What do you mean hard coding. What options are you trying to display?
like i have 25 choices for one option and multiple options, i dont want to create an Optionchoice object for every choice i have, it takes way too long and there must be an easier way, thats what i am asking for, if anyone has an example on it or knows a way to do it
It is not required to make them into OptionChoice objects. You can just pass a list. Unless of course you need localization or alternate values.
Option(choices=["hi",])
Other wise you would need to use a for loop or something if you need localization or values.
i need alternate values, thats why i'm using it. i know i should do it with a loop, but i cant pass a loop in the parameter, so how should i do it? thats why i'm asking for the best practice (if there is one)
i will find a way to use it for sure and it will work, but i'm asking for a best practice
Where can I find info about subclasses & classes?
I think you could do a simple for loop
choices=[]
for i in range(len(names)):
choices.append(OptionChoice(name, value))
Like in general for python?
The code above could be even more condensed im sure.
For Python please
https://youtube.com/playlist?list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc
Episodes 1 and 4 are what you want specifically but I would watch them all.
*List comprehend
Ty btw ^
Anyone know how I would go around trying to create top.gg vote logs?
is it possible for 1 option in a slash command to effect the content in a different option?
(i.e option 1 can give 3 different sets of options for option 2)
at that point you should just use buttons
for this use case buttons wouldnt be way to messy visually
you can use autocomplete
https://github.com/Pycord-Development/pycord/blob/283db543c267d0ec51526b17a5728bed4d6516fe/examples/app_commands/slash_autocomplete.py#L110
look at the function at line 110
examples/app_commands/slash_autocomplete.py line 110
async def get_animals(ctx: discord.AutocompleteContext):```
thanks
wat
anyway is it possible to compare 2 PermissionOverwrite?
I know it is possible with Permission but I tried with PermissionOverwrite and it didn't work
select menus then
I guess i can use python's issubset() for tuples but is there a more elegant way?
anyoneee?
in slash options can a option be coloured like a role option?
I found a 7 month old question about listeners and the say, the limit of them is 25. I tried to find that information in the pycord docs and didnt find it, am I just blind or was the limit removed?
it’s 25 on the discord docs, py-cord just doesn’t state that anywhere.
oh, ok
thanks
Guys how do I show my bot is using pycord in #creations
is it the total limit of any listeners or can i have like 25 on message listeners and 25 on ready , etc?
Little stuck, getting this error:
async def airingsub(ctx, method, args):
File "C:\Users\nicho\PycharmProjects\Rimuru\ve1nv\lib\site-packages\discord\commands\options.py", line 312, in decorator
type = type or func.__annotations__.get(name, str)
AttributeError: 'BridgeCommand' object has no attribute '__annotations__'
i guess you can just type there something about your bot
you can have as many as your machine can handle
@silver moat Your an expert at these kinda things, do you know anything about this?
@discord.option(name="method", choices=[OptionChoice(name='example', value='example'), OptionChoice(name='example2', value='example2'), OptionChoice(name='example3', value='example')], description="Choose the method")
They removed it because they said they can't tell if it uses pycord lol no reply either
did you send there a github link or is your bot open source?
It's not open source that might be why
well then ig you have to options, somewhere publish the code, so they can verify its made with pycord or dont use that channel
read pins: #creations message
#help-rules §2
what do i need to do buttons?
?tag guide
So I have heard that mongodb is slow on python, are there any alternates data base or should I stick to it?
The execution time for that is around 4 seconds which is a lot
postgres, mysql, sqlite are all great choices
How’s the execution time on them?
depends on your implementation
If any of them are better in terms of speed I’ll take it
Well I’m using db to store user id and their balance when they do certain action
And when I do say /work
It takes around 4 second to finish executing
First to run through the docs to check if the user id is stored in there
And then sends in F in the channel
I used to use mongodb and never had that problem
Imma try a different way and see if it’s fixed
It shouldn’t take that long
Sometimes it’s also wherever the db is located
what mongodb wrapper are you using
I local host mine so latency shouldn’t be a problem
Discord bots are asynchronous so I recommend motor
Mine is on a cloud on Ireland and I’m in England
Sure I’ll use that and let you know
Motor is a module right for thr synchronous
yes
I use motor and its not slow
if you store the id as an int, it will be slower than the id as a string btw
Is motor inside the asyncio module?
how do i send an image through replit files?
The same way as if your files were in your file system
That’s like that regardless of your IDE/host.
You either have to send it as a file or have no other content besides the link.
hello its 3:30am im at my last straw but want to get atleast something running, why arent the slash commands showing up when i try to post them in my server?
i know its probably shitcode but im very new
the top image is the main file
that is not how you load a cog (unless the file is literally called "SimpleCommands.py")
It is
And in async def quote you need to do self.get_quote because there is an error there.
Oh wait, I didn't even see the error, thanks
Huh wait why self.get_quote? That's the name of the command iirc
Did you invite the bot with the application.commands scope
yeah
Check if they are working in dms
Nope
Imma get a good sleep and look at it tomorrow again. I think I'm missing something basic but I'm too tired too see it, thank you anyways though
with modals, Can you specify input type? (eg. string, int)
pretty sure that's a no
I seem to have a problem with persistent views. Below is my code and i think it should wprk but still when i restart the bot the buttons wont work. Can someone help me find the mistake as there isnt any error too.
class Myview(discord.ui.View):
def __init__(self, timeout=None):
super().__init__(timeout=timeout)
class testbot(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
self.bot.add_view(Myview())
@commands.command(name="test")
async def test(self, ctx):
view = Myview()
b1 = Button(label="test", style=discord.Buttonstyle.grey, custom_id="test1")
view.add_item(b1)
async def b1callback(interaction):
await interaction.response.send_message("HI")
b1.callback=b1callback
await ctx.reply(content="Button test", view=view)
with modals, Can you have the user choose from a list of prefined options
how do i edit a interaction that has already been responded to?
What's this?
AttributeError: 'Member' object has no attribute 'add_role'
can someone help?
async def on_member_join(member):
guild = bot.get_guild(998188595372367913)
channel = guild.get_channel(998218612848459877)
embed = discord.Embed(
color=0x3498db
)
embed.add_field(name=f"Someone Just Joined This Server !", value=f"**Welcome To Server {member.mention} !**")
embed.set_image(url="https://media.giphy.com/media/AFdcYElkoNAUE/giphy.gif")
await channel.send(embed=embed)
role = get(member.guild.roles, id=998469564289536061)
await member.add_role(role)```
I want to make a restart command, does Client.close() also logs the bot out so I can Client.start() after that ?
U can do this it doesn't even exist in pycord so 
how can I get the traceback in on_application_command_error ?
Hi i was wondering if any one has any code or advice on the guilds.join endpoint in pycord/discord api and if any one had any packages that could help a user join a server when they add a bot
What is the best way to handle the "Not connected to voice" error, when the bot is connected to voice? Like how do I reconnect the best way?
Discord only has 2 valid inputs for modals. Short text input and long text input. We are as disappointed as you.
This is from my code. Traceback is imported as s base lib.
wdym?
Dangit forgot to paste the code lol
"".join(traceback.format_exception(type(error), error, error.__traceback__))
so if i use this inside an on_application_command_error event i can get the full traceback ?
Full traceback including the error I belive.
Like automatically join the user to a guild when they add the bot? That is not possible (if it is it is against TOS). You could send an invite when the bot joins the guild.
I copied from my github, I guess they added some characters for styling. :/
You could check the voice clients is_connected() method or you could try and except that error and call connect again.
some people did say that it doesn't matter and it's efficient to store the data as int instead of having to cast it all the time
Uhhh, got a little problem. Is it just me or does command cooldowns not work at all (prefix commands and slash commands) when client = bridge.Bot?
how are you using the command cooldown?
async def on_application_command_error and on_command_error
They worked originally when I didn't switch to the bridge system on the client
But no errors in the console are spouted, like its ignoring the cooldown completely for Bridge
Im getting this JavaScript error when I run my bot
@loud holly Any ideas? (*)
Doesn't look like I'm doing anything incorrectly
are you using bridges?
Bridges? I'm using bridge, yup
yeah bridge* lemme check the docks
lol autocorrect moment
Thanks, please let me know what you find, I've tried looking but ....kinda didn't find much
I'm a bit confused what's the difference between bridge and commands
Bridge is prefix + slash
So e.g. if I had a command called .hello, I could also do /hello
ohh
try doing the inconvenient way of

....manually coding a cooldown system?
wait no that won't work
I keep getting a JavaScript error when I try to run my bot
this is what I have found
Nothing on cooldowns 😓
try doing
do Bridge. and then scroll down onto the options until u see cooldown or something related to cooldown
For pycord, is there an async for ....a check before a command is executed?
Had a look, there's nothing 😓
WHAT
Cooldown works in my main.py file! But not in cogs
I keep getting a java script error in my replit discord bot whenever I try to run it
what error
You've been saying this more than 3 times, for anyone to help it'd be good if you mentioned what error 😓
Idk
I’ll not at my computer
But it’s like <JavaScript> html error something with weird numbers
you prob got ip banned
?tag replit
Read this to find out how you can install Pycord in replit - https://namantech.me/pycord/installation/#replit
How to install the Py-cord library - Pycord Guide
oh oops
You should not use Repl.it to host your bot.
While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:
-
The machines are super underpowered.
-
- This means your bot will lag a lot as it gets bigger.
-
You need to run a webserver alongside your bot to prevent it from being shut off.
-
- This isn't a trivial task, and eats more of the machines power.
-
Repl.it uses an ephemeral file system.
-
- This means any file you saved via your bot will be overwritten when you next launch.
-
They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
Please avoid using repl.it to host your bot. It's not worth the trouble.
See ?tag vps in testing if you want a list of decent hosts (there are no free hosts).
easy fix tho just go into shell and type kill 1
does anyone have knowledge in mongodb itself? I have been running in runtime error and that the insert_one does not have await when it does have await into it
@bot.slash_command()
async def work(ctx):
Mongo_DB = Client["Folder"]
Collection = Mongo_DB["Collection"]
async def do_insert():
document = {
"__id": ctx.user.id,
"Balance": 100
}
await Collection.insert_one(document)
Loop = Client.get_io_loop()
Loop.run_until_complete(do_insert())
await ctx.respond("Hello")
I have defined Client (in case you were wondering)
This async function of do_insert() works when I remove the async def work and only keep that async function with no issue

Tried to put it into a synchronous function, same error
What does that mean?
read what i said underneath
I’m confused
Install pycord fixes up bans?
no
Oh
just go into shell and type kill 1
I’m on chrome book
So replit is the only one I can use
Ik how to kill the thing
I’ve been using replit for years and this has never happen
can i use embed.set_image() with a file on my pc?
@fervent cradle btw you have any idea on why I'm getting the error that I am?
I dont use mongo im sorry
ah no prob, it says runtime error which I'm confused on, well I guess time to use txt files
I used await since it is async but idk
i believe squid uses the same lib as I do, so he knows it better
https://stackoverflow.com/questions/72568802/mongo-db-runtime-error-because-of-connection-is-closed-too-early this might help?
yes, it's in the docs faq
oh im blind
There's a way of sending the file on discord, and then clicking on the image and then viewing on the tab, copy the link on the tab and put it in the set.image and it should work
embed.set_image(url=f"attachment://temp/1689945.png")
would work?
nope, it should be attachment://(filename)
welp
and it has to be the same filename as the file you upload
can you send the imagine over here?
file = discord.File("path/to/my/image.png", filename="image.png")
embed = discord.Embed()
embed.set_image(url="attachment://image.png")
await channel.send(file=file, embed=embed)
no?
like you see in the code one thing is creating the File and the other one is accessing the attachment
create the file object
with the directory and the file
then in set_image you put attachment:// and the file name without the directory
and then in the message you send the embed and the file
i'm not sure tbh since i did evrything on it there ty 4 the help
I found the issue at why it's happening and it's here, I wonder if the Client variable is colliding with the pycord word?? I don't think it should
How can I make the output of fetchall a list?
It is so called a list but the content is in () which I don't want.
Can anyone help me?
nvm I think I did it woohooo
nice
oh
yeah however there's still the error of runtime which it does add data to the db
but you can't do anything after the loop.run...
the autocompletion example on github shows how to make option choices dependent on other options, is it possible to do that also if there is no autocompletion context because i dont want to use autocompletion?
then use normal options?
b!rtfm pyc discord.Option
first one
Yeah, I’m using normal options, but my question is how I make the second option choices dependent on the first option choice selected?
try flipping the options in the example to your liking and seeing if that works
guys im at my pc now
<script>(function(){window['__CF$cv$params']={r:'72cca4a41ca05fce',m:'74hOO.IvYVzl.0V8igG5_LF2EGBEpQavKHTsoNmHRKI-1658162258-0-AXrbXOJ9pCArUb2WO21FC3vxo2+9jhMC4bOEmWwYHtaQ+Xz1vI3iM7SOwikcpfjzid3geud4p0NIUINZfPGm3EffLuucc+mkcjh8TsUL8rN6DlR6opXS2G0aATs973TPKOegqSLW2LQDIbhFkvVnxEs=',s:[0xe2c0873413,0x4a0765fba0],}})();</script></body>
</html>
that's html and js
can i define a chennel by its name?
what does that mean
cause if i want it in multiple servers its gonna be dificult
I don't know what you mean by this
i have it currently that it defines a channel by the id, but if its in a different server its gonna say that there isno channel with that id
a channel
channel = bot.get_channel("departures")
like that
dude
@bot.event
async def on_member_join(member):
channel = discord.utils.get(ctx.guild.channels, name=given_name)
db[f"{member}"] = "none"
await channel.send(f"{member.mention}, Take Off Granted, Happy Trails! ")
await member.send(f"{member.mention}, please type your Sky Warriors In-Game Username - !SetUser (In Game Username)")
it says ctx is not defined
member,guild
oh ok
It should be a string :0
it says departures is not defined
oh
departures = "departures"
channel = discord.utils.get(member.guild.channels, name=departures)
like that?
yes
Hi, i would like to send an ephemeral message to someone who gives a reaction, but i can't seem to let it work. Can someone help me?
Ephemeral messages are only possible with interactions.
So a reaction is not an interaction?
A reaction event is not an interaction
Ok thanks
if my bot says this error , does it mean it got banned?
Traceback (most recent call last):
File "D:\p-bot-2.0\venv\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "D:\p-bot-2.0\venv\lib\site-packages\discord\bot.py", line 1041, in on_connect
await self.sync_commands()
File "D:\p-bot-2.0\venv\lib\site-packages\discord\bot.py", line 643, in sync_commands
registered_guild_commands[guild_id] = await self.register_commands(
File "D:\p-bot-2.0\venv\lib\site-packages\discord\bot.py", line 472, in register_commands
prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id)
File "D:\p-bot-2.0\venv\lib\site-packages\discord\http.py", line 354, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access```
- Update py-cord
- Invite the bot with application.commands scope
i have both, i had no problems until i did something sus with the bot (which i did like 5 minutes ago)
what did you do?
well i created and deleted a bunch of channels
like in hunderts
on my testing server
that's not a problem
and created thousands of webhooks
yeah that's fine
one server started telling me internal server errors when i tried to edit a channel
one of the testing servers
Is there a way to handle all button clicks in a function? like on_message or on_member_join but for interactions specifically buttons
on_interaction?
Ohhhh that's the one, sorry came from discord components
no problem
I would probably let the bot rest for a day and if it doesn't work, feel free to come back
so if it is ok, then i have the version 2.0.0 and i am sure that it was invited to all the servers with that scope
oh ok
Hey squid, for the motor module that you're using
are you using asyncio or the tornado one?
I'm using asyncio
but it's really just preference
I'm using asyncio because I've been used to it in other projects
what is it?
@bot.slash_command()
async def work(ctx):
Mongo_DB = Client_Link["Folder"]
Collection = Mongo_DB["Collection"]
await ctx.respond("Hello")
async def do_insert():
document = {
"_id": ctx.user.id,
"Balance": 100
}
await Collection.insert_one(document)
Loop = Client_Link.get_io_loop()
await Loop.run_until_complete(await do_insert())
you didn't need to make it a loop
since you are in an async
so just
await do_insert()
so I'd use that only if I want to add in more data?
instead of ```py
Loop = Client_Link.get_io_loop()
await Loop.run_until_complete(await do_insert())
if you are in an async environment, yes
Hmmm, I think I understand???
hey, i found out that my bot is functioning normally, but it only once when started send the error. Right before this happened i deleted one of the testing servers the bot was on. Can that be the problem?
yeah
because if one of your guild_ids were that guild
that error would happen
how can i fix this? or will it fix automatically after some time?
ok so lemme get it straight,
since I'm already in an async I don't need to add the in loop
however if I'm not in an async function like the discord command is above then I need to use the loop?
yes
If you are in a non-async environment and this still occurs, install nest_asyncio
default 'except:' must be last
how do i make commands not case sensitive?
b!rtfm pyc commands.Bot
discord.ext.commands.Bot
discord.ext.commands.Bot.activity
discord.ext.commands.Bot.add_application_command
discord.ext.commands.Bot.add_check
discord.ext.commands.Bot.add_cog
discord.ext.commands.Bot.add_command
discord.ext.commands.Bot.add_listener
discord.ext.commands.Bot.add_view
discord.ext.commands.Bot.after_invoke
discord.ext.commands.Bot.allowed_mentions
read
cant u just tell me?
?tag nohelp
Nobody helps you? See #help-rules §2, then you know why.
#help-rules Rule 4
nvmd i figured it out
Hello, I need someone to show me how to add simple button to a command in a normal file not a cogs file.
please and thanks
Hello, i am having an issue with getting the image to post in the embed, it posts them separately. ive looked it up everywhere and it all days to do this but it just doesnt seem to work
embed = discord.Embed(title="Squad Maps", color=color)
embed.set_footer(text=f'Created By {me} | [ {random.choice(embedQuotes)} ]', icon_url=f"{iconLink}")
if select.values[0] == "AAS V1":
file = discord.File("./assets/maps/Al Basrah AAS v1.png", filename="Al Basrah AAS v1.png")
embed.set_image(url="attachment://Al Basrah AAS v1.png")
await interaction.response.send_message(file=file, embed=embed)
Here's the confirm example.
@fervent cradle
i see ty
figured it. Due to the image names having spaces in it, potentially the most pathetic excuse to not work ever but thas just discord i guess
I'm at a loss,
Why does this cog not load?
It doesnt give any errors on loading it, it just... doesn't do anything...
from discord.ext import commands
from utils import logger
log = logger.logger
class Flare(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.web_server.start()
self.app = web.Application()
self.routes = web.RouteTableDef()
@self.routes.get("/")
async def welcome(request):
return web.Response(text=f"{self.bot.user.name} is Online!!")
self.app.add_routes(self.routes)
@tasks.loop()
async def web_server(self):
runner = web.AppRunner(self.app)
await runner.setup()
site = web.TCPSite(runner, host=None, port=self.bot.port)
await site.start()
@web_server.before_loop
async def web_server_before_loop(self):
await self.bot.wait_until_ready()
def setup(bot):
log.info("Loading Flare Cog...")
bot.add_cog(Flare(bot))
Like, it seems like it doesnt even trigger the setup(), as the info log is empty.
Is there a limit for slash commands?
100 global, 100 server specific
Thanks
what's in your start file?
as u have to tell it to load the cogs in the main file
cu_cogs_extensions = ["flare"]
cu_cogs_folder = "crawler_utilities.cogs"
for extension in cu_cogs_extensions :
bot.load_extension(f"{cu_cogs_folder}.{extension}")
This is not my first rodeo. And all cogs work just fine. It's this specific one that fails to load.
or rather, isn't loading at all, as it's not failing.
New slash commands are not showing. My old slash commands work
global commands take roughly an hour to appear
so in slash commands i have
editlater = await interaction.response.send_message("message here")
it waits ~10s due to processing then
await editlater.edit_original_message(content="Message 2")
And then waits for a response with a limit of 180s
if the user responds it manages to successfully edit the message again by using the same thing however when i try to delete the message when it fails it gives me a error saying unknown message
how would i delete the edited message?
ive tried
n = await editlater.edit_original_message(content="")
await n.delete()
And
await editlater.edit_original_message(content="")
await editlater.delete_original_message()
nvm
it stopped working on the succesfull part iswell
now its
AttributeError: 'NoneType' object has no attribute 'fp'
how would i go about using py-cord in replit
ive installed it in the packages however it keeps trying to install discord.py when ran
selfbots are against ToS
you need to fork an older project (one from before april 2022)
then follow instructions from
No that’s against tos
?tag replit
Read this to find out how you can install Pycord in replit - https://namantech.me/pycord/installation/#replit
How to install the Py-cord library - Pycord Guide
what if i just delete poetry?
it will re-install
time to find that then
Not that
i installed all the packages and then deleted poerty now it works. however. it doesnt load cogs 😭
guess ill have to find a old project
still could use other hosts
Is there a way to use ctx.reinvoke() with slash commands?
Like if you want to override a cooldown if you're the bots owner
i just wanted free hosting lol
i ask for your help once again @storm geode
hi
is it possible to pass information to a view
I have a bot that will generate a view with buttons
ooh
before I even send this
a user fills a form with a link or something
I want to be able to pass the "link" or any piece of information specifically to that button
so if i press get points button
tbh i have no clue
okay , ty tho
i think it shoukd be possible
How can I do that things are suggested there that you can enter?
Here's the slash autocomplete example.
try this @signal stratus
thx
nope but the items can
Can you add a modal in a slash command group? I'm having issues with it
Yes you can
Mine is just saying that the modal class is not reachable
Traceback?
What does VSC say exactly
if i put it in a regular slash command everything is fine
Show full code my man
class DescriptionModal(discord.ui.Modal):
def __init__(self, bot, *args, **kwargs) -> None:
self.bot = bot
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Server Description",value="Your server description\nGoes here",style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(
title="Your Server description is set",
fields=[
discord.EmbedField(name="Server Description", value=self.children[1].value, inline=False),
],
color=discord.Color.random(),
)
await interaction.response.send_message(embeds=[embed])
class Test(commands.Cog,name='Test'):
def __init__(self,bot):
self.bot = bot```
```py
test = SlashCommandGroup('test','Testing command')
@test.command()
@commands.has_permissions(manage_guild=True)
async def desc(self,ctx: discord.ApplicationContext):
"""Sets the description of the server where the command is used"""
async with aiomysql.connect(DATABASE INFO) as db:
db_cur = await db.cursor()
await db_cur.execute("""SELECT * FROM data WHERE serverId=%s""", (str(ctx.guild.id),))
row = await db_cur.fetchone()
if row is None:
await db_cur.execute("""INSERT INTO bdata(serverid)VALUES(%s)""" , (str(ctx.guild.id),))
await ctx.respond('Server added to database. Please rerun the command.')
return
modal = DescriptionModal(title="Slash Command Modal")
await ctx.send_modal(DescriptionModal(self.bot))```
for the emoji parameter of a button, how to get a emoji? I tried :one: but it throws an error
can you add a drop down menuin a discord modal?
you can do anything with a discord bot
i think u need to copy and paste the acctuall emoji
i might be wrong
no you're right
you need to use the raw emoji (on windows 10 press Windows + ., or get some other emoji picker). Custom emoji work as long as you provide the full ID (i.e. :emotename:123456789)
You can get it just doing \:emoji: here on Discord.
is this possible ?
technically yes
but support for it isn't complete yet
think it's broken on mobile
if you do want it you can look into applying ##1419; i wouldn't recommend it for now, but you might enjoy it anyway
I uninstalled Novus and installed Py-Cord for my python interpreter and yet it still thinks Novus is installed and throws errors as if it is:
TypeError: __init__() missing 1 required positional argument: 'command_prefix'
from discord.ext import commands
intents = discord.Intents(messages=True, guilds=True, bans=True, dm_messages=True, dm_reactions=True, dm_typing=True,
emojis=True, guild_messages=True, guild_reactions=True, guild_typing=True, invites=True,
members=True, reactions=True)
bot = commands.Bot(intents=intents)
Any idea why? I had this same issue on my desktop (currently doing the same on my laptop) and I think I just left everything open for a while and it went away...?
Well, you have to provide a prefix...
if you want slash commands you need to use discord.Bot instead of commands.Bot
actually slash commands work with commands.Bot since its a subclass of discord.Bot
its just in case you need to use prefixed commands e.g. developer only commands that won't get added to servers
Yes, but also uses prefixed commands that's why it needs a command_prefix
^ this
Is there an event for when a button is clicked?
on_interaction, but it’s not just buttons
how do you get the button custom_id from an interaction?
i need it specifically from interaction
On a button callback
You also receive button
So you can do button.custom_id
As I said, depends on how you're working with it
interaction.custom_id works the same as button.custom_id
i just suck at using it properly
Whatever you say chief
RuntimeError: Task <Task pending name='pycord: on_ready' coro=<Client._run_event() running at /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py:382>> got Future <Future pending> attached to a different loop
asyncio.run(get_connection())```
heres some more code
await c.execute("CREATE TABLE IF NOT EXISTS config (guildid INTEGER, mode INTEGER DEFAULT 1, premium BOOLEAN DEFAULT false, prefix TEXT DEFAULT null, droprate INTEGER DEFAULT 20, gambling BOOLEAN NOT NULL DEFAULT false, dropamount TEXT DEFAULT '10-15', UNIQUE (guildid))")
async def get_connection():
pool = await aiomysql.connect(host='192.158.229.237', port=3306, user='bot', password=data['dbpass'], db='cratebot', autocommit=True)
bot.pool = pool
bot.db = pool```
with on_interaction how do i get the view object?
How can I make it work without changing the command?
@commands.command(name="8ball")
async def eightball(self...)
Thx :D
yeah, functions cant start with numbers
with the on_interaction event, How do you get if the component was a button?
buttons aren't components
They are
How can I make it so when a new server is joined and the owner enables slashcommands for the bot, how can I add the slash commands without restarting the script? I tried a function but it said pylance couldnt access it or something
Would it ever be possible to have a dropdown menu in a modal
await ctx.respond(embed=embed)
Because you havent respond to the command
how do u make the grey box around your code?
This errors with discord.errors.ClientException: Callback for levelingrewardremove command is missing "context" parameter.
async def levelingRewardRemove(ctx):
print('e')
enableSlashCommands(serverList)```
why does this error appear?
what command are you making for that error to happen?
oh i just figured that out
the dev portal
i have a guild only slash command, but my beta bot isn't in that guild
and i was accessing my beta bot
why does my bot return "the application did not respond" but there is no error in the console
You get a 403 Forbidden (error code: 50001): Missing Access as error?
You might've added your bot in the past without the applications.commands scope.
What to do?
Old way: Re-add the bot with the applications.commands scope.
New way: Since 11/07/2022 discord automatically includes the applications.commands scope in OAuth. You just need to re-add the bot with the bot scope. See [#discord-api-updates@996103073111998544](#discord-api-updates message) for more infos.
you need to respond to the interaction
wdym
umm
like @commands.is_owner
I want to get is_owner from the command
image processing
on_member_join
a different library used for image manipulation
you can use pillow to create that
I have never used it so i cant help
Alr
Ty
All my game teamsters are I’m impressed by my discord bot I need them to be rly impressed what should I do
Teammate*
if i was to move some button classes to a cod do they go in the main class with the commands or are they kept separate
e.g.
class class1(commands.Cog):
class Buttons(discord.ui.View):
or
class class1(commands.Cog):
class Buttons(discord.ui.View):
put them outside the cog is the better practice. I think both work tho.
okie, its just extremely messy having 3 different systems that each have multiple button classes all in 1 file
do you have a recommendation to organise it better?
Put the systems in different files. (You should only have 1 cog per file)
yeah so all of them are in my main file currently,
put each 1 into its own cog?
yes
Project folder
-> cogs
-> cog1.py
-> cog2.py
-> main.py
that is a template for how your file structure should look like
thank you,
btw how would you make persistent views in a cog
would it be the same in the main file but use the listener on_ready to add the views?
yes
perfect, last question sorry but what are the prc files in the pycache folder in my cogs folder for?
Im sorry, but i could not tell you, they dont appear on my bot.
you can typically ignore the pycache folder
Discord is working on this I’m pretty sure.
it's already implemented, just not officially released yet
Yeah
oooo
Aren’t they adding the markdown syntax for role mentions in the fields as well?
there's a PR for it on the github if you wanna apply that, just be warned that it won't work on all platforms so i'd advise against using it for public commands
is there any reason why modals are caped at 5 input fields?
yeah they're supposedly adding various mentions and autocomplete
discord limitation, but if i'm not mistaken paginated modals are also planned
that'll be good
commenting on this, is it recommended to separate the views from the cog file into their own directory?
maybe if you want to reuse the view across multiple cogs? I personally wouldn't though
I think that depends on if you are using the same view template in multiple places.
For example if you have a acept deny view you use in commands across multiple commands a view folder would seem right but if the view is used for 1 commands keep it local
alr alr
@bot.slash_command()
@discord.Option(
"discord_member",
choices=[discord.member],
required=False
)
async def balance(
ctx: discord.ApplicationContext,
member: str
):
I'm confused on what it means by TypeError: issubclass() arg 1 must be a class
async def balance(
ctx: discord.ApplicationContext,
member: discord.member, required=False
):
I tried to do this however the required gets blank and I get the same error
I'm trying to do it like this
nvm figured it out
How do I check if a message is from a follow channel like the one shown in the picture?
i guess you could check if the message has a webhook id
if message.webhook_id is not None:
# do something
if you have other webhooks apart from follow channels you can get the webhook from that id and check the type
What can I add to my bot to impress ppl
Ok, thx :D
anti-spam/nuke ai
thats legitimately effective
Nobody cares about that
What else
idk
nothing is impressive when your name is 0-zone57
personally i would never take that
if you really want to make something impressive, get out there and think about it. this is a help channel for the library
Is there a way to get an api for any mobile game
I can’t find it
sounds like you don't know what an api is
i assume you want to get information from a game
Yes
if the api is private, you'll have to pay to get access to it
Pay who?
the developers
Is there a way to get it
i can't help you much since i don't know what game you want to get the api from
I'm not finding any documentation/api from the game nor the developer, so i suppose that they don't have one
Is there a way to do it without an api?
yes, good luck reverse engineering java
or swift
or some c++
anyways the language wouldn't be python
Is it possible that the bot executes a /command?
bots cannot issue application commands
if the stats were available somewhere on a page but without api, you can make a web scraper to get it for you
ok
but if it's all inside a mobile game in a private database, you're not gonna get it easily
Can i have buttons which do have timeout but they also work fine when bot restarts? In persistent view timeout is kept none but I want to disable the buttons after a specific time that being said they should work when bot restarts
you can make it persistent and then have something that runs view.stop after that time
hey everyone, super quick question, does slowmode affect users when using bot slash commands? (i.e. if I set a 10s slowmode, do users have to wait 10s in between using any form of slash command on that text channel)?
Currently I am just updating the view with view=None is this right practice? Cause i think even though i update the view bot tries to add view again to that message in on_ready function
pretty sure it is effectively bypassed
ah okay, so if I'm making a bot for a local/small server which I want a slowmode for, would using prefix-based commands be better then?
cooldowns exist
should work
thanks I'll look into it, tysm!
No
both work completely fine though the process of getting the cooldown error is different
Do you know how I can get the Guild ID from the Webhook?
so you mean using slowmode on the channel will also limit slash commands?
acc dw I'll get a friend to test it, thanks for ur help!
nope, I meant as in to get the cooldown values, like how long it'll take before you can use the command once again, that is different
ah I see, cool thanks
you'll have to get the webhook first then, and then do webhook.guild_id
hey guys , my other users are not seeing the /command
Okay, but the webhook id is not from the server I follow the channel, but from my server. Had expressed myself wrong. How can I get the guild id from the server I follow?
I have it all good
examplepy channel = bot.get_channel(channelID) user = bot.get_user(userID) def check(message: discord.Message): return message.author == user messages = await channel.history(limit = 100, check = check)
i know, the webhook id is from your guild, and to get the original guild first you have to get the webhook object and access its guild attribute
There is source_guild.
Think this is what I am looking for
yep
you can use the async iterator to append the messages to an auxiliary list if the messages are from a specific author
if you want to find the first occurrance, use channel.history().find(check)
async for m in channel.history(limit=100):
if m.author == user:
# do something
if i put all my cogs into a folder would loading them be the same or will i have to add something?
if you have a folder named "cogs," you could load them like this:
bot.load_extension("cogs", recursive=True)
thanks
Hey, can you get the message history of a channel without using "await"? Like with a URL or something
no
does doing this include any other subdirectories within
it does everything in that folder including subdirectories
even the pycache dir?
It’s not a .py file
Is there a way to get my bot's integration role?
discord.utils.find(lambda r: r.name == bot.user.name and r.is_bot_managed(), guild.roles)
is there a way to get total message count of a person without looping through all channels and all messages 1 by 1
Thanks!
for tasks, will it run individually so let's say
User A runs a command and after 1 hour it pings them that they can run the command once again
Between the command Cooldown User B runs the command, will the task command get confused or will it ping User A and then after how many time left, it'll then ping User B
tasks as in .ext.tasks?
I'm not sure if you can run the same task twice concurrently
is there a way to do it?
I don't think so
Is discord planning to add date selector to slash commands?
Yes, but not sure about the priority (https://github.com/discord/discord-api-docs/issues/2576)
i think it does work?
oh really
yeah, apart from this
so i have CREATE TABLE IF NOT EXISTS but then i get Warning: Table 'whatever' already exists
not sure if I did it correct
that is correct
it does save the data and pings, I only had to do was asyncio.sleep()
and then it'd ping
but how are you calling the task?
its in their roadmap https://github.com/discord/discord-api-docs/discussions/3581
thanks, least its in the works
AttributeError: 'NoneType' object has no attribute 'invoke'
its hard to get help when your snippet doesn't explain the problem at all
that’s because i don’t know the line…
¯\_(ツ)_/¯
you need to show your code tho. somewhere where you sue invoke
Just to follow up on this - my bot and its integration role had different names for some reason, so this didn't work.
I managed to come up with a version that did work though :
discord.utils.find(lambda r: r.is_bot_managed() and r in guild.get_member(bot.user.id).roles, guild.roles)
i have no idea where i use invoke
Traceback (most recent call last):
File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\ticket bot.py", line 81, in <module>
for filename in os.listdir('./cogs'):
FileNotFoundError: [WinError 3] The system cannot find the path specified: './cogs' ```
```py
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
print(f'Loaded {filename[:-3]}')```
not to sure about this
Application Command raised an exception: ClientOSError: [WinError 64] The specified network name is no longer available
what does this error mean
bot was running ok and then it just poped
@grizzled sentinel @smoky forge sorry for the ping, but i have no "invoke" in my code
can you show the full traceback?
yes
Loaded extension: cogs.startup
Loaded extension: cogs.general
Loaded extension: cogs.cratedrop
Loaded extension: cogs.economy
Failed loading extension:
Extension 'cogs.stats' raised an error: ModuleNotFoundError: No module named 'timeago'
Loaded extension: cogs.lottery
Loaded extension: cogs.gambling
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiomysql/cursors.py:239: Warning: Table 'config' already exists
await self._query(query)
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiomysql/cursors.py:239: Warning: Table 'channels' already exists
await self._query(query)
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiomysql/cursors.py:239: Warning: Table 'roles' already exists
await self._query(query)
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiomysql/cursors.py:239: Warning: Table 'users' already exists
await self._query(query)
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiomysql/cursors.py:239: Warning: Table 'lottery' already exists
await self._query(query)
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiomysql/cursors.py:239: Warning: Table 'tickets' already exists
await self._query(query)
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiomysql/cursors.py:239: Warning: Table 'rewards' already exists
await self._query(query)
beta#7179 is ready with:
1 guilds
0 users
Ignoring exception in command config:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/commands/core.py", line 1171, in _invoke
await command.invoke(ctx)
AttributeError: 'NoneType' object has no attribute 'invoke'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/bot.py", line 992, in invoke_application_command
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/commands/core.py", line 358, in invoke
await injected(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'invoke'
idk how to get rid of the warnings
configure the logger of aiomysql to exclude warnings
log level 40
enum is logging.ERROR
Or dont try to create tables when they already there
What are the arguments that discord.ApplicationContext.respond admits?
Can I send a file through it?
I tried with ```py
await ctx.respond(file=file)
How do I send a response to a slash command that only the issuer of the slash command can view?
Found it, it's ctx.send_response(message, ephemeral=True)
is there a method for offering a context specific option list for a slash command argument?
I believe ctx.respond takes the same arguments as send_response, which is at https://docs.pycord.dev/en/master/api.html#discord.ApplicationContext.send_response
is the variable file of type discord.File?
What is the difference between ctx.send_response and ctx.respond? From what I can tell, they do the exact same thing except ctx.respond will fallback to a followup
Hello, trying to load a modal, however an error gets raised https://pastebin.com/uuxAtiep Need help
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Found the problem, you can only do up to 5 inputs
Is there a way to allow slash commands, but prevent users from sending normal messages?
Is there an event for when someone nitro boosts the server?:
its possible using the oauth api, not against the tos if the user knows its going to happen, many if not all bot lists do this, when you add the bot/api application to your acc in authorized apps, the application adds you to the lists server
Autopurge for the channel witch a message Check
await ctx.respond(embed=content, ephemeral=True)```
Doesn't seem to be working
Well at least its returning the message, but not privately.
have you given your defer method call the same ephemeral kwarg?
Oh! Does defer needs to be given it? Alright, will do now
yes, follow ups to a defer will inherit the ephemeral state of the defer
Thanks! All workin' now :)
Is it the same with ctx.send?
Can I send ephemeral with normal messages?
no
Ah kk. Also another little problem.
Regarding cooldowns on Pycord, I'm using on_command_error for prefix commands, and on_application_command_error for slash
Is that fine?
not sure
I was not aware of this. Pycord only supports the discord API (and the voice if that counts as a subsection) we don't handel the oauth.
how to maximize performance when useing pillow/opencv in async?
also these libs support async?
or i need to use thraedpoolexecutors n all
Pillow does not automatically
This might help
https://stackoverflow.com/questions/53557304/pil-and-blocking-calls-with-asyncio
Little stuck, uhm, how do you do views in cogs?
same as if you were doing it in your main file
somethings have to change tho
*Thought it was inside the commands.Cog class, which is what I meant, don't worry, did a tryitands.ee thing haha
yeah the views go out side of the commands class
how do you check if a button interaction is in a specific category?
hey
if status.favicon is not None:
b64_img = status.favicon.removeprefix("data:image/png;base64,")
img_bytes = b64decode(b64_img)
with open("images/status.png", "wb") as f:
f.write(img_bytes)
image_url = "attachment://images/status.png"
embed.set_image(url=image_url)
await ctx.send(embed=embed)
why my image isn't sending
only the embed with the text
but no image
you need to pass a file to send to send
and how can i do that?
create a discord.File with your attachment and pass that to the file kwarg
now it looks like that
but how can i send it in the embed
filename in your image url for your embed needs to be the same as the file you're sending

