#_pickle.PicklingError Can't pickle class 'discord.enums._EnumValue_VoiceRegion' attribute lookup

1 messages · Page 1 of 1 (latest)

keen latch
#

I can't schedule unban. Someone can help?

async def UnbanUserTask(user, admin):
    guild = admin.guild
    await guild.unban(user)
    audit = guild.get_channel(976679614317461575) 
    embed = discord.Embed(
        title=f'{user.name} unbanned after ban from {admin.name}.',
        color=discord.Color.blurple()
    )
    return await audit.send(embed=embed)


class UpsScheduler:

    def __init__(self, scheduler: AsyncIOScheduler, jobstore: MongoDBJobStore) -> None:
        self.scheduler = scheduler
        self.scheduler.add_jobstore(MongoDBJobStore(database="UpsShelter", collection="SCHEDULES", client=jobstore))
        self.scheduler.start()


    def UnBanSchedule(self, to_ban: datetime, user: discord.Member, admin: discord.Member):
        return self.scheduler.add_job(
            UnbanUserTask,
            "cron",
            args=[user, admin],
            day=to_ban.day,
            hour=to_ban.hour,
            minute=to_ban.minute,
            year=to_ban.year,
            month=to_ban.month,
            misfire_grace_time=600
        )
#

Traceback:

Ignoring exception in command ban:
Traceback (most recent call last):
  File "F:\lib\site-packages\discord\commands\core.py", line 122, in wrapped
    ret = await coro(arg)
  File "F:\lib\site-packages\discord\commands\core.py", line 825, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\upsto\OneDrive\Github\UpsBotV2\discordbot\cogs\slashcmds.py", line 146, in BanCommand
    scheduler.UnBanSchedule(to_ban, user, ctx.author)
  File "c:\Users\upsto\OneDrive\Github\UpsBotV2\discordbot\ext\schedulerUps.py", line 29, in UnBanSchedule
    return self.scheduler.add_job(
  File "F:\lib\site-packages\apscheduler\schedulers\base.py", line 447, in add_job
    self._real_add_job(job, jobstore, replace_existing)
  File "F:\lib\site-packages\apscheduler\schedulers\base.py", line 871, in _real_add_job
    store.add_job(job)
  File "F:\lib\site-packages\apscheduler\jobstores\mongodb.py", line 90, in add_job
    'job_state': Binary(pickle.dumps(job.__getstate__(), self.pickle_protocol))
_pickle.PicklingError: Can't pickle <class 'discord.enums._EnumValue_VoiceRegion'>: attribute lookup _EnumValue_VoiceRegion on discord.enums failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "F:\lib\site-packages\discord\commands\core.py", line 331, in invoke
    await injected(ctx)
  File "F:\lib\site-packages\discord\commands\core.py", line 128, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: PicklingError: Can't pickle <class 'discord.enums._EnumValue_VoiceRegion'>: attribute lookup _EnumValue_VoiceRegion on discord.enums failed
frosty spear
#

looks like an issue with the scheduler

keen latch
#

idk how i can realise tempban without apscheduler

frosty spear
#

use an asyncio task

keen latch
frosty spear
#

p.search python how to make an asyncio task

restive jayBOT
#

Use the buttons below to search for python how to make an asyncio task on the internet.

keen latch
frosty spear
#

run asyncio.sleep at the start of it

#

so it will wait

keen latch
#

it's not working with 10+ days

#

it's a very bad realisation

#

and hosting is heroku, heroku restarting your app every 12 hours.

#

it brokes everything...

frosty spear
#

what can I do man