我正在尝试执行 unban 命令,但出现了此错误。 "inconsistent use of tabs and spaces in indentation"
I'm trying to make an unban command but this error shows up. "inconsistent use of tabs and spaces in indentation"
我已经尝试修复它,但仍然没有。我 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 解禁文件:
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))
您在 cog 文件中的一行似乎缺少 '
,这应该可以解决:
unban = discord.Embed(title='UnBan Hammer Has Spoken! :boom:', description=f'**Moderator:** {ctx.author}\n **User UnBanned:** {member}', color=0xbd2929)
我已经尝试修复它,但仍然没有。我 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 解禁文件:
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))
您在 cog 文件中的一行似乎缺少 '
,这应该可以解决:
unban = discord.Embed(title='UnBan Hammer Has Spoken! :boom:', description=f'**Moderator:** {ctx.author}\n **User UnBanned:** {member}', color=0xbd2929)