Compare commits
7 Commits
f0e1325a6c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
7d6373e38b
|
|||
|
3a5e182970
|
|||
|
45b6ccdf22
|
|||
|
0a80999ca7
|
|||
|
8194268ce1
|
|||
|
ed3afdbeae
|
|||
|
3ca6f487c6
|
6
.envrc
Normal file
6
.envrc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
dotenv
|
||||||
|
|
||||||
|
export VIRTUAL_ENV=."venv"
|
||||||
|
layout python
|
||||||
|
|
||||||
|
use flake
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
.direnv
|
||||||
.env
|
.env
|
||||||
.venv
|
.venv
|
||||||
__pycache__
|
__pycache__
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from ... import utils
|
from ... import utils
|
||||||
|
from ...state import players
|
||||||
from .utils import command_allowed
|
from .utils import command_allowed
|
||||||
|
|
||||||
|
|
||||||
@@ -19,5 +20,8 @@ async def leave(message):
|
|||||||
if not command_allowed(message):
|
if not command_allowed(message):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if message.guild.id in players:
|
||||||
|
del players[message.guild.id]
|
||||||
await message.guild.voice_client.disconnect()
|
await message.guild.voice_client.disconnect()
|
||||||
|
|
||||||
await utils.add_check_reaction(message)
|
await utils.add_check_reaction(message)
|
||||||
|
|||||||
@@ -251,7 +251,8 @@ async def skip(message):
|
|||||||
if not command_allowed(message):
|
if not command_allowed(message):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not players[message.guild.id] and not players[message.guild.id].queue:
|
if players[message.guild.id] and not players[message.guild.id].queue:
|
||||||
|
del players[message.guild.id]
|
||||||
message.guild.voice_client.stop()
|
message.guild.voice_client.stop()
|
||||||
await utils.reply(
|
await utils.reply(
|
||||||
message,
|
message,
|
||||||
|
|||||||
@@ -31,34 +31,34 @@ REACTIONS = {
|
|||||||
"pizza": ["🍕"],
|
"pizza": ["🍕"],
|
||||||
}
|
}
|
||||||
RELOADABLE_MODULES = [
|
RELOADABLE_MODULES = [
|
||||||
"arguments",
|
"errornocord.arguments",
|
||||||
"audio",
|
"errornocord.audio",
|
||||||
"audio.discord",
|
"errornocord.audio.discord",
|
||||||
"audio.queue",
|
"errornocord.audio.queue",
|
||||||
"audio.utils",
|
"errornocord.audio.utils",
|
||||||
"audio.youtubedl",
|
"errornocord.audio.youtubedl",
|
||||||
"commands",
|
"errornocord.commands",
|
||||||
"commands.bot",
|
"errornocord.commands.bot",
|
||||||
"commands.tools",
|
"errornocord.commands.tools",
|
||||||
"commands.utils",
|
"errornocord.commands.utils",
|
||||||
"commands.voice",
|
"errornocord.commands.voice",
|
||||||
"commands.voice.channel",
|
"errornocord.commands.voice.channel",
|
||||||
"commands.voice.playback",
|
"errornocord.commands.voice.playback",
|
||||||
"commands.voice.playing",
|
"errornocord.commands.voice.playing",
|
||||||
"commands.voice.queue",
|
"errornocord.commands.voice.queue",
|
||||||
"commands.voice.sponsorblock",
|
"errornocord.commands.voice.sponsorblock",
|
||||||
"commands.voice.utils",
|
"errornocord.commands.voice.utils",
|
||||||
"constants",
|
"errornocord.constants",
|
||||||
"core",
|
"errornocord.core",
|
||||||
"events",
|
"errornocord.events",
|
||||||
"extra",
|
"errornocord.extra",
|
||||||
"fun",
|
"errornocord.fun",
|
||||||
"sponsorblock",
|
"errornocord.sponsorblock",
|
||||||
"tasks",
|
"errornocord.tasks",
|
||||||
"utils",
|
"errornocord.utils",
|
||||||
"utils.common",
|
"errornocord.utils.common",
|
||||||
"utils.discord",
|
"errornocord.utils.discord",
|
||||||
"voice",
|
"errornocord.voice",
|
||||||
"yt_dlp",
|
"yt_dlp",
|
||||||
"yt_dlp.version",
|
"yt_dlp.version",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import disnake_paginator
|
|||||||
from . import commands, utils
|
from . import commands, utils
|
||||||
from .commands import Command as C
|
from .commands import Command as C
|
||||||
from .constants import EMBED_COLOR, OWNERS, PREFIX, RELOADABLE_MODULES
|
from .constants import EMBED_COLOR, OWNERS, PREFIX, RELOADABLE_MODULES
|
||||||
from .state import client, command_cooldowns, command_locks, idle_tracker
|
from .state import client, command_cooldowns, command_locks, idle_tracker, players
|
||||||
|
|
||||||
|
|
||||||
async def on_message(message, edited=False):
|
async def on_message(message, edited=False):
|
||||||
@@ -148,18 +148,20 @@ async def on_message(message, edited=False):
|
|||||||
command_locks[(message.guild.id, message.author.id)].release()
|
command_locks[(message.guild.id, message.author.id)].release()
|
||||||
|
|
||||||
|
|
||||||
async def on_voice_state_update(_, before, after):
|
async def on_voice_state_update(member, before, after):
|
||||||
def is_empty(channel):
|
def is_alone(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]
|
||||||
|
|
||||||
channel = None
|
if member.id == client.user.id and is_alone(after.channel):
|
||||||
if is_empty(before.channel):
|
if before.channel.guild.id in players:
|
||||||
channel = before.channel
|
del players[before.channel.guild.id]
|
||||||
elif is_empty(after.channel):
|
await after.channel.guild.voice_client.disconnect()
|
||||||
channel = after.channel
|
return
|
||||||
|
|
||||||
if channel:
|
if is_alone(before.channel):
|
||||||
await channel.guild.voice_client.disconnect()
|
if before.channel.guild.id in players:
|
||||||
|
del players[before.channel.guild.id]
|
||||||
|
await before.channel.guild.voice_client.disconnect()
|
||||||
|
|
||||||
|
|
||||||
def rreload(reloaded_modules, module):
|
def rreload(reloaded_modules, module):
|
||||||
@@ -183,8 +185,8 @@ def rreload(reloaded_modules, module):
|
|||||||
|
|
||||||
def reload(*_):
|
def reload(*_):
|
||||||
reloaded_modules = set()
|
reloaded_modules = set()
|
||||||
rreload(reloaded_modules, __import__("core"))
|
rreload(reloaded_modules, __import__("errornocord.core"))
|
||||||
rreload(reloaded_modules, __import__("extra"))
|
rreload(reloaded_modules, __import__("errornocord.extra"))
|
||||||
for module in filter(
|
for module in filter(
|
||||||
lambda v: inspect.ismodule(v) and v.__name__ in RELOADABLE_MODULES,
|
lambda v: inspect.ismodule(v) and v.__name__ in RELOADABLE_MODULES,
|
||||||
globals().values(),
|
globals().values(),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import string
|
|||||||
import disnake
|
import disnake
|
||||||
from youtube_transcript_api._api import YouTubeTranscriptApi
|
from youtube_transcript_api._api import YouTubeTranscriptApi
|
||||||
|
|
||||||
from state import client, kill, players
|
from .state import client, kill, players
|
||||||
|
|
||||||
|
|
||||||
async def transcript(
|
async def transcript(
|
||||||
|
|||||||
@@ -8,3 +8,6 @@ errornocord = "errornocord.main:main"
|
|||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
where = ["."]
|
where = ["."]
|
||||||
include = ["errornocord*"]
|
include = ["errornocord*"]
|
||||||
|
|
||||||
|
[tool.basedpyright]
|
||||||
|
typeCheckingMode = "basic"
|
||||||
|
|||||||
Reference in New Issue
Block a user