【发布时间】:2019-03-01 16:34:03
【问题描述】:
有一个争夺游戏,如果它已解决或未解决,我想删除原始消息。试过 client.delete_message(nameofmsghere) 但它没有删除它。
if message.content.startswith('!scramble'):
async with aiohttp.post("http://watchout4snakes.com/wo4snakes/Random/RandomWord") as post:
assert isinstance(post, aiohttp.ClientResponse)
word = await post.read()
word = word.decode()
print(word)
scrambled = random.sample(word, len(word))
scrambled = ''.join(scrambled)
scramblemsg = "The word scramble is: `{}`! You have 10 seconds to solve...".format(scrambled)
await client.send_message(message.channel, scramblemsg)
def check(m):
return m.content == word
scrambleloot = random.randint(5,15)
msg = await client.wait_for_message(timeout= 10, check=check)
try:
if msg:
await client.send_message(message.channel, "Nice job! {} solved the scramble for ${}! The word was {}!".format(msg.author.mention, scrambleloot, word))
await client.delete_message(scramblemsg)
add_dollars(msg.author, scrambleloot)
else:
if msg is None:
await client.send_message(message.channel, "Oops! Nobody solved it. The word was {}!".format(word))
await client.delete_message(scramblemsg)
【问题讨论】:
标签: python python-3.x discord discord.py