I want to make my discord bot only reply to question on a specific channel. Here is the example:
Channel A:
User A: Dream!
Discord Bot: You are Dream’s big fans? Oh me too!
Channel B:
User A: Dream!
Discord Bot: "No Respond"
I want to make something like this. If it is possible, please help me! This is part of my code:
import discord
import time
import random
client = discord.Client()
@client.event
async def on_ready():
print('{0.user} has already login!'.format(client))
@client.event
async def on_message(message):
name = message.author.display_name
if message.author == client.user:
return
if message.content.startswith("Hey Rikky!"):
await message.channel.send('Always Here!')
if "Rikky, tell me a joke" in message.content:
await message.channel.send("I'm sorry, I'm not good at telling someone jokes")
client.run('My token')
Thanks for spending so much time reading this question! Thank you! (I’m using discord.py)
>Solution :
Just check the message’s channel id with message.channel.id before replying:
if message.content.startswith("Hey Rikky!") and message.channel.id == "YourChannelId":
await message.channel.send('Always Here!')