What I want to do
I'm making a bot for an announcement command, and I want to make the bot send a message in a specific channel and send a message back to the user to show that the command was sent. However, I get this error:
Stack Trace
After a while of waiting, and getting "The application did not respond", I finally got the error of:
Ignoring exception in on_interaction Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/bot.py", line 727, in process_application_commands
command = self._application_commands[interaction.data["id"]] KeyError: '956003758620426290'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/bot.py", line 1028, in on_interaction
await self.process_application_commands(interaction) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/bot.py", line 742, in process_application_commands
await self.sync_commands(unregister_guilds=[guild_id]) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/bot.py", line 685, in sync_commands
await self.http.bulk_upsert_command_permissions(self.user.id, guild_id, guild_cmd_perms) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 357, in request
raise HTTPException(response, data) discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In 0: Invalid application command id provided
Minimum Reproducible Example
@bot.slash_command(guild_ids=testing_servers, name="announce", description="Make server announcements!")
async def announce(ctx, title, text, channel_id,anonymous=None):
#response embed
print(channel_id)
#announcement embed
embed_announce = discord.Embed(
colour = discord.Colour.blue(),
title=str(title),
description = text
)
await channel_id.send(embed = embed_announce)
embed = discord.Embed(
colour=discord.Colour.blue(),
title = "Sent!",
description= "Check the channel to make sure you wrote the right thing!"
)
await ctx.respond(embed = embed)
Past attempts:
I have tried getting the channel with:
bot.get_channel(channel_id)
I also tried using channel id and #channel
However, I get this error:
AttributeError: 'NoneType' object has no attribute 'send'
This means it couldn't get the channel. What's the proper way to do this?
from Why does bot.get_channel() produce NoneType?
No comments:
Post a Comment