Module realm_bot.roll.response
Roll response formats (verbose vs. compact)
Functions
def compact(ctx: discord.ext.commands.context.Context,
dice: str,
results: realm_schema.dice_rolls.RollResults) ‑> str-
Expand source code
def compact(ctx: Context, dice: str, results: RollResults) -> str: """ Compact output for dice roll results. Args: dice: The original dice roll string results: The list of results for the roll segments Returns: The message to be posted to the channel """ rolls = "* :game_die: *".join([s.work for s in results.results if s.work]) totals = [s.total for s in results.results] grand_total = sum(totals) success = _success_text(results, grand_total) return "".join( ( f"{ctx.author.mention} ", f"`{dice}` | :game_die: *{rolls}* | ", f":checkered_flag: {totals} ", f"= **{grand_total}**", f" | {success}" if success else "", ) )Compact output for dice roll results.
Args
dice- The original dice roll string
results- The list of results for the roll segments
Returns
The message to be posted to the channel
def segment_icon(segment: realm_schema.dice_rolls.SegmentResult)-
Expand source code
def segment_icon(segment: SegmentResult): """Get emote icon for displaying segment result in an Embed.""" if segment.work: return ":game_die:" return ":1234:"Get emote icon for displaying segment result in an Embed.
def verbose(ctx: discord.ext.commands.context.Context,
dice: str,
results: realm_schema.dice_rolls.RollResults) ‑> discord.embeds.Embed-
Expand source code
def verbose(ctx: Context, dice: str, results: RollResults) -> Embed: """ Verbose output for dice roll results. Args: dice: The original dice roll string results: The list of results for the roll segments Returns: The embed to be posted to the channel """ embed = Embed( title=f"Roll: `{dice}`", color=Color.purple(), ) embed.set_author( name=ctx.author.name, icon_url=ctx.author.avatar.url if ctx.author.avatar else None, ) for result in results.results: embed.add_field( name=f"{segment_icon(result)} {result.segment.raw}", value=result.work if result.work else "", ) totals = [s.total for s in results.results] grand_total = sum(totals) embed.add_field( name=":checkered_flag: Total", value=f"{totals} = **{grand_total}**", inline=False, ) success = _success_text(results, grand_total) if success: embed.add_field(name=":trophy: Success", value=success) return embedVerbose output for dice roll results.
Args
dice- The original dice roll string
results- The list of results for the roll segments
Returns
The embed to be posted to the channel