我的 Killswitch 在 Discord.py 中不起作用,也不起作用,没有错误消息

时间:2021-02-17 07:20:14

标签: python discord discord.py repl.it

所以,我一直在 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 :)')

1 个答案:

答案 0 :(得分:-2)

我在你的代码中看到的第一件事是当你定义嵌入时你只定义了颜色。我继续添加标题和描述的其他字段并将它们设置为无

我看到的第二个问题是,在添加字段值时,您调用了 member.name 但是你应该打电话给member.display_name

最后两个问题是您定义了嵌入图像和缩略图,但是您没有传递任何值。相反,要么传递 None,要么首先不定义它们

`

import discord
from discord.ext import commands, tasks
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(title=None, description=None, color=0x00FF00)
    embed.add_field(name="I have been Killed", value=f"{member.display_name} has killed me! That's very unpog of them!", inline=False)
    embed.set_footer(text=f"Killed By: {ctx.author.name}")
    await ctx.send(embed=embed)
    await client.logout()

client.run('YOUR TOKEN HERE')

`