discordで取得した文字にaaaが含まれていると、ランダムな言葉を発言するBOTです。
自信のメッセージはmessage.contentで取得出来ますが、他ユーザのメッセージが取得出来ません。
message.authorでユーザを取得する場合は、他ユーザでも取得出来ます。
何か足りないモノがありますでしょうか。
他ユーザが発言した後のmessage.contentの中は空に値になっています。
coding=utf-8
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import os
from time import sleep
import time
import random
import datetime
import asyncio
bot = commands.Bot(command_prefix="+", intents = discord.Intents.default())
work_channel_id = "93183424993359859"
word = ["lol", "nice", "wow", "gogo", "good", "haha"]
send_message = random.choice(word)
def init(self, bot):
self.bot = bot
@bot.event
async def on_ready():
print("Logged in as {0.user}.".format(bot))
メッセージの送信時に実行されるイベントハンドラを定義
@bot.event
async def on_message(message):
#指定したチャンネルとメッセージを送ったチャンネルが同じIDなら実行
if int(message.channel.id) == int(work_channel_id):
a = message.content
if "aaa" in a:
print("found the word")
time.sleep(3)
await message.channel.send(send_message)
else:
time.sleep(3)
else:
print("not hit")
pass
bot.run("abcde", bot=False)

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。