1

So, I have been working on a killswitch for my bot in discord.py, and I've hit a stump. My kill switch is not working and it's not giving me an error. If anyone can help I would very much appreciate it.

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 Answers1

-2

The first thing I saw in your code was when you defined the embed you only defined the color. I went ahead and added the other fields for title and description and set them to None

The second issue I saw was that when adding the field value, you called member.name however you were supposed to call member.display_name

The final two issues are you were defining an embed image and thumbnail, however you did not pass any values. Instead, either pass None or do not define them in the first place

`

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')

`

  • There's no need to initialize embed fields as None, they're empty by default if you don't give them a value. `member.name` isn't wrong either - `display_name` is something else, `name` exists as well. – stijndcl Feb 17 '21 at 08:09