#sending message to specific channel

1 messages · Page 1 of 1 (latest)

gloomy axle
#
async def _signupPost(ctx:interactions.SlashContext, event_name, channel_name):
initial_embed=await channel_name.send(embed=embed)```
Did syntax change?
send() is not an object even when I tried `channel_name.send()`
robust stumpBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

gloomy axle
#

is channel_type a required thing when using CHANNEL as option?

elder thunder
#

you need a channel object

#

You can get this either from a guild object or the client instance

gloomy axle
#

using the optiontype CHANNEL won't give you the channel object?

elder thunder
#

oh uhm

#

Should give you it?

gloomy axle
#

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):

elder thunder
#

technically yes

gloomy axle
#

ok, giving it try

#

It worked. Thanks!

#

Would it be possible to loop through a list to have it SlashCommandChoices?

elder thunder
#

maybe?

gloomy axle
#

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

terse basin
#

I think you are not udnerstanding everything correctly

terse basin
gloomy axle
# terse basin If you use a channel option type, then your channel_name arg will be of type cha...

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)?

terse basin
#

Get the message object and edit it using bot.fetch_message

robust stumpBOT
#

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)`
gloomy axle
terse basin
#

There is

gloomy axle
#

I ain't getting one. Guess it don't need me to complete my code..lol

#

Is there a documentation on this?

#

Found it!

#

Thanks

#

its not bot.fetch.message(). U have to get the channel object and then use that object.fetch_message()