-
Notifications
You must be signed in to change notification settings - Fork 1
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
295e066
commit be10ad9
Showing
12 changed files
with
67 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: Add roll command | ||
pull_request: | ||
type: features |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,52 @@ | ||
import asyncio | ||
import random | ||
|
||
import discord | ||
from discord.ext import commands | ||
|
||
from mgylabs.i18n import __ | ||
from mgylabs.utils.config import resource_path | ||
from mgylabs.utils.LogEntry import DiscordEventLogEntry | ||
|
||
from .utils import Emoji | ||
from .utils.feature import Feature | ||
from .utils.MGCert import Level, MGCertificate | ||
from .utils.MsgFormat import MsgFormatter | ||
|
||
|
||
@commands.hybrid_command() | ||
@MGCertificate.verify(level=Level.TRUSTED_USERS) | ||
@Feature.Experiment() | ||
async def roll(ctx: commands.Context): | ||
""" | ||
Roll a dice. | ||
""" | ||
embed = MsgFormatter.get(ctx, description=f"{Emoji.typing} {__('Rolling...')}") | ||
dice_file = discord.File(resource_path("app/bot/Game Die.png"), filename="dice.png") | ||
embed.set_author(name="Dice", icon_url="attachment://dice.png") | ||
|
||
msg: discord.Message = await ctx.send(embed=embed, file=dice_file) | ||
|
||
result = random.randint(1, 6) | ||
|
||
DiscordEventLogEntry.Add(ctx, "DiceResult", {"result": result}) | ||
|
||
dice_file = discord.File(resource_path("app/bot/Game Die.png"), filename="dice.png") | ||
|
||
number_file_name = f"Keycap Digit {result}.png" | ||
discord_number_file_name = number_file_name.replace(" ", "") | ||
number_file = discord.File( | ||
resource_path(f"app/bot/{number_file_name}"), | ||
filename=discord_number_file_name, | ||
) | ||
|
||
embed.description = None | ||
embed.set_thumbnail(url=f"attachment://{discord_number_file_name}") | ||
|
||
await asyncio.sleep(1) | ||
|
||
await msg.edit(embed=embed, attachments=[dice_file, number_file]) | ||
|
||
|
||
async def setup(bot: commands.Bot): | ||
bot.add_command(roll) |
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
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