这是我不想区分大小写的一行:if message.content.startswith('.rich'):我想把它改成小写,但我还没有弄清楚如何在代码中实现它
import discord
from discord.ext import commands
import os
from keep_alive import keep_alive
client = discord.Client()
from discord.utils import find
@client.event
async def on_message(message):
if message.content.startswith('.rich'):
embed1 = discord.Embed(title='Richard I (Flag Defense)')
embed1.set_image(url='https://cdn.rok.guide/wp-content/uploads/2019/09/richard-flag-defense-talent-build.jpg')
embed1.set_author(name='Talent Builder', icon_url='https://cdn.discordapp.com/attachments/821829884967649291/860267265404305473/TB7.2t.png')
embed2 = discord.Embed(title="Richard I (Garrison)")
embed2.set_image(url='https://cdn.rok.guide/wp-content/uploads/2019/09/richard-i-garrison-talent.jpg')
embed2.set_author(name='Talent Builder', icon_url='https://cdn.discordapp.com/attachments/821829884967649291/860267265404305473/TB7.2t.png')
embed3 = discord.Embed(title="Richard I (Infantry)")
embed3.set_image(url='https://cdn.rok.guide/wp-content/uploads/2019/09/richard-i-infantry-talent.jpg')
embed3.set_author(name='Talent Builder', icon_url='https://cdn.discordapp.com/attachments/821829884967649291/860267265404305473/TB7.2t.png')
await message.channel.send(embed=embed1)
await message.channel.send(embed=embed2)
await message.channel.send(embed=embed3)```
2条答案
按热度按时间pbgvytdp1#
试着编辑这行
为此:
cedebl8k2#
使字符串区分大小写的一种简单方法是使用
.lower()
方法如下:这个
.lower()
将每个字符设置为其小写自身。这将允许任何大写或小写字母通过if语句,而不区分大小写。