#General Help
1 messages · Page 2 of 1
sorry im not seeing a way
but i can give you code that deletes itself thats not ephemeral
Oh the delete_after parameter works, just as long as ephemeral is not true
yeah
isnt the point of a ephemeral message for you to only see it
seems counter productive to delete it
#970690142476058734
Yeah, but they might get a ton of them which is why I only want them to last like 10 seconds
help me on this
and istg if its a simple answer i will scream
@tasks.loop(seconds = 10)
async def change_status():
await bot.change_presence(status=discord.Status.idle, activity = status)
```why dosent this work
whats the error
what is cycle
does it return anything?
that is my list
and expecting activity to be a list
you can't delete ephemeral messages
is there anyway to get rid of them after a certain time?
nop
can only dismiss manually
though if you reload the client they should be gone
url buttons can’t have callbacks, so you need to add them with view.add_item
can you add guild_ids to bot events so they only happen in that server
for example your bot is welcoming people into your server and dming them
but it does that for all servers
You can make a list containing the guild ids in which you want the event to react to
In the specific event you can make an if statement checking if the authors guild id is in that dictionary
would a list work?
I meant list sorry
so for example @bot.event(guild_ids = [some random guild])
no
then how?
@bot.event
async def on_message(msg):
if msg.guild.id in a_list:
#Your code
I'm not sure if it's guild.id
Hi guys, can someone tell me how can I make the slash command /unload <cog> work?
bot.unload_extension() <-- this is not working i guess
In this your a_list contains all the guild ids you want the event to react to
what if its a on join command
wouldnt i have to change msg
i should just take out the param
manke it member
what exactly isn't working?
it's the same format as load and reload
msg is just an argument
you could just do the same
async def on_member_join(member):
if member.guild.id in a_list:
###
It should prob work
async def unload(ctx, cog_name: str):
bot.unload_extension(f'cogs.{cog_name}')
await ctx.respond(f'Unloaded Cog: {cog_name}')```
the command responds but does not remove the cog file
are you trying to remove slash commands?
Even if you put msg instead of member it would still do the same thing
or regular commands
yes
slash commands are a bit different
ok, i think i got it 😕
you should look into sync_commands to see how to unregister https://docs.pycord.dev/en/master/api.html#discord.Bot.sync_commands
I want that, when unloading a file, the slash commands stop appearing in the chat
would this work?
async def on_member_join(ctx, member):
if member.guild.id in guilds:
embed = discord.Embed(title = "welcome")
await ctx.member.send(embed = embed)````
i think you could try:
- get a list of application commands in the cog
- with sync_commands, get all application commands on the bot but remove said commands
Don't put ctx
ah
It's an event not command
yeah no context
member.send would be enough also
gotcha
alright, i will try that
i dont think its member.guild.id
should be
is guilds a list of guild ids?
Error?
yeah
nope
they're not strings
bot.guilds is a list of Guild objects
hmmm
OH the account wasnt verified
oh
so it didnt know who to send to
hmm
ok everythings good
Ohk noic
no just member.send
what if member isnt defined
uhhhh
It should
if it's on_member_join you'll always get a member object
Be defined at all cost
no i mean in a slash command
if you don't get the member or user object, just fetch it yourself
i'd personally use get_or_fetch_user https://docs.pycord.dev/en/master/api.html#discord.Client.get_or_fetch_user
Heroku is a hosting platform which provides 550 free hours per month but by adding a credit/debit card (without paying) you get 1000 hours. So do you get 1000 hours per month or is it only one time?
i think it's total, but i wouldn't use heroku for hosting anyway
generally you should avoid "free" solutions because they are NOT built for a task like bot hosting (despite it being possible)
e.g... replit is a popular one these days
ctx.author.send works
Oh I see
yeah that should work
But I'm broke f I had money i would go for better servers ;/
rip
ploxhost is for $1.50
Traceback (most recent call last):
File "D:\banbot\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "D:\banbot\lib\site-packages\discord\bot.py", line 1147, in on_connect
await self.sync_commands()
File "D:\banbot\lib\site-packages\discord\bot.py", line 683, in sync_commands
permissions = [
File "D:\banbot\lib\site-packages\discord\bot.py", line 686, in <listcomp>
if perm.guild_id is None
AttributeError: 'function' object has no attribute 'guild_id'```
Just a bug in the library or?
its guild.id
2.0.0b7
import discord
from dotenv import dotenv_values
config = dotenv_values(".env")
bot = discord.Bot()
@bot.event
async def on_ready():
print(f"We have logged in as {bot.user}")
@bot.slash_command(guild_ids=[456413000887435285], permissions=[discord.commands.permissions.is_owner()])
async def reload(ctx):
for cog in cogs_list:
bot.reload_extension(f'cogs.{cog}')
await ctx.respond("Reloaded")
bot.run(config['DISCORD_API_TOKEN'])
hmmm
But the traceback doesnt trace back to my code.
Quick question, can you have a select menu to a modal?
This isn't how you implement permissions, is_owner is a decorator (e.g. @discord.commands.permissions.is_owner())
Though regardless I don't think it'll work due to perms v2
is discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message a message i should be concerned about fixing? everything else works perfectly. can go more into detail if needed but i read #932108949652648026 message that it was apparently pretty harmless so wanted to verify whether that's true and i should just not worry about it, or if i should address it further
Well it depends on your code, it's harmless in that specific context but if you're trying to get a specific message in your command and you get that then you should deal with it
What is the correct way?
It seems to work tho.
i'm pretty sure the message is not found because i deleted it which is the intended behavior
Ah I see.
Fair enough, but you should probably handle the exception instead of just letting it error (if this is a regular occurrence)
Rlly need to learn about the decorators once...
gotcha, will work on it
@agile tundra Wrong use of @discord.commands.permissions.is_owner() was causing that error.
Bruh
my sllash command isnt appearing
i registered it in my cog with commands.slash but i dont see it on discord
anything else i need to do?
how do i make the "" with a hotkey
Anyone know the code for getting profilepic url from ctx.author?
Nope, I managed to figure it out via the docs. It is ctx.author.display_avatar
yeah. I meant display avatar. my fault
How can I generate number? for example make each modal submitted application 1, 2 3 and so on
you can do an autoincrement column with mysql
what
do slash commands work from cogs
you would just store the highest number somewhere and then reference/update it for each application
yes of course
did u ever figure this out
Command groups? Yes
how can i upgrade to py-cord 2.0.0b7 ?
when i'm installing it in vps, it installs the 1.7.3
!install
Install pycord:
pip install py-cord```
Install pycord beta:
```pip uninstall discord.py
pip install py-cord==2.0.0b5```
Install pycord alpha from git:
```pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord```
oh b7 should be on github im pretty sure
how do i completely uninstall pycord?
pip uninstall py-cord
pip install py-cord 2.0.0b7 doesn't work?
yea
How even
The correct command is pip install py-cord==2.0.0b7
Oh I guess the error says that
i cant use pip normally on this machine
pip3 works
What about py -3 -m pip
Is the channel Option Type for application commands already fixed on the master branch?
I think you can do discord.channel
Is it possible to pass arguments to an view to determin how many buttons should be active?
Subclassing?
Just add an _init_ function (remember to super) and add an extra argument there you can pass in
I realized I'm dumb with Python, thanks!
All good
I was passing arguments in the subclassing definition and was bewildered, ah well
Perhaps another question: I can pass the arguments, but it would be the decorator that actually attaches the button to the view. So how would I make the decorator conditional?
im having a problem
i made a discord button thats supposed to send a embed with a truth or dare question
but it keeps sending the name question
>>> field2 = embed.fields[2]
>>> print(field2 == embed.fields[2])
False
``` why doesn't it return True?
how do you do slash command groups in a cog?
Not worth a whole thread, but has anyone had issues with clear_single_reaction complaining that it requires 2FA? I didn't think bots needed 2FA
(Edit: Turns out 2FA is inherited by the application owner)
never mind i figured it out
async def cmnd(ctx):
select = Select(
placeholder="Pick a category",
options=[
discord.SelectOption(label="One"),
discord.SelectOption(label="Two"),
discord.SelectOption(label="Three"),
discord.SelectOption(label="Four"),
discord.SelectOption(label="Five"),
])
async def my_callback(interaction):
await interaction.response.send_message()
```how can i make the `await interaction.` to edit it? wadda i use for edits? 
i did await interaction.message.edit but it gives an error altho it still works
did you do await interaction.message.edit(context = "blah blah blah")
oh it works nvm
you should interaction.respond.edit_message()
Is there a way to send dm's from interactions?
It’s not supposed to be used as a response tho
https://discord.com/channels/881207955029110855/970401629893439558
I'm getting an issue when mentioning multiple users with solution given. But if I mention a single user, it works
how do i get an input from a modal?
i need to get the input and parse it into a spreadsheet
?tag ex
Bot examples: https://github.com/Pycord-Development/pycord/tree/master/examples
Slash command/context menu examples: https://github.com/Pycord-Development/pycord/tree/master/examples/app_commands
Buttons, dropdowns example: https://github.com/Pycord-Development/pycord/tree/master/examples/views
check views
can someone give me an example that works (with imports) for buttons, i cant find any that work
?tag ex
Bot examples: https://github.com/Pycord-Development/pycord/tree/master/examples
Slash command/context menu examples: https://github.com/Pycord-Development/pycord/tree/master/examples/app_commands
Buttons, dropdowns example: https://github.com/Pycord-Development/pycord/tree/master/examples/views
i forgot to mention im using discord.py not pycorfd
please ask in the discord.py server then, this is pycord support.
i was made fun of there, im never going back
Traceback (most recent call last):
File "C:\Users\hayha\PycharmProjects\pythonProject3\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\hayha\PycharmProjects\pythonProject3\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
await injected(ctx)
File "C:\Users\hayha\PycharmProjects\pythonProject3\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: 'str' object cannot be interpreted as an integer
@discord.command(name='random-choice', description='Randomly choose a # of winners from given choices')
async def random_item(self, ctx, items: discord.Option(str, 'put items here, separated by a space'), winners=1):
item_list = items.split()
winner_list = []
for x in range(winners):
choice = random.choice(item_list)
winner_list.append(choice)
await ctx.respond(winner_list)
Pycord v2.0.07b: not sure why this is erroring, nothing looks wrong to me. The items parameter is not the issue either, I have isolated that. any ideas? (it is a beta build of the lib, so it could be a bug?)
Yeah that’s really weird, try down grading to b6 if needed until they can fix it
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 352, in _run_event
await coro(*args, **kwargs)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 793, in on_connect
await self.register_commands()
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 338, in register_commands
to_update = update_guild_commands[guild_id]```
why is this happening?
Yo, is there a simpler way to do this so i dont have to write await ctx.message.delete() on every command?
I just want it to auto delete the message the command was in
the discord.ext.commands on_command and the on_application_command event
Does anyone have an idea for that?
or at least a way to bypass this
Is it possible to disable a Button for an specific User?
works now with interaction.respond.edit_message(context="") ty @balmy flame and @slow dome 😉
Help me
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 181, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/PyBot/cogs/funny.py", line 138, in marry
if member.id in marriages_members:
AttributeError: 'NoneType' object has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1505, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 190, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'```
i'll give it a try, thanks
how to use quotes with a jump to original button?
sth like this
how to add that jump button
oh I found out it's just an embedded link
I'm a better help then jab
If the user does not enter in a username, member will default to None. This command should require a member unless you can marry yourself or something. Otherwise you will need tocheck if member is None before using member.id
yea it's a hyperlink
"[jump text here](url here)"
Why do bots have the "Use application commands" perms? Can 1 bot use application cmds of a 2nd bot?
seems the issue was fixed with typecasting for whatever reason
doesnt work
No. It can't.
then why is this a thing?
how i can add Cooldown on command in cogs?
Why when i create a new embed with a button if i restart the bot the message need to be resended or the button says "Interaction failed"?
How i can do a button permanent?
class View(nextcord.ui.View):
def __init__(self):
super().__init__(timeout = None)
its still not working
lemme fix
can you show your slash commands code?
wanna come in dm?
ill send you all
okay
Persistent views
@stray smelt @coarse marsh What was the fix? I would like to know for myself.
does someone have an idea?
So, I'm currently trying to install py-cord==2.0.0b7
I uninstalled discord, discord.py, discord_components, buttons, nextcord.
What I typed in the terminal: pip install py-cord==2.0.0b7
The error messages:
WARNING: Ignoring invalid distribution -ywin32 (c:\users\no\appdata\local\programs\python\python37\lib\site-packages)
ERROR: Could not find a version that satisfies the requirement py-cord==2.0.0b7 (from versions: 1.7.3)
ERROR: No matching distribution found for py-cord==2.0.0b7
WARNING: Ignoring invalid distribution -ywin32 (c:\users\no\appdata\local\programs\python\python37\lib\site-packages)
WARNING: Ignoring invalid distribution -ywin32 (c:\users\no\appdata\local\programs\python\python37\lib\site-packages)```
those are discord permissions, but bots are restricted from interacting with other bots as far as the API is concerned
Did you allow it on bot perms?
looks like discord updated again
kick it from your server, and invite it back with this
i want permissions decorator baaaack 😭
yes
only 1 command is showing up
out of the 5
Oh
are the slash commands guild or global
guild
via guild_ids?
yes
or debug_guilds
guild_ids
try updating your client and restart the bot
how would i do that
updating my client
and i have restarted my bot
many times
how to use permissions decorator like this today?
Phone = app store/ play store
reset client secret, I think
desktop = upper left corner
im currently hosting on repl
click green download button thingy
😭
updating your discord
im on web discord rn
refresh
show code
slash commands need a description
i just added a new cmd and all of a sudden this started happening
they do have it
lmfao
and permissions are broken
discord was like how do we make people use slash commands? release an update so it breaks everything
Few days ago, breaking api change with no warning and no version bump + other issues 🙃
Though they at least apologised for it
Also just a quick question
Traceback (most recent call last):
File "AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 1147, in on_connect
await self.sync_commands()
File "AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 770, in sync_commands
await self._bot.http.bulk_upsert_command_permissions(self._bot.user.id, guild_id, guild_cmd_perms)
File "AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 359, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed```
Is this uh
because of outdated lib?
Or intent mayne?
How to make forum channel?
Wait until you're whitelisted
How do I delete the default help panel
help_command=None```
on
```discord.ext.commands.Bot
Then I can make a custom one ?
Hmm
Hello,
Is it possible to get the custom status a User himself sets? I can get the Game the User is playing via member.activities but I can't seem to be able to get the custom status one can set?
What you mean?
activities = guild.get_member(user.id).activities
For Custom Activities
Got it to work sorry, I guess I didn't wait long enough for it to sync
Hi, is there a way to get a guild's roles in order? Or at least check if a role is higher than another?
check role.position
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Can someone suggest if there is any fix for this?
I am trying to get list of users with a certain role, through a command
Also, how to check the user ID of user who ran the command? (Above warning I shared is for the below code)
@bot.command()
async def getuser(ctx, role: discord.Role):
print("Debug-Inside getuser()")
await ctx.send("Loading...")
await ctx.send("\n".join(str(member) for member in role.members))
ctx.respond("Done")
the error tells you what's wrong...
you need to await your ctx.respond
Oh my bad. Thanks
In this code, if I want to predefine the role for which user list is fetched, how to implement?
I mean something like...
defBoostRole = 123456789012345678
@bot.command()
async def getBoosters(ctx):
role = get(ctx.guild.roles, id=defBoostRole)
await ctx.send("Loading...")
if(len(role.members)>0):
await ctx.send("\n".join(str(member) for member in role.members))
await ctx.respond("Executed!")
I am not sure how to pre-define the role part with the id...
role = get(ctx.guild.roles, id=defBoostRole)
it looks predefined to me...
role = get(ctx.guild.roles, id=defBoostRole) didn't work
what is get()?
is that a method you wrote?
or did you just import get from discord.utils
Yes
what doesn't work? do you get back None?
did you read the error?
your command name is invalid, probably the capital B
Ok thanks a lot, is there any docs for those naming conventions I can refer to? Is this pycord specific or for discord in general?
Ok thanks a lot, will check it out
can someone help me with that?
state of # help... despair haha
yeah we really need a faq
chat, random question, this "Integations" menu is cool and all but can it hide slash commands from me(as server admin) as well ? 😄 anybody knows anything? it hides things from non-adminds just fine but idk
Does bridge.Bot not honor debug_guilds?
99% sure it can't hide them from the server owner
Hello I'm trying to get poetry setup with my project though everytime I run poetry init I get this error which I don't how to fix
Error:
poetry init
This command will guide you through creating your pyproject.toml config.
Package name [reko]: Reko
Version [0.1.0]: 0.4.4-beta
Description []:
Author [TechnoTalksDev <>, n to skip]:
License []:
OSError
[WinError 1920] The file cannot be accessed by the system: 'C:\\Users\\chcha\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe\\Scripts'
at C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\pathlib.py:1095 in stat
1091│
1092│ Return the result of the stat() system call on this path, like
1093│ os.stat() does.
1094│ """
→ 1095│ return self._accessor.stat(self, follow_symlinks=follow_symlinks)
1096│
1097│ def owner(self):
1098│
1099│ Return the login name of the file owner.
Nvrm
I keep getting an error saying my token must be of type str, not NonType
idk how to fix it
stack tracE?
is there a TOKEN enviroment variable in your enviroment? @potent rivet
no?
idk
theres your issue
what do you think os.getenv('TOKEN') does
then use python-dotenv
gets token from env
i am
yeah no
thats what the guide said
so how do i make it work
just TOKEN=your token
ok ty
channel = channel.name
name = channel.split("reps-")
print(int(name[1]))
rename = name + 1
other_channel = bot.get_channel(971111822356795402)
print("f", rename)
await other_channel.edit(name=f'reps-{rename}')
So the code above should just rename my channel to reps-number_here of course, now the name of the channel right now is just reps-0, the first print statements gets printed but after that, the next print does not and subsequently, the channel is never renamed
You can only rename a channel twice every 10 minutes
well I havent renamed it all yet
do you have permissions to rename channels?
name is a list, you can't add 1 to a list
oh you're right, so would I just convert name[1] into an int I guess
?tag install
- Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y
- Install
py-cord
python -m pip install py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Updating to beta:
pip install py-cord==2.0.0b7
I already installed it still showing the error
can you pip list @cloud lotus
are you sure thats the error?
yes It was working fine few day back now I'm getting that error
thats odd
idk what happened 
hm 🤔
is this limited to messages that are in the internal cache?
or it will fetch it from the API if it isn't in the internal message cache
how do you create webhooks with code?
like i know you can make them in the channel settings, and there's also Webhook.from_url() which you can use to use those ones that you made yourself, but how would you do it where the bot makes it itself?
b!rtfm pycord TextChannel.create_webhook
When Trying to fetch a message with its ID it is throwing an exception:
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:\Users\felix\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "c:\Users\felix\Desktop\py\dc_msgtrack\main.py", line 18, in on_raw_reaction_add
message = bot.get_message(id=payload.message_id)
AttributeError: 'Bot' object has no attribute 'get_message'
Code is as follows:
# load in packages and libs
import discord
from discord.ext import commands
from log import log
# read token
with open('token.txt','r',encoding='utf8') as tokenfile:
token = tokenfile.read()
bot = commands.Bot(intents=discord.Intents.all(),prefix='.')
@bot.event
async def on_ready():
log('Connected to Discord')
@bot.event
async def on_raw_reaction_add(payload):
message = bot.get_message(id=payload.message_id)
log(message)
# log(payload.message_id)
log(payload.member.id)
bot.run(token)
Update to master
how to perform this update?
?tag install
- Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y
- Install
py-cord
python -m pip install py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Updating to beta:
pip install py-cord==2.0.0b7
which one is master?
so the issue I'm facing is known and will be fixed in a future release?
want to confirm is the current release (old version not 2.0 beta) affected by this?
how would i take an image link and convert it to a bytes-like object?
huh
- i cant find anything that works then . _.
- im trying to make webhooks with avatars, and im storing them as urls
you can specify avatar as url, no?
just get it from url and turn in to bytes
🤔
it wont accept urls, only "bytes-like object"
hang on let me try that
also is it required to download the image for it to work?
don't think so
every solution i can find seems to do that
im pretty sure you can just read bytes
from url
with BytesIO
i think i've done this several times
it should work with aiohttp
@bot.slash_command(name='nothin', guild_ids=slash_guilds)
async def nothin(ctx):
basic_bot = Button(label='Basic Tier Bot', style=discord.ButtonStyle.blurple)
interm_bot = Button(label='Intermediate Tier Bot', style=discord.ButtonStyle.green)
advanced_bot = Button(label='Advanced Tier Bot', style=discord.ButtonStyle.red)
await ctx.respond('test')
view = View()
view.add_item(basic_bot)
view.add_item(interm_bot)
view.add_item(advanced_bot)
await ctx.respond(view=view)```
Any reasons for that error?
great, I made a new bot application and now another bot command just disappeared and the rest are still here
how do I get a message that is not in its internal message cache?
channel.fetch_message(id)
do I need manage messages permissions for this to work?
it is giving me a 403 forbidden error
how would i speed up (<built-in method _overlapped.GetQueuedCompletionStatus>)?
# @param {string} plant (key)
# @return {JSON} lastState```
has anyone ever seen this type of type hinting for python?
is it possible to make my select menü persistent?
persistent view
Enable MESSAGE_CONTENT_INTENT on both the portal and the program
That is enabled
you also need messages
how can i make this think?
you mean choices?
yes
choices kwarg in Option. must contain a list of the input type max. 25 elements
wtf
idk im working with an aws lambda function here
this is old shit some dude made that i need to update
i was instructed to follow the conventions used in the script
maybe a c# developer having had to use python or something?
theres also return keywords on some of the helper functions when it isnt necessary
possibly
gl with that
i wont fiddle around with the documentation much but ill use more line efficient conventions in some places
theres also no usage of f-strings anywhere in this script
autocomplete
same error
do pip list
What now.
send it here
okay
whats that?
it's a file on desktop
do you have another file on your desktop called discord.py
try now
what is coro
its bot.event
its harmless
but you can just update to the master branch
if you want to get rid of it
Is there an event which gets executed before on_ready?
on_connect() prolly does
I se thanc
Has anyone done discord authorization with bearer and fastapi?
I installed pycord but it says no module named 'discord'
run pip list
and send the output
------------------ ---------
MarkupSafe 2.1.1
multidict 6.0.2
numpy 1.22.3
pip 22.0.4
py-cord 2.0.0b7
pycord 0.1.1
pygame 2.1.2
requests 2.27.1
setuptools 58.1.0
urllib3 1.26.9
Werkzeug 2.1.2
yarl 1.7.2
------------------ ---------
MarkupSafe 2.1.1
multidict 6.0.2
numpy 1.22.3
pip 22.0.4
py-cord 2.0.0b7
pycord 0.1.1
pygame 2.1.2
requests 2.27.1
setuptools 58.1.0
urllib3 1.26.9
Werkzeug 2.1.2
yarl 1.7.2
Its a simple reason: Discord doesnt always update it quickly.
To fix it, what you could do is make a list/array with guild ids, and to put change to:
@client.command(name='ping', guild_ids=[ids])
...
In that way, you simple tell the bot that the guild(s) in the list are the testing guilds, and that these should update ASAP once the bot restarts.
You can do it however you like, you can make a variable list for it too.
varlistids = [ids]
@client.command(name='ping', guild_ids=varlistids)
# OR
@client.command(name='ping', guild_ids=[ids])
Let me know if it works
Wait, is that even a slash command?
@bot.slash_command(guild_ids=[your, guild_ids, here])
async def hello(ctx):
await ctx.respond("Hello!")```
It isn't.
You use @client.command instead of @client.slash_command
Ah my bad.
Did you invite the bot correctly?
Okay, weird.
I also wouldnt know the issue then.
Also, another question: how do I update to the latest main branch on a Raspberry Pi/Linux system?
I installed pycord but it says no module named 'discord'
------------------ ---------
MarkupSafe 2.1.1
multidict 6.0.2
numpy 1.22.3
pip 22.0.4
py-cord 2.0.0b7
pycord 0.1.1
pygame 2.1.2
requests 2.27.1
setuptools 58.1.0
urllib3 1.26.9
Werkzeug 2.1.2
yarl 1.7.2
the import discord doesn't work
I also installed discord.py
the from discord.ext.commands import Bot also doesn't work
Is there a timeout for interaction to respond?
import discord
from discord.commands import slash_command
from discord.ext import commands
class Testing(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(guild_ids=[guild_id])
async def testing(self, ctx, color: str, animal: str):
await ctx.respond(f"You picked {color} and {animal}.")
def setup(bot):
bot.add_cog(Testing(bot)) ```
Whenever am loading this extension and running my bot, testing command is not showing up
Am using py-cord 2.0.0b4
I keep getting interaction failed even with 2 seconds delay
Yes, initial response must be send within 3 seconds
defer to get 15 minutes
Anyone know the issue here?
you probably need to initiaise name in the command event handle
# . . .
@slash_command(name = 'testing', guild_ids = [guild_id]
# . . .
Well it was working till yesterday, idk what changed so suddenly?
interesting
Am still using v2.0.0b4
And name is not an issue afaik, as if name argument is not given then it takes the method name as the name of the command
ye ik that, in the past i used slash commands by defining name, description in the event handle
Ohh it worked now, it was a typo xD, didn't noticed my bad
I mistyped, bot.load_extension('ttesting') instead of bot.load_extension('testing')
General Python Help lmao
My discord bot is hosted on an online server. Problem is that the sever file structure is different from my local machine. i,e
the path 'C:\Python\images' is 'C:/Python/images'. Is there any way to use the os module to avert this issue with a try-except block for every cog?
i think pathlib can do that
I installed pycord but it says no module named 'discord'
------------------ ---------
MarkupSafe 2.1.1
multidict 6.0.2
numpy 1.22.3
pip 22.0.4
py-cord 2.0.0b7
pycord 0.1.1
pygame 2.1.2
requests 2.27.1
setuptools 58.1.0
urllib3 1.26.9
Werkzeug 2.1.2
yarl 1.7.2
it isnt supposed to
then why would this happen
thank you!
uninstall discord.py and pycord for now
then re-install
!install
Install pycord:
pip install py-cord```
Install pycord beta:
```pip uninstall discord.py
pip install py-cord==2.0.0b5```
Install pycord alpha from git:
```pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord```
pycord is stable i.e very few bugs
pycord beta is semi stable i.e a few more bugs
pycord alpha is WIP i.e you can expect a lotta bugs
depending on your need
Autocomplete interactions can be used for modal text inputs?
Or they're just for slash command options?
although i would recommend pip install py-cord
what IDE do you use? sometimes it helps to restart your IDE or your System
works for me to restart VS-Code when i install a new library
how can I check?
I know I use pycharm for coding
just restart your system
how can I restart it?
. . .
sorry for being dumb and annoying
like restat your pc
nahh, everyone starts somewhere
It's updating 10 %
What is a user command?
right click on any message, and go to Apps >
Those are user commands, useful for things like translation etc
I think that's a message_command a user command I would have to right click on the user
hello, why does message.content output blank? (i am using discord.Bot and my bot object) can anyone help pls thank you :)
Yea, that seems to be the case
I restarted it but it is still not working
Hello, since today I no longer see my slash commands so what was visible and I haven't changed anything can someone help me
Traceback (most recent call last):
File "main.py", line 1, in <module>
import discord
File "/home/runner/musket-amateur/venv/lib/python3.8/site-packages/discord/__init__.py", line 25, in <module>
from .client import Client
File "/home/runner/musket-amateur/venv/lib/python3.8/site-packages/discord/client.py", line 53, in <module>
from .webhook import Webhook
File "/home/runner/musket-amateur/venv/lib/python3.8/site-packages/discord/webhook/__init__.py", line 12, in <module>
from .async_ import *
File "/home/runner/musket-amateur/venv/lib/python3.8/site-packages/discord/webhook/async_.py", line 52, in <module>
from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/home/runner/musket-amateur/venv/lib/python3.8/site-packages/discord/channel.py)
why does it say this?
completely uninstall all discord related packages (discord.py, discord-literally-anything, py-cord etc.) and install pycord again after
ok
can i just do
pip uninstall -y -r <(pip freeze)
and uninstall everything in one go
ehhh
that'll probably uninstall a lot of other packages you don't wanna touch
what shows when you do pip freeze
ok
Is there any way to extract all users which have a some specific role, like extracting all users who have mods role??
just make a requirements.txt highlight > copy > paste the contents from pip freeze that you want to uninstall then do pip uninstall -r requirements.txt -y
maybe you could loop through the members and check if each member has that role
if they do return that user else pass
This should do exactly what you need
Or, if you want to check if a member has one of the roles inside a list of roles, I did something similar here:
return len(set(member.roles) & set(roles_list)) > 0
Basically does an intersection of user's roles and the list of roles I want to check, if the result is higher than 0 (there are intersecting roles), then the member has one of those roles. Can return instead of len() only the intersection and you'll get a set of the roles the user has
How can I use this I checked the docs many times still can't figure out 😅
Does someone have an idea how to do this correctly?
get role, get members attribute of the role
So you'd need to get the role first (which can be done in various ways, depending on your case, I'll give an example of getting the role through the id from context):
@commands.command()
async def get_members_of_role(ctx):
role = ctx.guild.get_role(123456) # desired role id to find users of
return role.members
It's as easy as that. Get the role class from the guild then get the members from the role.
I recommend checking out the examples pycord has, am pretty sure this is done somewhere https://github.com/Pycord-Development/pycord/tree/master/examples
tysm I'll check it out
You can try this instead:
field2 = embed.fields[2].to_dict()
print(field2 == embed.fields[2].to_dict())```
that's a good idea, thank you
No problem! It might have to do something with the class' __equal__() which doesn't check correctly or lets python deal with it
When you bot.reload_extension is it meant to re-map slash commands
because I pulled an update then decided to reload extensions instead of restarting the whole bot
and the callback didn't change
Nevermind I was being thick
When will this error be fixed? In a new beta version or in the stable v2?
Traceback (most recent call last):
File "c:\Users\MA\Documents\PythonBots\Rubicon\env\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "c:\Users\MA\Documents\PythonBots\Rubicon\env\lib\site-packages\discord\bot.py", line 1147, in on_connect
await self.sync_commands()
File "c:\Users\MA\Documents\PythonBots\Rubicon\env\lib\site-packages\discord\bot.py", line 770, in sync_commands
await self._bot.http.bulk_upsert_command_permissions(self._bot.user.id, guild_id, guild_cmd_perms)
File "c:\Users\MA\Documents\PythonBots\Rubicon\env\lib\site-packages\discord\http.py", line 359, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed```
I think they're working on it quickly, but can't give an ETA since Discord just pushed it over night
Ah okay 👍
Yea discord should announce releases for lib developer a bit earlier at least xD
Nope
My bridge commands aren't all showing up as slash commands. I have debug_guilds set, and I've even waited over an hour. Using b7
I want to get the list of all members in server but it is only printing one member any fix for this??
for member in ctx.guild.members:
print(f'{member}')
I'm also facing same issue
Do they appear in the server settings at integrations? If they do, what seemed to help was disabling then re-enabling them in there
They do show, yes, and show as synced
Try with fetch_members(), maybe the cache wasn't updated, although less likely
This works ... unfortunately, it looks like I have to do it manually for each command 
Yeah, the only work around at the moment until a fix for the new perms is pushed
Got it. That's frustrating. I don't seem to have this issue with another bot of mine
do you have the members intent enabled?
nope
theres your issue
should I enable all?
use Intents.default() to get an Intents object with everything but the privileged intents enabled
and then afterwards set the members attribute of the resulting object to True
okay tysm
getting all these and it makes the bot crash after a few hours
does it only print your bot?
Yes, now it's printing all member after I enabled intent
any use case of this command??
How do I get member object from user id?
say I have
user = await bot.get_or_fetch_user(id)
I want to do it to add roles to it
so it has to be a member object
you could add roles using a user id
I am not sure why I am getting this error
how?
await user.add_roles(role)
is not working
role = discord.utils.get(ctx.guild.roles, name = "Role")
wait i am currently away from my laptop right now
@bot.slash_command(guild_ids=Whitelisted_Guilds,name='honor', description='give the top members an Honorary Role')
async def honor(ctx, from_top: int, to_top: int):
r = requests.get(f'https://mee6.xyz/api/plugins/levels/leaderboard/{guild_id}')
res = r.json()
topmembers = ''
guild = bot.get_guild(guild_id)
# amount = int(amount)
if str(ctx.author.top_role) == adminRole:
for i in range((from_top-1), to_top):
# topmembers += f'''{i+1}. <@{res['players'][i]['id']}>\n'''
member = await guild.fetch_member(int(res['players'][i]['id']))
role = discord.utils.get(member.guild.roles, name='Honorary')
await member.add_roles(role)
embed = discord.Embed(title='Honored :crown:', description=f'''Top {i+1} Member of the month <@{res['players'][i]['id']}> has become a(an) {role.mention} ''')
await ctx.respond(embed=embed)
await asyncio.sleep(1)
else:
embed = discord.Embed(title='Command Execution Failed!', description=f'**Reason:** {ctx.author.mention} has no permission', color=GeneralColor, timestamp=TimeNow)
await ctx.respond(embed=embed, ephemeral=True)
I used this to give roles to top members in mee6 leaderboards
you could modify it to your liking. but what you want should be
member = await guild.fetch_member(member_id)
role = discord.utils.get(member.guild.roles, name='test')
await member.add_roles(role)
try it without the await too if it would work. if not, then do it like this.
same here
I will try
intents.message_content = True
fixed it
can we create forum channel like this in any discord server
I usually get this error:
IndexError: list index out of range```
How can i wait for bot to load embed image?
also Try Except IndexError didn't work
is it possible to call a modal with a button?
Yes
did you try to await it?
Hii! I just restarted my bot, now commands don't work anymore for the guilds. Is there any fix around? I know this is caused by the permissions-v2 issue.
Hello I can't remove the default help panel
I can't
Even with
help_command = none
Hey guys, how can I get a guild ban list?
I want to send DM to all the members who have role dms but it is send DM to only 1 user any fix??
@bot.bridge_command(guild_ids=[])
async def dm(ctx, *, message):
"""Send DMs"""
member: discord.Member
async for member in ctx.guild.fetch_members():
memberRoles = [role.name for role in member.roles]
if "dms" in memberRoles:
#print(member)
#print(memberRoles)
#print(f'{message}\n')
channel = await member.create_dm()
embedMsg = discord.Embed(
title=f'Sent by {ctx.author}',
description=message
)
try:
await channel.send(embed=embedMsg)
await ctx.respond("Message sent!")
except:
await ctx.respond("Unsucceful while sending DM, please tell mentioned users to turn on their DMs.")
finally:
return
# print(member)
await ctx.respond('message sent')
hi i have a question how i can buttons with url ? The url should also contain ctx and member
i have but i dont know i have not found
my problem is member and ctx url is clear.
Do you have an error message?
no im sorry my question is how i can ctx and member import in class
is that even possible?
What do you mean with a class?
I guess you use self in class
ye
ye button class for cogs
so wait
show url yk?
class avatars(discord.ui.Button):
def __init__(self):
super().__init__(label="Download this",
custom_id="interaction: avatars",
url=f"how i can here member and ctx use?",
style=discord.ButtonStyle.gray)
when i add member: discord.Member in init is a error there
And then I have to add something in the command but idk
Check this code ya might get some idea
https://github.com/Pycord-Development/pycord/blob/master/examples/views/button_roles.py
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/button_roles.py at master · Pycord-Development/pycord
thanks but..
so this working but when i added member.id / member.avatar in url is a error there..
Code:
class avatars(discord.ui.Button):
def __init__(self, member: discord.Member):
super().__init__(label=f"Download this {member.name}",
custom_id="interaction: avatars", url=f"https://cdn.discordapp.com/avatars/{member.id}/{member.avatar}.jpg",
style=discord.ButtonStyle.gray)
class Buttons(commands.Cog):
@slash_command()
async def avatar(self, ctx, member: discord.Member):
view = discord.ui.View(timeout=None)
view.add_item(avatars(member))
await ctx.respond("ye")
await ctx.send(f"Button:", view=view)
Error coming
Ignoring exception in command avatar:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 825, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Buttons.py", line 25, in avatar
view.add_item(avatars(ctx))
File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Buttons.py", line 9, in __init__
super().__init__(label=f"Download", custom_id="interaction: avatars",
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\ui\button.py", line 100, in __init__
raise TypeError("cannot mix both url and custom_id with Button")
TypeError: cannot mix both url and custom_id with Button
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
await injected(ctx)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: cannot mix both url and custom_id with Button
remove either the custom id and the callback or the url
okay wait
also .avatar is an Asset
ye its working thanks
Only admins can use slash command on my server, anyone know why?
No regular users can use
and uh, there is no permission restriction in the commands
check
server settings > integrations > yourBot
see if the permissions are correct
What would the decorator for message_command in a cog be
@discord.commands.message_command()
async def example(self , ctx : discord.ApplicationContext , message : discord.Message):
I'm trying to put my token in a .env file and i keep getting an error that the token has to be a string, can anyone help
wasnt this literally fixed 24h ago
.
i did that and its still saying it has to be a str
not NoneType
bot.run(os.getenv('TOKEN'))
this is right?
Nono, in console
So that it'll set up all variables that you have in the .env file
*if you're on windows, the command is different*
yeah i am
Looked for a Windows version, couldn't find one that would be worth the hustle. The easiest way would be to install the dotenv module on python and do something like:
import os
from os.path import join, dirname
from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
.... bot code here ....
bot.run(os.getenv('TOKEN'))
.-.
it no work still eee
wait
no
why do i have 2 python 3.8.2's?
there should be quotation marks around token right?
Yes, there should be
ok well I did your thing and it still gives an error
What error?
A few ideas that might help:
- in .env, make sure you have TOKEN=insert_token_here without spaces and have variable in caps
- try this too:
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
... same code for the rest ...
- don't put " in .env
- make sure .env is in the same folder with main.py; if it's in the same folder you can also try
load_dotenv()without passing the path/find function
If none fix it, you might want to manually set it with set TOKEN=insert_token_here since I blame Windows 😄
i have it as TOKEN = 'my token' because if i leave spaces it gives error
What error do you get without spaces?
What file is that error on? Shouldn't be on .env though
pip install python-dotenv
import discord
import os
from dotenv import load_dotenv
load_dotenv()
token = os.getenv('BOT_TOKEN')
bot = discord.Bot()
bot.run(token)
.env
BOT_TOKEN=tokenhere
i did mine and without quotation on the bot token and it is working fine
is @has_permissions works ok with permissions v2?
im trying to figure out how modals work, and i copied this code from a video:```python
import pycord
import config
from pycord.ui import InputText, Modal
from pycord.ext import commands
intents = pycord.Intents.all()
bot=commands.Bot(intents = intents, command_prefix = None)
@bot.event
async def on_ready():
print('Online!')
class MyModal(Modal):
def init(self) -> None:
super().init('A Modal')
self.add_item(InputText(label='Short Input', placeholder='Placeholder'))
self.add_item(
Input_text(
label='Long Input',
value='Default',
style=discord.InputTextStyle.long
)
)
async def callback(self, interaction: pycord.Interaction):
embed = discord.Embed(title='Your Modal Results', color=discord.Color.burple())
embed.add_field(name='First Input', value=self.children[0].value,inline=False)
embed.add_field(name='Second Input', value=self.children[1].value,inline=False)
await interaction.response.send_message(embeds=[embed])
@bot.slash_command(guild_ids = [513201373169319937], name= 'modal')
async def test(ctx):
modal = MyModal()
await ctx.interaction.response.send_modal(modal)
bot.run(config.TOKEN)```but when i run it i get this error: pycord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access. what's causing this?
invite your bot with application.commands scope
?tag missing.access
No tag missing.access found.
?tags missing
missing_access
?tag missing_access
If you get a Missing Access (50001) error, you probably forgot to add the applications.commands scope.
To fix that, just replace YOUR_BOT_ID with your bot id and visit this link: https://discord.com/oauth2/authorize?client_id=YOUR_BOT_ID&scope=applications.commands
ah, ive never had to deal with any other scopes before 
now im getting pycord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed
?tag 405
No tag 405 found.
?tag method not allowed
No tag method found.
?tag HTTPException
No tag HTTPException found.

check #library-updates
the issue seems to be with guild_ids 
whenever i run it with that i get the 405 error
waiting for the slash command to go through to check to see if the modal works
everyone gets that error, doesn't matter if you use guild_ids
umm, I keep getting this error everytime i start the bot, whats going wrong here??
btw, im using discord.ext.commands.Bot
need help, thats the part that causes the error
latency = SlashCommandGroup("latency", "get bot latency")
@latency.command()
async def embed(self, ctx):
embed = discord.Embed(title="Latency",
description=f"`{round(self.bot.latency * 1000)}ms`",
color=discord.Colour.blue())
await ctx.send(embed=embed)
this is the error
Ignoring exception in command latency embed:
Traceback (most recent call last):
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 839, in _invoke
await self.callback(ctx, **kwargs)
TypeError: embed() missing 1 required keyword-only argument: 'ctx'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1103, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 345, in invoke
await injected(ctx)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1101, in _invoke
await command.invoke(ctx)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 345, in invoke
await injected(ctx)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: embed() missing 1 required keyword-only argument: 'ctx'
i dont know that i did wrong
how do i make my prefix commands non-case-sensitive?
I want >>help and >>HeLp to trigger the same command
could you dm me the part of the code where you specify the prefix, i think i have a solution but im not sure so i want to test it first
def fetch_prefix(client, message):
guild_info = MAIN_DB['guild_information'].find_one({'_id' : message.guild.id})
return guild_info['prefix']
client = commands.Bot(
command_prefix = fetch_prefix,
help_command = None,
intents = discord.Intents.all(),
debug_guilds = [GUILD-ID]
)
am i allowed to dm you? @terse plinth
ye sure
How do you disconnect a user from a channel?
so I tried making a class that makes making modals way easier, and it works great. the only problem is that when you submit everything, it does this:
i get the output printed in the console, everything else works fine and i dont know why this is causing me issues 
any help would be really appreciated
I guess you need to respond to the interaction
In general how much RAM do bots with PyCord take for 1 server only and not so many functionalities? Considering what hosting machine size to start with before analyzing if more is needed
so for some reason it seems to only close when you send the message you want to send inside of the modal
it seems that modals only work right when they're in the form of their own class object

try removing modal.stop
same issue 
Learn how you can implement Modals in your Discord Bot with Pycord!
Just follow that
yeah but the thing is i dont want the modal itself to send a message
i just want to get the inputs from the user, then have it do some other stuff
Then remove the send
also, does it have to be as its own class?
when i do that it doesnt close the modal after you click submit
that's the issue
Well, you're using a slash command, either way it needs a return otherwise, you'll just get an error. This will only show the return message to the user that used it.
await interaction.response.send_message("Submitted", ephemeral=True)
I use the amazon free tier, sometimes I pay around $12 / month for network usage.
discord.ext.commands.Bot is not working. I tried everything I could, but the bot won't respond to the commands
from discord.ext import commands
import discord
bot = commands.Bot(command_prefix=">>", intents=discord.Intents.all())
@bot.command()
async def test(ctx, arg):
print("test")
await ctx.send("testing")
bot.run("TOKEN")
No error is showing up. even the print("test") is not printing test. Can anyone help here?
The bot runs right? You can see it online in your server?
So I assume >>test does not work
yes. It doesn't
what version of pycord?
the development one. I did using pip install -U git+https://github.com/Pycord-Development/pycord
can you pip show py-cord
ok, have you enabled the intents on the developer portal?
yes
hm

Using this same thing?
do you need the dev one?
I was using the slash command and buttons. I just downloaded dev one because I saw somewhere saying the normal one didn't have them yet
Ohk then. So I just do pip install py-cord?
um. idk
1.7 is normal, Idk if that has buttons?
hang on let me see what version ive got
pip install py-cord==2.0.0b7
he has b7
That's the most up to date beta
.
I didn't yet uninstall pycord
bruh
ok wait
I send all of what it showed? image or copy paste?
whatever you want
Package Version
------------------ ---------
aiohttp 3.8.1
aiosignal 1.2.0
async-generator 1.10
async-timeout 4.0.2
atomicwrites 1.4.0
attrs 21.4.0
certifi 2021.10.8
cffi 1.15.0
chardet 4.0.0
charset-normalizer 2.0.12
clashroyale 4.0.1
coc.py 2.0.0
colorama 0.4.4
et-xmlfile 1.1.0
ffmpeg-python 0.2.0
frozenlist 1.3.0
future 0.18.2
humanfriendly 10.0
idna 3.3
imageio-ffmpeg 0.4.5
iniconfig 1.1.1
multidict 6.0.2
numpy 1.22.3
openpyxl 3.0.9
packaging 21.3
pandas 1.4.2
pluggy 1.0.0
py 1.11.0
py-cord 2.0.0b7
pycparser 2.21
PyNaCl 1.4.0
pyparsing 3.0.7
pyreadline3 3.4.1
pytest 7.1.1
python-box 6.0.2
python-dateutil 2.8.2
pytz 2022.1
randomstuff.py 2.0.0
requests 2.27.1
schedule 1.1.0
six 1.16.0
tomli 2.0.1
typing_extensions 4.1.1
ujson 5.2.0
urllib3 1.26.9
yarl 1.7.2```
hm alright
I think it's an intents issue
uhh
he has them enabled in the code and the portal
let me go check again on page
so not sure whats happened
I just ran that code
all are enabled
worked?
what are you inputting for arg?
try adding this to your code and let us know if it prints anything
@bot.event
async def on_ready():
print("I'm online!")
I had this one. It showed that. I just didn't send it while sending here
it was this
@bot.event
async def on_ready():
print(f"{bot.user} is online")
super weird tbh
wait a sec
I removed the intents, my bot is running, but the commands aren't registering either >.>
Ohk so. I'm sorry. I was running a different file. It had the same file name and the bot token was also same. So that's why bot was coming online
Sorry for bothering so much. :/
lmao
Now the commands are working.
yeah
So that's why bot was coming online
😒
why do u want bot to be offline
Hello, I'm making a modal but I can't send the embed to a specific channel
await bot.get_channel(channel_id).send(embed=embed)
Something like this?
AttributeError: 'NoneType' object has no attribute 'send'
No, it's the right channel it does the same to me when I get a guild
Sounds like your bot doesn't have the right permissions?
He has the permissions he sends me the button and the modal opens but does not send
If you go to the channel that you're trying to send to, is the bot in the user list?
Yes
He is an administrator
Have you setup intents?
Yes all
Weird
'_MissingSentinel' object has no attribute 'request'
channel = await bot.fetch_channel(965366395254734858)
I get the error there when I do the command there too
and channel is not None?
No he is present and the correct id
but you can't send() ?
permit the bot to send embeds on that channel
this one
are you using bot = discord.Bot() ?
also do you have ctx argument on the command?
He is an administrator
Yes
hmmmm
This is not a command but a modal (class)
ohh i see
def __init__(self):
super().__init__("Tu recherches un graphiste ?")
self.add_item(discord.ui.InputText(label="Description :", placeholder ="Entrer une courte description de ce que vous recherchez.", style=discord.InputTextStyle.long))
self.add_item(discord.ui.InputText(label="Budget :", placeholder ="Entrer votre budget."))
async def callback(self, interaction: discord.Interaction):
user = interaction.user
embed = discord.Embed(color=0x2f3136, description=
f":coc_arrow: **{user.name} recherche un graphiste !**\n\n" +
"> :coc_message: **» Description :**\n" +
f"{self.children[0].value}\n" +
"> :coc_message: **» Budget :**\n"
f"{self.children[1].value}\n"
)
embed.set_thumbnail(url=user.avatar)
embed.set_image(url="https://i.ibb.co/RctGDPz/barrejaunecoc.png")
button_contacter = Button(label="Contacter", style=discord.ButtonStyle.green)
viewGraph = View(timeout=None)
viewGraph.add_item(button_contacter)
channel = await bot.fetch_channel(965367379796307999)
await channel.send(embed=embed, view=viewGraph)```
try to remove the await on the channel
see if it would work
for the channel i am using channel = bot.get_channel()
No, there is an error he asks for the await
AttributeError: 'NoneType' object has no attribute 'send'
the channel exists...
Can you print(channel) after the get and before send
None :/
Yes
Sorry I can't read that
i used this
@bot.command()
async def modal_slash(ctx: discord.ApplicationContext):
"""Shows an example of a modal dialog being invoked from a slash command."""
class MyModal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Modal Results")
embed.add_field(name="Short Input", value=self.children[0].value)
embed.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[embed])
modal = MyModal(title="Modal via Slash Command")
await ctx.send_modal(modal)
Oh yeah sorry
that one worked for me
You might need manage messages on
Yes but I want to use the modal with button
ohhh you are taking about sending an embed to a channel and when the button is pressed, a modal would pop up
Yes
And then as soon as the modal is filled it sends itself to another channel
also manage channels









