[英]How can I make a welcome message with a discord bot with python?
[英]Discord Python - How to make the BOT search for a message?
有誰知道如何使BOT在特定服務器上的特定通道中查找特定消息? 如果BOT找到了,他會做ssm,否則他會做ssm。 我現在有這個:
@bot.command(pass_context=True)
async def command(ctx):
search = discord.utils.get(bot.get_message, message = 'MESSAGE', channel = bot.get_channel(id = 'CHANNEL ID'))
if not search == None:
await bot.say("SSM")
else:
await bot.say("SSM ELSE")
它說錯誤...
在這里,我使用logs_from
來通讀帶有id的channel消息,尋找一條消息,其中包含在其中調用命令的服務器的id。
from discord import NotFound
@bot.command(pass_context=True, name="command")
async def _command(ctx):
channel_id = "123"
channel = bot.get_channel(channel_id)
if not channel:
await bot.say("Error: Could not resolve controller channel")
return
server_id = ctx.message.server.id
async for message in bot.logs_from(channel, limit=500):
if server_id in message.content:
await bot.say("SSM")
return
await bot.say("SSM ELSE")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.