【发布时间】:2020-06-01 16:25:42
【问题描述】:
User 1: nuclear
User 2: reactor
我希望能够比较这两条消息;但是,我遇到了一些麻烦:我只是不知道如何将第二条消息保存到变量中。我试过使用wait_for(),不知道这是这样做的方法还是我使用正确。
import discord
from discord.ext import commands
class Shiritori(commands.Cog):
""" Start a new word from the last letter of the one before. """
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
last_letter = message.content[-1]
print(f"The first letter is {message.content[0]}")
msg = await self.client.wait_for('message')
print(f"The last letter is {msg}")
if message.content[0] != msg[-1]:
await message.delete()
def setup(client):
client.add_cog(Shiritori(client))
我的计划是保存用户 1 单词的最后一个字母,并与用户 2 单词的第一个字母进行比较,如果不匹配,则删除用户 2 的消息。
【问题讨论】:
标签: python python-3.x discord.py