refactor: clean up some import and names
This commit is contained in:
parent
8d0bec4cf2
commit
d6bc67f17a
@ -1,9 +1,9 @@
|
||||
import enum
|
||||
from enum import Enum
|
||||
|
||||
import constants
|
||||
|
||||
|
||||
class Command(enum.Enum):
|
||||
class Command(Enum):
|
||||
CLEAR = "clear"
|
||||
CURRENT = "current"
|
||||
EXECUTE = "execute"
|
||||
|
12
core.py
12
core.py
@ -13,6 +13,7 @@ import disnake_paginator
|
||||
import commands
|
||||
import constants
|
||||
import utils
|
||||
from commands import Command as C
|
||||
from state import client, command_locks, idle_tracker
|
||||
|
||||
|
||||
@ -42,7 +43,6 @@ async def on_message(message, edited=False):
|
||||
if message.guild.id not in command_locks:
|
||||
command_locks[message.guild.id] = asyncio.Lock()
|
||||
|
||||
C = commands.Command
|
||||
try:
|
||||
match matched[0]:
|
||||
case C.RELOAD if message.author.id in constants.OWNERS:
|
||||
@ -136,13 +136,13 @@ async def on_voice_state_update(_, before, after):
|
||||
def is_empty(channel):
|
||||
return [m.id for m in (channel.members if channel else [])] == [client.user.id]
|
||||
|
||||
c = None
|
||||
channel = None
|
||||
if is_empty(before.channel):
|
||||
c = before.channel
|
||||
channel = before.channel
|
||||
elif is_empty(after.channel):
|
||||
c = after.channel
|
||||
if c:
|
||||
await c.guild.voice_client.disconnect()
|
||||
channel = after.channel
|
||||
if channel:
|
||||
await channel.guild.voice_client.disconnect()
|
||||
|
||||
|
||||
def rreload(reloaded_modules, module):
|
||||
|
10
state.py
10
state.py
@ -1,13 +1,13 @@
|
||||
import collections
|
||||
import time
|
||||
from collections import OrderedDict
|
||||
|
||||
import disnake
|
||||
|
||||
|
||||
class LimitedSizeDict(collections.OrderedDict):
|
||||
def __init__(self, *args, **kwds):
|
||||
self.size_limit = kwds.pop("size_limit", 1000)
|
||||
super().__init__(*args, **kwds)
|
||||
class LimitedSizeDict(OrderedDict):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.size_limit = kwargs.pop("size_limit", 1000)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._check_size_limit()
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
|
Loading…
x
Reference in New Issue
Block a user