I'm making a Discord bot to handle an announcement command. When the command is used, I want the bot to send a message in a specific channel and send a message back to the user to show that the command was sent.
However, I cannot get the message to be sent to the channel. I tried this code:
import discord
import os
import random
import asyncio
testing_servers = [912361242985918464]
intents = discord.Intents().all()
bot = discord.Bot(intents=intents)
@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 bot.get_channel(channel_id).send(embed = embed_announce)  
But before even attempting to send the other message back to the user, I get an error that says AttributeError: 'NoneType' object has no attribute 'send'.
I conclude that bot.get_channel(channel_id) evaluated to None. But why? How can I get the correct Channel to send the message?
Make sure you are sending an integer to get_channel():
await bot.get_channel(int(channel_id)).send(embed=embed_announce)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With