Reputation: 19
I would like to send a message in a channel when my bot starts here is my code
@client.event
async def on_ready():
print("Bot is running")
activity = discord.Game(name="!test", type=3)
await client.change_presence(status=discord.Status.idle, activity=activity)
#issue starts here
client.getchannel(944607968211652631)
await client.channel.send("I am online")
I have tried a different way aswell
async def on_ready():
print("Bot is running")
activity = discord.Game(name="!test", type=3)
await client.change_presence(status=discord.Status.idle, activity=activity)
on = client.getchannel(944607968211652631)
await on.channel.send("I am online")
but this also has not worked
Upvotes: 0
Views: 283
Reputation: 353
Instead of using client.getchannel which doesn't exist, use Client.get_channel
. It returns a channel which can be used to send messages.
Example:
channel = client.get_channel(id)
await channel.send("hi i've started")
Upvotes: 1