@client.slash_command(name = 'announce', description = 'Makes XYZ announcement in your announcements channel')
@application_checks.has_guild_permissions(moderate_members=True)
async def announce(interaction: nextcord.Interaction, channel: nextcord.TextChannel, *, msg):
await channel.send(f'{msg}')
I keep receiving a typehint error which is relevant to SlashOptions. I am just trying to send the message into the specified channel defined by the channel argument. Why is it error out?
@client.slash_command(name = 'announce', description = 'Makes XYZ announcement in your announcements channel')
@application_checks.has_guild_permissions(moderate_members=True)
async def announce(interaction: nextcord.Interaction, channel: nextcord.TextChannel, *, msg):
channel_id = channel.id
channel = client.get_channel(channel_id)
await channel.send(f'{msg}')
So to answer my own question I went back and was looking at previous code I had written and realized I never specified where I was trying to send the message even though the channel was an "argument"
To fix this I realized that I needed to specify the channel the user was inputting by utilizing:
#Creates a variable to collect channel: nextcord.TextChannel
channel_id = channel.id
# Now specifying the channel to send it to by grabbing the channel id of the requested channel.
channel = client.get_channel(channel_id)
This more or less became less Slash Option help and more of an understanding command arguments. Never give up folks! You'll get there eventually.