【发布时间】:2021-03-14 21:49:18
【问题描述】:
我试图修复它,但仍然没有。我 100% 确定问题出在 unban 文件上。因为一旦我删除嵌入,机器人就可以正常工作,所以是的,让我只显示代码......
主文件:
import discord
import os
import random
from discord.ext import commands
client = commands.Bot(command_prefix = '/')
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
client.run(My current key)
Cog Unban 文件:
import discord
from discord.ext import commands
class unban(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
@commands.has_permissions(ban_members=True)
async def unban(self, ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
unban = discord.Embed(title='UnBan Hammer Has Spoken! :boom:', description=f'**Moderator:** {ctx.author}\n **User UnBanned:** {member}, color=0xbd2929)
await ctx.channel.send(embed=unban)
def setup(client):
client.add_cog(unban(client))
【问题讨论】:
-
您是否对同一个文件使用了不同的编辑器,或者您是否从互联网上复制了一些 sn-ps?
标签: discord.py discord.py-rewrite python-3.8