-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99819f9
commit 9117539
Showing
4 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import Any, Sequence | ||
|
||
from discord.app_commands import Command | ||
from discord.ext import commands | ||
from discord.ext.commands import Bot, Context | ||
|
||
from discord_bot.checks import is_in_channel | ||
from . import settings | ||
|
||
def _build_command(name: str, channels: set[str] | None, response: Sequence[str]) -> Command[Any, Any, Any]: | ||
async def _(ctx: Context[Bot]) -> None: | ||
for resp in response: | ||
await ctx.send(resp) | ||
|
||
f = _ | ||
f.__name__ = name | ||
if channels: | ||
f = is_in_channel(channels)(f) | ||
|
||
return commands.command(name=name)(f) | ||
|
||
def add_easy_commands(bot: Bot) -> None: | ||
for command in settings.COMMANDS: | ||
bot.add_command(_build_command(*command)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters