Reformat entire project with ruff instead of black

This commit is contained in:
Rapptz
2025-08-18 20:15:44 -04:00
parent 3ef6272e07
commit 44a44e938f
88 changed files with 485 additions and 730 deletions

View File

@ -31,7 +31,6 @@ class CustomBot(commands.Bot):
self.initial_extensions = initial_extensions
async def setup_hook(self) -> None:
# here, we are loading extensions prior to sync to ensure we are syncing interactions defined in those extensions.
for extension in self.initial_extensions:
@ -53,7 +52,6 @@ class CustomBot(commands.Bot):
async def main():
# When taking over how the bot process is run, you become responsible for a few additional things.
# 1. logging

View File

@ -92,6 +92,7 @@ async def joined(interaction: discord.Interaction, member: Optional[discord.Memb
# accessing a menu within the client, usually via right clicking.
# It always takes an interaction as its first parameter and a Member or Message as its second parameter.
# This context menu command only works on members
@client.tree.context_menu(name='Show Join Date')
async def show_join_date(interaction: discord.Interaction, member: discord.Member):

View File

@ -60,6 +60,7 @@ async def add(
# Examples of these include int, str, float, bool, User, Member, Role, and any channel type.
# Since there are a lot of these, for brevity only a channel example will be included.
# This command shows how to only show text and voice channels to a user using the Union type hint
# combined with the VoiceChannel and TextChannel types.
@client.tree.command(name='channel-info')
@ -83,6 +84,7 @@ async def channel_info(interaction: discord.Interaction, channel: Union[discord.
# In order to support choices, the library has a few ways of doing this.
# The first one is using a typing.Literal for basic choices.
# On Discord, this will show up as two choices, Buy and Sell.
# In the code, you will receive either 'Buy' or 'Sell' as a string.
@client.tree.command()

View File

@ -4,10 +4,10 @@ import discord
from discord.ext import commands
import random
description = '''An example bot to showcase the discord.ext.commands extension
description = """An example bot to showcase the discord.ext.commands extension
module.
There are a number of utility commands being showcased here.'''
There are a number of utility commands being showcased here."""
intents = discord.Intents.default()
intents.members = True

View File

@ -97,10 +97,10 @@ class Music(commands.Cog):
"""Changes the player's volume"""
if ctx.voice_client is None:
return await ctx.send("Not connected to a voice channel.")
return await ctx.send('Not connected to a voice channel.')
ctx.voice_client.source.volume = volume / 100
await ctx.send(f"Changed volume to {volume}%")
await ctx.send(f'Changed volume to {volume}%')
@commands.command()
async def stop(self, ctx):
@ -116,8 +116,8 @@ class Music(commands.Cog):
if ctx.author.voice:
await ctx.author.voice.channel.connect()
else:
await ctx.send("You are not connected to a voice channel.")
raise commands.CommandError("Author not connected to a voice channel.")
await ctx.send('You are not connected to a voice channel.')
raise commands.CommandError('Author not connected to a voice channel.')
elif ctx.voice_client.is_playing():
ctx.voice_client.stop()
@ -126,7 +126,7 @@ intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(
command_prefix=commands.when_mentioned_or("!"),
command_prefix=commands.when_mentioned_or('!'),
description='Relatively simple music bot example',
intents=intents,
)

View File

@ -40,7 +40,7 @@ async def userinfo_error(ctx: commands.Context, error: commands.CommandError):
# If the conversion above fails for any reason, it will raise `commands.BadArgument`
# so we handle this in this error handler:
if isinstance(error, commands.BadArgument):
return await ctx.send('Couldn\'t find that user.')
return await ctx.send("Couldn't find that user.")
# The default `on_command_error` will ignore errors from this command
# because we made our own command-specific error handler,
# so we need to log tracebacks ourselves.

View File

@ -55,5 +55,5 @@ async def guess(ctx, number: int):
# let people do very malicious things with your
# bot. Try to use a file or something to keep
# them private, and don't commit it to GitHub
token = "your token here"
token = 'your token here'
bot.run(token)

View File

@ -70,7 +70,7 @@ class Feedback(discord.ui.Modal, title='Feedback'):
client = MyClient()
@client.tree.command(guild=TEST_GUILD, description="Submit feedback")
@client.tree.command(guild=TEST_GUILD, description='Submit feedback')
async def feedback(interaction: discord.Interaction):
# Send the modal with an instance of our `Feedback` class
# Since modals require an interaction, they cannot be done as a response to a text command.

View File

@ -84,7 +84,7 @@ class TimeoutModal(discord.ui.Modal, title='Timeout Member'):
client = MyClient()
@client.tree.command(guild=TEST_GUILD, description="Timeout a member")
@client.tree.command(guild=TEST_GUILD, description='Timeout a member')
async def timeout(interaction: discord.Interaction, member: discord.Member):
# Send the modal with an instance of our `TimeoutModal` class
# Since modals require an interaction, they cannot be done as a response to a text command.

View File

@ -5,7 +5,8 @@ from discord.ext import commands
intents = discord.Intents.default()
bot = commands.Bot(command_prefix=commands.when_mentioned, description="Nothing to see here!", intents=intents)
bot = commands.Bot(command_prefix=commands.when_mentioned, description='Nothing to see here!', intents=intents)
# the `hidden` keyword argument hides it from the help command.
@bot.group(hidden=True)

View File

@ -22,7 +22,6 @@ class CounterBot(commands.Bot):
# Define a simple View that gives us a counter button
class Counter(discord.ui.View):
# Define the actual button
# When pressed, this increments the number displayed until it hits 5.
# When it hits 5, the counter button is disabled and it turns green.

View File

@ -3,12 +3,12 @@
import discord
from discord.ext import commands
# Defines a custom Select containing colour options
# that the user can choose. The callback function
# of this class is called when the user changes their choice
class Dropdown(discord.ui.Select):
def __init__(self):
# Set the options that will be presented inside the dropdown
options = [
discord.SelectOption(label='Red', description='Your favourite colour is red', emoji='🟥'),

View File

@ -15,6 +15,7 @@ import re
# `counter:5:user:80088516616269824` where the first number is the current count and the
# second number is the user ID who owns the button.
# Note that custom_ids can only be up to 100 characters long.
class DynamicCounter(
discord.ui.DynamicItem[discord.ui.Button],

View File

@ -22,7 +22,6 @@ class EphemeralCounterBot(commands.Bot):
# Define a simple View that gives us a counter button
class Counter(discord.ui.View):
# Define the actual button
# When pressed, this increments the number displayed until it hits 5.
# When it hits 5, the counter button is disabled and it turns green.

View File

@ -9,24 +9,24 @@ import enum
class FruitType(enum.Enum):
apple = "Apple"
banana = "Banana"
orange = "Orange"
grape = "Grape"
mango = "Mango"
watermelon = "Watermelon"
coconut = "Coconut"
apple = 'Apple'
banana = 'Banana'
orange = 'Orange'
grape = 'Grape'
mango = 'Mango'
watermelon = 'Watermelon'
coconut = 'Coconut'
@property
def emoji(self) -> str:
emojis = {
"Apple": "🍎",
"Banana": "🍌",
"Orange": "🍊",
"Grape": "🍇",
"Mango": "🥭",
"Watermelon": "🍉",
"Coconut": "🥥",
'Apple': '🍎',
'Banana': '🍌',
'Orange': '🍊',
'Grape': '🍇',
'Mango': '🥭',
'Watermelon': '🍉',
'Coconut': '🥥',
}
return emojis[self.value]

View File

@ -4,6 +4,7 @@ from typing import List
from discord.ext import commands
import discord
# Defines a custom button that contains the logic of the game.
# The ['TicTacToe'] bit is for type hinting purposes to tell your IDE or linter
# what the type of `self.view` is. It is not required.