【发布时间】:2021-05-20 01:42:03
【问题描述】:
所以,我一直在 discord.py 中为我的机器人开发一个 killswitch,但我遇到了一个难题。我的终止开关不起作用,它没有给我一个错误。如果有人可以提供帮助,我将不胜感激。
import discord
from discord.ext import commands, tasks
from keep_alive import keep_alive
import asyncio
import random
import json
import random
import discord.utils
from datetime import datetime
client = commands.Bot(command_prefix=',')
client.remove_command('help')
@client.event
async def on_ready():
global startdate
startdate = datetime.now()
await client.change_presence(
status=discord.Status.online,
activity=discord.Game('Type "," to activate me! e'))
print('Bot is ready.')
@client.command(aliases=["shut", "shutdown", "quit", "stop_that", "stahp", "kill"])
@commands.has_permissions(administrator=True)
async def stop(ctx, member: discord.Member = None):
embed = discord.Embed(colour=discord.Green())
embed.add_field(name="I have been Killed", value=f"{member.name} has killed me! That's very unpog of them!", inline=False)
embed.set_image(url="")
embed.set_thumbnail(url="")
embed.set_footer(text=f"Killed By: {ctx.author.name}")
await ctx.send(embed=embed)
await client.logout()
client.run('no token for you :)')
【问题讨论】:
-
你试过client.close()吗?
-
您是打算简单地以
,shut或,shut some_user运行命令吗? -
感谢大家的支持!你帮我把终止开关做得更好了
标签: python discord discord.py repl.it