Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions discord_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

import discord
from discord import app_commands

# Provide fallback implementations for slash commands and Option when Pycord is unavailable.
def slash_command(*args, **kwargs):
def decorator(func):
app_cmd = app_commands.command(*args, **kwargs)
async def wrapper(interaction: discord.Interaction, *fargs, **ffkwargs):
# Provide respond and send compatibility for interactions similar to Pycord.
interaction.respond = interaction.response.send_message
interaction.send = interaction.followup.send
return await func(interaction, *fargs, **ffkwargs)
return app_cmd(wrapper)
return decorator

class ApplicationContext(discord.Interaction):
"""Fallback ApplicationContext for discord.py."""
pass


def Option(annotation, description=None, **kwargs):
"""
Fallback Option for discord.py.
In discord.py, use type annotations directly.
"""
return annotation

class SlashCommandGroup(app_commands.Group):
"""Fallback SlashCommandGroup for discord.py."""
pass
7 changes: 5 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from datetime import datetime

import discord
from discord.commands import slash_command, ApplicationContext
try::
from discord.commands import slash_command, ApplicationContext
except ImportError:
from discord_compat import slash_command, ApplicationContext
from discord.ext import commands

import config
Expand All @@ -25,7 +28,7 @@
fishdb = S_SQLite("static/fishing.db")


class EpBot(discord.AutoShardedBot):
class EpBot(dcommands.AutoShardedBot):
def __init__(self):
super().__init__(
help_command=None,
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
aiofiles==24.1.0

aiohappyeyeballs==2.4.4
aiohttp==3.11.11
aiopg==1.4.0
Expand Down Expand Up @@ -31,7 +32,7 @@ platformdirs==4.3.6
propcache==0.2.1
psycopg2==2.9.10
psycopg2-binary==2.9.10
py-cord==2.6.1

pycodestyle==2.12.1
pycparser==2.22
PyJWT==2.10.1
Expand All @@ -50,3 +51,5 @@ tzdata==2025.1
tzlocal==5.2
urllib3==2.3.0
yarl==1.18.3

discord.py==2.3.2