Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update master to use the latest versions of dependencies. #85

Merged
merged 24 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6e998ab
Add ruff in place of isort and flake8
Ev-1 Apr 26, 2023
d8836f7
Run linter
Ev-1 Apr 26, 2023
737f145
Update github workflow to use ruff
Ev-1 Apr 26, 2023
6eb360d
Merge pull request #80 from r-Norge/feature/ruff_linter
Ev-1 Apr 28, 2023
74cf951
Add support for scroller with more than 25 pages. Fixes #79
Ev-1 Apr 28, 2023
7cf3acc
Remove _add_truncated_range
Ev-1 Apr 28, 2023
4011ac8
Add pythonpath to pytest in pyproject.toml. Rename navbar range tests
Ev-1 Apr 28, 2023
62ac8f4
Merge pull request #81 from r-Norge/feature/fix_long_queue_page_select
Ev-1 Apr 28, 2023
7288710
Add selector_button_callback decorator
Ev-1 May 5, 2023
61d0bfb
Merge pull request #82 from r-Norge/feature/callback_decorators
Ev-1 May 8, 2023
ef37fe2
Update dependencies, force disconnect on empty voice, more typing
Ev-1 Jun 22, 2023
7884b15
Merge pull request #83 from r-Norge/feature/library_updates
Ev-1 Jun 22, 2023
19f51ba
Update to lavalink.py v5
Ev-1 Mar 9, 2024
1c1466a
Update ruff and fix linting issues
Ev-1 Mar 9, 2024
b0b4005
Merge pull request #84 from r-Norge/feature/lavalinkpy5
Ev-1 Mar 9, 2024
c5c246e
Update voice client for newer d.py versions
Ev-1 Mar 17, 2024
c638196
Merge pull request #86 from r-Norge/feature/connect_fix
Ev-1 Mar 19, 2024
45972fb
Update voice client for newer d.py versions
Ev-1 Mar 17, 2024
ffc39cc
Update nodemanager to handle new Node type
Ev-1 Mar 27, 2024
429a145
Merge pull request #87 from r-Norge/feature/node_fix
Ev-1 Mar 28, 2024
8724b23
Update readme docker example
Ev-1 Mar 28, 2024
ec23397
Fix reconnect command
Ev-1 Mar 28, 2024
49100f7
Add extra logging to track end event.
Ev-1 Mar 28, 2024
687f76d
Update docker python image
Ev-1 Mar 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,9 @@ on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
env:
CheckFiles: "bot.py musicbot/"
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/[email protected]
with:
python-version: 3.10.7

- name: Lint with flake8
run: |
pip install flake8
flake8 ${CheckFiles}

- name: Check with Isort
run: |
pip install isort
isort --check --sp setup.cfg ${CheckFiles}
- uses: chartboost/ruff-action@v1

test:
runs-on: ubuntu-latest
Expand Down
30 changes: 15 additions & 15 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# Discord Packages
import discord
import lavalink
from discord.ext import commands
from discord.flags import MemberCacheFlags

import codecs
import os
import time
import traceback
from argparse import ArgumentParser, RawTextHelpFormatter
from typing import Optional

import discord
import lavalink
from discord.ext import commands
from discord.flags import MemberCacheFlags

import aiohttp
import yaml

# Bot Utilities
from musicbot.utils.localisation import Aliaser, LocalizedContext, Localizer, LocalizerWrapper
from musicbot.utils.logger import BotLogger
from musicbot.utils.settingsmanager import Settings
Expand Down Expand Up @@ -49,12 +47,12 @@ def __init__(self, datadir, debug: bool = False):
self.settings = Settings(datadir, **conf['default server settings'])
self.APIkeys = conf.get('APIkeys', {})

self.localizer = Localizer(conf.get('locale path', "./localization"), conf.get('locale', 'en_en'))
self.aliaser = Aliaser(conf.get('locale path', "./localization"), conf.get('locale', 'en_en'))
self.localizer: Localizer = Localizer(conf.get('locale path', "./localization"), conf.get('locale', 'en_en'))
self.aliaser: Aliaser = Aliaser(conf.get('locale path', "./localization"), conf.get('locale', 'en_en'))

self.datadir = datadir
self.debug = debug
self.main_logger = logger
self.debug: bool = debug
self.main_logger: BotLogger = logger
self.logger = self.main_logger.bot_logger.getChild("Bot")
self.logger.debug("Debug: %s" % debug)
self.lavalink: Optional[lavalink.Client] = None
Expand All @@ -68,7 +66,7 @@ async def process_commands(self, message):
ctx = await self.get_context(message, cls=LocalizedContext)

# Replace aliases with commands
ctx = self.aliaser.get_command(ctx)
ctx: LocalizedContext = self.aliaser.get_command(ctx)

# Add the localizer
if ctx.command and ctx.command.cog_name:
Expand Down Expand Up @@ -99,9 +97,11 @@ async def on_ready(self):
self.logger.debug("Bot Ready")

self.session = aiohttp.ClientSession(loop=self.loop)
await self.change_presence(activity=discord.Game(type=0,
name=conf["bot"]["playing status"]),
status=discord.Status.online)

if presence := conf["bot"]["playing status"]:
await self.change_presence(activity=discord.Game(type=0,
name=presence),
status=discord.Status.online)

def run(self):
try:
Expand Down
22 changes: 6 additions & 16 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ default:
# Make a new virtual environment
[private]
make_venv:
python3.10 -m venv {{env_name}}
python3 -m venv {{env_name}}
{{python}} -m pip install --upgrade pip
{{python}} -m pip install -r requirements.txt
{{python}} -m pip install flake8
{{python}} -m pip install isort
{{python}} -m pip install pytest

# Make the environment if it does not exit
[private]
Expand All @@ -24,23 +21,16 @@ run: venv
{{python}} bot.py

# Run with debug logging enabled
debug: run
--debug
debug: venv
{{python}} bot.py --debug

clean:
rm -rf {{env_name}}
# Lint with flake8
flake: venv
{{python}} -m flake8 bot.py musicbot

# Fix import order with isort
isort: venv
{{python}} -m isort --sp setup.cfg bot.py musicbot

# Run both isort and flake8
lint: venv
just isort
just flake
# Run ruff
lint: venv
{{python}} -m ruff check . --fix

# Run tests
test: venv
Expand Down
11 changes: 5 additions & 6 deletions musicbot/cogs/cogmanager.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Discord Packages
from discord.ext import commands

import traceback

from discord.ext import commands

from bot import MusicBot
from musicbot.utils.userinteraction import ClearMode, Scroller

from ..utils.userinteraction import ClearOn, Scroller
from .helpformatter import commandhelper


Expand All @@ -21,7 +20,7 @@ async def _cogmanager(self, ctx):
ctx.localizer.prefix = 'help' # Ensure the bot looks for locales in the context of help, not cogmanager.
paginator = commandhelper(ctx, ctx.command, ctx.invoker, include_subcmd=True)
scroller = Scroller(ctx, paginator)
await scroller.start_scrolling(ClearOn.AnyExit)
await scroller.start_scrolling(ClearMode.AnyExit)

@_cogmanager.command()
@commands.is_owner()
Expand Down Expand Up @@ -59,7 +58,7 @@ async def _reload(self, ctx, *, module):
@_cogmanager.command(name='reloadall')
@commands.is_owner()
async def _relaod_all(self, ctx):
"""Reloads all extensions"""
"""Reloads all extensions."""
try:
for extension in self.bot.extensions:
if extension == 'musicbot.cogs.cogmanager':
Expand Down
9 changes: 4 additions & 5 deletions musicbot/cogs/errors.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Discord Packages
import sys

import discord
from discord.ext import commands

import sys

from bot import MusicBot
from musicbot.utils.userinteraction import ClearMode, Scroller

from ..utils.userinteraction import ClearOn, Scroller
from .helpformatter import commandhelper
from .music import music_errors

Expand All @@ -31,7 +30,7 @@ async def on_command_error(self, ctx, err):
isinstance(err, commands.BadArgument)):
paginator = commandhelper(ctx, ctx.command, ctx.invoker, include_subcmd=False)
scroller = Scroller(ctx, paginator)
await scroller.start_scrolling(ClearOn.AnyExit)
await scroller.start_scrolling(ClearMode.AnyExit)

if isinstance(err, (commands.CommandNotFound)):
return
Expand Down
8 changes: 4 additions & 4 deletions musicbot/cogs/helpformatter/help.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Discord Packages
from discord.ext import commands

from bot import MusicBot
from musicbot.utils.userinteraction.scroller import ClearMode, Scroller

from ...utils.userinteraction.scroller import ClearOn, Scroller
from .helpformatter import coghelper, commandhelper, helper, prefix_cleaner


class Help(commands.Cog):
"""Help command"""
"""Help command."""

def __init__(self, bot: MusicBot):
self.bot: MusicBot = bot

Expand All @@ -35,4 +35,4 @@ async def help(self, ctx): # Takes no args because reasons(using the view direc
paginator = await coghelper(ctx, thing)

scroller = Scroller(ctx, paginator)
await scroller.start_scrolling(ClearOn.Timeout | ClearOn.ManualExit)
await scroller.start_scrolling(ClearMode.Timeout | ClearMode.ManualExit)
11 changes: 5 additions & 6 deletions musicbot/cogs/helpformatter/helpformatter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Discord Packages
from discord.ext import commands

import re

from ...utils.userinteraction import HelpPaginator
from discord.ext import commands

from musicbot.utils.userinteraction import HelpPaginator

usermention = r"<@!?\d{17,19}>"

Expand Down Expand Up @@ -91,14 +90,14 @@ def commandhelper(ctx, command, invoker, include_subcmd=True):
description = f"```{description}```"
paginator = HelpPaginator(max_size=5000, max_fields=5, color=ctx.me.color, title=cmd, description=description)

for sub_command, sub_cmd_dict in sub_commands.items():
for _sub_command, sub_cmd_dict in sub_commands.items():
paginator.add_command_field(sub_cmd_dict)
paginator.add_page_indicator(ctx.localizer, "{pageindicator}", _prefix=ctx.prefix)
return paginator


def prefix_cleaner(ctx):
""" Changes mentions to prefixes when commands are invoked with mentions."""
"""Changes mentions to prefixes when commands are invoked with mentions."""
bot = ctx.bot
prefix = ctx.prefix
if re.match(usermention, prefix):
Expand Down
18 changes: 6 additions & 12 deletions musicbot/cogs/misc.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Discord Packages
import platform
import time

import discord
from discord.ext import commands
from lavalink import __version__ as LavalinkVersion

import platform
import time

from bot import MusicBot

from ..utils import bot_version
from musicbot.utils import bot_version


class Misc(commands.Cog):
Expand Down Expand Up @@ -48,9 +46,7 @@ async def _guilds(self, ctx):

@commands.command()
async def musicinfo(self, ctx):
"""
Info about the music player
"""
"""Info about the music player."""
embed = discord.Embed(title='{music.title}', color=ctx.me.color)

listeners = 0
Expand Down Expand Up @@ -79,9 +75,7 @@ async def reload_alias(self, ctx):

@commands.command()
async def info(self, ctx):
"""
Info about the bot
"""
"""Info about the bot."""
guilds = len(self.bot.guilds)
members = len(self.bot.users)

Expand Down
Loading
Loading