【发布时间】:2021-07-29 16:11:07
【问题描述】:
如何让 Discord 机器人不区分大小写?我目前使用的方法不起作用。我见过其他类似的任务,但它们与我正在做的事情无关。
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
bot = commands.Bot(command_prefix='', case_insensitive=True) #ive tried both true/false. neither works
print("Starting...")
@bot.event
async def on_ready():
print("Logged on as {0.user}".format(bot))
@bot.event
async def on_message(message):
if message.author == bot.user:
return
elif 'hello' in message.content:
await message.delete()
await message.channel.send(‘hi')
bot.run("Token")
我希望用户能够说“你好”或“你好”,它会起作用。关于我将如何去做的任何想法?
【问题讨论】:
-
elif 'hello' in message.content.lower():要使比较区分大小写,只需将要比较的两个字符串强制为小写(或大写,只要您对两个字符串使用相同的大小写)。跨度> -
您希望不区分大小写的
@bot.command在哪里? -
我没有使用命令,我只是检测是否发送了消息
-
顺便说一句谢谢
标签: python discord.py