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
|
import constants
|
||||||
|
|
||||||
|
|
||||||
class Command(enum.Enum):
|
class Command(Enum):
|
||||||
CLEAR = "clear"
|
CLEAR = "clear"
|
||||||
CURRENT = "current"
|
CURRENT = "current"
|
||||||
EXECUTE = "execute"
|
EXECUTE = "execute"
|
||||||
|
12
core.py
12
core.py
@ -13,6 +13,7 @@ import disnake_paginator
|
|||||||
import commands
|
import commands
|
||||||
import constants
|
import constants
|
||||||
import utils
|
import utils
|
||||||
|
from commands import Command as C
|
||||||
from state import client, command_locks, idle_tracker
|
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:
|
if message.guild.id not in command_locks:
|
||||||
command_locks[message.guild.id] = asyncio.Lock()
|
command_locks[message.guild.id] = asyncio.Lock()
|
||||||
|
|
||||||
C = commands.Command
|
|
||||||
try:
|
try:
|
||||||
match matched[0]:
|
match matched[0]:
|
||||||
case C.RELOAD if message.author.id in constants.OWNERS:
|
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):
|
def is_empty(channel):
|
||||||
return [m.id for m in (channel.members if channel else [])] == [client.user.id]
|
return [m.id for m in (channel.members if channel else [])] == [client.user.id]
|
||||||
|
|
||||||
c = None
|
channel = None
|
||||||
if is_empty(before.channel):
|
if is_empty(before.channel):
|
||||||
c = before.channel
|
channel = before.channel
|
||||||
elif is_empty(after.channel):
|
elif is_empty(after.channel):
|
||||||
c = after.channel
|
channel = after.channel
|
||||||
if c:
|
if channel:
|
||||||
await c.guild.voice_client.disconnect()
|
await channel.guild.voice_client.disconnect()
|
||||||
|
|
||||||
|
|
||||||
def rreload(reloaded_modules, module):
|
def rreload(reloaded_modules, module):
|
||||||
|
10
state.py
10
state.py
@ -1,13 +1,13 @@
|
|||||||
import collections
|
|
||||||
import time
|
import time
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
|
|
||||||
class LimitedSizeDict(collections.OrderedDict):
|
class LimitedSizeDict(OrderedDict):
|
||||||
def __init__(self, *args, **kwds):
|
def __init__(self, *args, **kwargs):
|
||||||
self.size_limit = kwds.pop("size_limit", 1000)
|
self.size_limit = kwargs.pop("size_limit", 1000)
|
||||||
super().__init__(*args, **kwds)
|
super().__init__(*args, **kwargs)
|
||||||
self._check_size_limit()
|
self._check_size_limit()
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user