#sending message to specific channel
1 messages · Page 1 of 1 (latest)
Hey! Once your issue is solved, press the button below to close this thread!
is channel_type a required thing when using CHANNEL as option?
you need a channel object
You can get this either from a guild object or the client instance
using the optiontype CHANNEL won't give you the channel object?
Ok sp if I set channel_name type as Guild, would it fix it?
async def _signupPost(ctx:interactions.SlashContext, event_name, channel_name: Guild):
technically yes
ok, giving it try
It worked. Thanks!
Would it be possible to loop through a list to have it SlashCommandChoices?
maybe?
dont know.. searching for a way
Another question, So how would you edit a message thats in different channel?
I think I found a way. I used a variable to store the channel id from the channel_name and used channel_name.edit() but am getting AttributeError: 'Snowflake' object has no attribute 'edit'
PS its a /create command where i get the channel_name from, but am trying to edit the message using a different slash command from different channel
I think you are not udnerstanding everything correctly
If you use a channel option type, then your channel_name arg will be of type channel, not guild, so wrong typehint here
That I got fixed. The issue I'm facing right now, is the message is in different channel. I can't do ctx.edit() to edit the message and I can't do channel_id.edit() (as I came to know only a message can have the edit()? )
The scenario is I've a message which is in different channel (say channel A). I've that channel id (ID of A) and message ID. How would I edit that specific message when I use a command from a different channel (say channel B)?
Get the message object and edit it using bot.fetch_message
In interactions.py, there is a difference between getting or fetching an object.
Getting an object only looks at objects that have been cached, and therefore is a synchronous function. Getting an object can occasionally return None if that object has never been cached before. Here are some use cases:
user: User | None = bot.get_user(123456789)
member: Member | None = guild.get_member(123456789)```
Although interactions.py's cache system is very reliable, you might sometimes want to make sure that None will not be returned. This is were **fetching** an object becomes useful. When fetching an object, interactions.py will first look if that object is cached. If not, it will then request that object from the Discord API asynchronously. Here are some use cases:
```py
user: User = await bot.fetch_user(123456789)
member: Member = await guild.fetch_member(123456789)```
_Note:_ If you want to skip interactions.py checking if the object is first cached, and directly fetch the object from the Discord API, you can use the optional argument `force=True`. This can become very useful for some features that are never passed by the Discord Gateway except when fetching.
Example: `user: User = await bot.fetch_user(123456789, force=True)`
I dont think theres a fetch_message(). This is all i get for the bot
There is