我正在尝试制作一个Python Discord Bot,它首先可以删除频道内的消息。我希望它是终结者3的主题,所以它会由用户说起Skynet然后机器人要求激活Y或N?当用户输入Y时,如果用户键入N,它将删除频道中的所有消息,它会说判断日是不可避免的。任何帮助将不胜感激。
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
token = 'Token'
Client = discord.Client()
client = commands.Bot(command_prefix = '!')
@client.event
async def on_ready():
print("Skynet Online")
@client.event
async def on_message(message):
if message.content == 'skynet':
await client.send_message(message.channel, 'Execute Y/N?')
@asyncio.coroutine
async def delete_messages(messages):
if message.content == 'Y':
await client.delete_messages()
client.run('Token')
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
@has_permissions(manage_messages=True, read_message_history=True)
@bot_has_permissions(manage_messages=True, read_message_history=True)
async def purge(ctx, limit: int = 100, user: d.Member = None, *, matches: str = None):
"""Purge all messages, optionally from ``user``
or contains ``matches``."""
logger.info('purge', extra={'ctx': ctx})
def check_msg(msg):
if msg.id == ctx.message.id:
return True
if user is not None:
if msg.author.id != user.id:
return False
if matches is not None:
if matches not in msg.content:
return False
return True
deleted = await ctx.channel.purge(limit=limit, check=check_msg)
msg = await ctx.send(i18n(ctx, 'purge', len(deleted)))
await a.sleep(2)
await msg.delete()
这是删除邮件的命令