我的不和谐机器人刚坏了,我不知道为什么(discord.py)

时间:2020-07-25 20:19:48

标签: python discord discord.py discord.py-rewrite

我的服务器上有一个不和谐的bot,直到今天它随机崩溃,并显示以下消息:

Traceback (most recent call last):
  File "bot.py", line 359, in <module>
    bot.run("BOT-TOKEN")
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 640, in run
    return future.result()
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 621, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 585, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 499, in connect
    await self._connect()
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 463, in _connect
    await self.ws.poll_event()
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\gateway.py", line 471, in poll_event
    await self.received_message(msg)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\gateway.py", line 425, in received_message
    func(data)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 750, in parse_guild_create
    guild = self._get_create_guild(data)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 725, in _get_create_guild
    guild._from_data(data)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\guild.py", line 296, in _from_data
    self._sync(guild)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\guild.py", line 323, in _sync
    self._add_channel(TextChannel(guild=self, data=c, state=self._state))
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\channel.py", line 107, in __init__
    self._update(guild, data)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\channel.py", line 131, in _update
    self._fill_overwrites(data)
  File "C:\Users\allis\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\abc.py", line 294, in _fill_overwrites
    self._overwrites.append(_Overwrites(id=overridden_id, **overridden))
TypeError: __new__() got an unexpected keyword argument 'deny_new'


我无法真正解密它,我感到非常困惑,因为昨天它工作正常。这是我的机器人代码:

import os
import discord
import asyncio
from discord.ext import commands
owner = "my discord name was here"
client = discord.Client()
bot_prefix="$"
bot = commands.Bot(command_prefix=bot_prefix)
message_counter = 0
warn_count = 0
poll_count1 = 0
poll_count2 = 0
mute_time = 0
afk = False
i=0
@bot.command()
async def poll(ctx, time, *, pollques):
    message = ctx.message
    await message.delete()
    if int(time) < 2880:
        timecounter = 0
        await ctx.send("A new poll has been opened!")
        await ctx.send("'{}' What do you think? React with :turtle: for option one, and :red_car: for option two. This poll will be active for {} mins".format(pollques, time))
        @bot.event
        async def wait_for_reaction(ctx, reaction: discord.Emoji):
            if reaction.emoji == ":turtle:":
                poll_count1 + 1
            if reaction.emoji == ":red_car:":
                poll_count2 + 1
        while timecounter <= int(time):
            timecounter += 1
            await asyncio.sleep(60)
            if timecounter == int(time):
                if poll_count1 < poll_count2:
                    await ctx.send("(Poll) Turtle wins!")
                else:
                    await ctx.send("(Poll) Red car wins!")
                    break
    else:
        await ctx.send(":x: (Poll) That time is too long! Must be under 2 days (2,880 minutes)!")
        

@bot.command()
@commands.has_permissions(manage_messages=True)
async def cc(ctx, limit1: int):
    channel = ctx.channel
    message = discord.Message
    messages = await channel.history(limit=limit1+1).flatten()
    for message in messages:
        await message.delete()

#mod/admin commands commands

@bot.command()
@commands.has_permissions(manage_messages=True)
async def warn(ctx, member: discord.Member, *, reason):
    try:
        message = ctx.message
        await message.delete()
        channel = await member.create_dm()
        await channel.send("You have been warned by a staff member, Reason: '{}'. If you do this again you will be kicked until further notice.".format(reason))
        await ctx.send("Member warned.")
        print("{} was warned for {}".format(member, reason))
    except Exception:
        await ctx.send(":x: Error. User may have blocked the bot.")

@bot.command()
@commands.has_permissions(manage_messages=True)
async def alert(ctx, channel: discord.TextChannel, *, message):
    try:
        message = ctx.message
        await message.delete()
        embed = discord.Embed(title="Alert!", color=0xff0000)
        embed.add_field(name="A staff member sent an alert!", value=message)
        embed.add_field(name="Triggered by:", value="{}".format(ctx.message.author))
        await channel.send("", embed=embed)
        await ctx.send(":white_check_mark: Message sent successfully!")
        
    except Exception:
        embed = discord.Embed(title="Error!")
        embed.add_field(name=":x: An error has occured!", value="Please contact wolverhulk13.")
        await ctx.send("", embed=embed)
        
@bot.command()
@commands.has_permissions(administrator=True)
async def ban(ctx, member: discord.Member, message_days, *, reason: str):
    try:
        message = ctx.message
        await message.delete()
        await ctx.send("THE BAN HAMMER HAS BEEN EPICALLY SLAMMED ON {} FOR {}!!! fs in the chat.".format(member, reason))
        await ctx.guild.ban(member)
    except Exception:
        await ctx.send(":x: Error. Ban unsuccesful. Check spelling?")
        
@bot.command()
@commands.has_permissions(administrator=True)
async def sban(ctx, member: discord.Member, message_days, *, reason: str):
    try:
        await author.send("You were silently banned from the server. Appeal at wolverhulk@voyagerfamily.com (my email).".format(member, reason))
        await ctx.guild.ban(member)
        message = ctx.message
        await message.delete()
    except Exception:
        await ctx.send(":x: Error. Ban unsuccesful. Check spelling?")
        

@bot.command()
@commands.has_permissions(administrator=True)
async def unban(ctx, member: discord.Member):
    message = ctx.message
    await message.delete()
    await ctx.send("{}'s ban has been lifted! Can I get a $celebrate?".format(member))
    await member.unban(member)
    
@bot.command()
@commands.has_permissions(administrator=True)
async def sunban(ctx, member: discord.Member):
    await author.send("You were silently unbanned. Have fun!".format(member))
    await member.unban(member)
    message = ctx.message
    await message.delete()

@bot.command()
@commands.has_permissions(manage_messages=True)
async def tempmute(ctx, member: discord.Member, mins: int):
    message = ctx.message
    await message.delete()
    global mute_time
    role = ctx.guild.get_role(694578104798150717)
    try:
        await member.add_roles(role)
        await ctx.send(":mute: {} muted for {} mins :mute:".format(member, mins))
        while mute_time <= int(mins):
            mute_time += 1
            await asyncio.sleep(60)
            if mute_time == int(mins):
                await member.remove_roles(role)
                await ctx.send(":microphone2: {} has been unmuted. :microphone2:".format(member))
    except Exception:
        await ctx.send(":x: Error. Mute unsuccesful. Check spelling?")
        
@bot.command()
@commands.has_permissions(manage_messages=True)
async def stempmute(ctx, member: discord.Member, mins: int):
    global mute_time
    role = ctx.guild.get_role(694578104798150717)
    try:
        message = ctx.message
        await message.delete()
        await ctx.send("You were muted for {} mins.".format(mins))
        await member.add_roles(role)
        while mute_time <= int(mins):
            mute_time += 1
            await asyncio.sleep(60)
            if mute_time == int(mins):
                await member.remove_roles(role)
                await author.send("Your were unmuted.")
        
    except Exception:
        await ctx.send(":x: Error. Mute unsuccesful. Check spelling?")
        
@bot.command()
@commands.has_permissions(manage_messages=True)
async def unmute(ctx, member: discord.Member):
    role = ctx.guild.get_role(694578104798150717)
    message = ctx.message
    await message.delete()
    try:
        await member.remove_roles(role)
        await ctx.send(":microphone2: {} has been unmuted. :microphone2:".format(member))
    except Exception:
        await ctx.send(":x: Error. Mute unsuccesful. Check spelling?")
        
@bot.command()
@commands.has_permissions(manage_messages=True)
async def sunmute(ctx, member: discord.Member):
    message = ctx.message
    await message.delete()
    role = ctx.guild.get_role(694578104798150717)
    try:
        await member.remove_roles(role)
        await member.send("You were unmuted.")
    except Exception:
        await ctx.send(":x: Error. Mute unsuccesful. Check spelling?")
        
@bot.command()
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member):
    role = ctx.guild.get_role(694578104798150717)
    await member.add_roles(role)
    await ctx.send(":mute: {} has been muted. :mute:".format(member))
    
@bot.command()
@commands.has_permissions(manage_messages=True)
async def smute(ctx, member: discord.Member):
    message = ctx.message
    await message.delete()
    role = ctx.guild.get_role(694578104798150717)
    await member.add_roles(role)
    await member.send("You were muted. Please appeal in #appeal or wait out your punishment.")
    
    
        

@bot.command()
@commands.has_role("Grape Gang")
async def gg(ctx):
    message = ctx.message
    await message.delete()
    await ctx.send(":grapes: Grape Gang :grapes:")

@bot.command()
@commands.has_permissions(administrator=True)
async def dm(ctx, member: discord.Member, *, message1):
    message = ctx.message
    await message.delete()
    ch = await member.create_dm()
    await ch.send("From {}: {}".format(ctx.author,message1))
    await ctx.send(":white_check_mark: Message sent!")



#error handler

@bot.event
async def on_command_error(ctx, error):

    if isinstance(error, commands.CheckFailure):
        await ctx.send(":x: You do not have the required role to use this command!")
        print(error)
    elif isinstance(error, commands.MissingPermissions):
        await ctx.send(":x: You do not have sufficient permission settings to use this command!")
        print(error)
    elif isinstance(error, commands.CommandNotFound):
        await ctx.send(":x: That command doesn't exist! You may have typed it wrong, try again. Use $help for more information")
        print(error)
    elif isinstance(error, commands.BotMissingPermissions):
        await ctx.send(":x: I'm missing the permissions to use this command!")
        print(error)
    elif isinstance(error, commands.MissingRequiredArgument):
        await ctx.send(":x: You missed an argument! For help do $help [command].")
        print(error)
    elif isinstance(error, commands.BadArgument):
        await ctx.send(":x: Wrong value type!")
        print(error)
    elif isinstance(error, commands.DisabledCommand):
        await ctx.send(":x: This command has been disabled!")
        print(error)
    elif isinstance(error, commands.NoPrivateMessage):
        await ctx.send(":x: This command can not be used inside private messages!")
    else:
        await ctx.send(":x: An unknown error has occured, please contact @wolverhulk13")
        print(error)
        
@bot.command()
@commands.has_permissions(manage_roles=True)
async def multiping(ctx, member: discord.Member, times:int, *, message):
    global i
    while i < times and times <= 10000:
        await ctx.send("{} {}".format(message, member.mention))
        i += 1
    if times > 10000:
        await ctx.send(":x: You are not permitted to execute this command that many times!")
    enter code here

my run token was here

有人可以帮我解决这个问题吗?我已经搜索了一段时间,无法在SO或任何网站上找到任何内容。

0 个答案:

没有答案