-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from approvers/feature/rinia/shuffle/002_info
GachaInfo: 排出率を表示するコマンドを実装
- Loading branch information
Showing
8 changed files
with
74 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Text; | ||
using Discord; | ||
|
||
namespace Approvers.King.Common; | ||
|
||
public static class DiscordMessageUtility | ||
{ | ||
public static string Table(IEnumerable<(string key, string value)> records) | ||
{ | ||
var recordList = records.ToList(); | ||
var maxLength = recordList.Max(r => r.key.Length); | ||
var sb = new StringBuilder(); | ||
foreach (var (key, value) in recordList) | ||
{ | ||
sb.AppendLine($"| {value.PadLeft(maxLength)} | {Format.Sanitize(key)}"); | ||
} | ||
|
||
return Format.Code(sb.ToString()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Approvers.King.Common; | ||
|
||
namespace Approvers.King.Events; | ||
|
||
public class GachaInfoCommandPresenter : DiscordMessagePresenterBase | ||
{ | ||
protected override async Task MainAsync() | ||
{ | ||
// 排出率を投稿する | ||
await DiscordManager.Client | ||
.GetGuild(SettingManager.DiscordTargetGuildId) | ||
.GetTextChannel(SettingManager.DiscordMainChannelId) | ||
.SendMessageAsync(embed: GachaUtility.GetInfoEmbedBuilder().Build()); | ||
} | ||
} |
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,20 @@ | ||
using Approvers.King.Common; | ||
using Discord; | ||
|
||
namespace Approvers.King.Events; | ||
|
||
public static class GachaUtility | ||
{ | ||
public static EmbedBuilder GetInfoEmbedBuilder() | ||
{ | ||
var records = GachaManager.Instance.ReplyMessageTable | ||
.OrderByDescending(x => x.Rate) | ||
.Select(x => (x.Message, x.Rate.ToString("P0"))); | ||
return new EmbedBuilder() | ||
.WithTitle( | ||
$"{IssoUtility.SmileStamp}{IssoUtility.SmileStamp}{IssoUtility.SmileStamp} 本日のいっそう {IssoUtility.SmileStamp}{IssoUtility.SmileStamp}{IssoUtility.SmileStamp}") | ||
.WithColor(new Color(0xf1, 0xc4, 0x0f)) | ||
.WithDescription($"本日は {Format.Bold($"{GachaManager.Instance.RareReplyRate:P0}")} の確率で反応します") | ||
.AddField("排出確率", DiscordMessageUtility.Table(records)); | ||
} | ||
} |
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,6 @@ | ||
namespace Approvers.King.Events; | ||
|
||
public static class IssoUtility | ||
{ | ||
public const string SmileStamp = "<:isso_smile:1081501060369236069>"; | ||
} |
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