public async Task PrefixHelpAsync(EventContext e) { e.CreateEmbedBuilder() .WithTitle("miki_module_general_prefix_help_header") .WithDescription(e.Locale.GetString("miki_module_general_prefix_help", await e.commandHandler.GetPrefixAsync(e.Guild.Id))) .Build().QueueToChannel(e.Channel); }
public async Task PrefixHelpAsync(EventContext e) { e.CreateEmbedBuilder() .WithTitle("miki_module_general_prefix_help_header") .WithDescription("prefix_info", await e.commandHandler.GetDefaultPrefixValueAsync(e.Guild.Id)) .Build().QueueToChannel(e.Channel); }
public async Task PingAsync(EventContext e) { IDiscordMessage message = await e.CreateEmbedBuilder() .WithTitle(new StringResource("Ping")) .WithDescription("ping_placeholder") .Build() .SendToChannel(e.Channel); await Task.Delay(100); if (message != null) { float ping = (float)(message.Timestamp - e.message.Timestamp).TotalMilliseconds; DiscordEmbed embed = new EmbedBuilder() .SetTitle("Pong - " + Environment.MachineName) .SetColor(Color.Lerp(new Color(0.0f, 1.0f, 0.0f), new Color(1.0f, 0.0f, 0.0f), Math.Min(ping / 1000, 1f))) .AddInlineField("Miki", ping + "ms").ToEmbed(); await message.EditAsync(new EditMessageArgs { content = "", embed = embed }); } }
public async Task WhoIsAsync(EventContext e) { ArgObject arg = e.Arguments.Join(); if (arg == null) { throw new ArgumentNullException(); } IGuildUser user = await arg.GetUserAsync(e.Guild); if (user == null) { user = e.Author as IGuildUser; } var embed = e.CreateEmbedBuilder(); embed.WithTitle("whois_title", user.Username); embed.embedBuilder.WithColor(0.5f, 0f, 1.0f); embed.embedBuilder.ImageUrl = user.GetAvatarUrl(); var roles = e.Guild.Roles.Where(x => user.RoleIds.Contains(x.Id) && x.Color.RawValue != Color.Default.RawValue).OrderByDescending(x => x.Position); Color c = roles.FirstOrDefault()?.Color ?? Color.Default; StringBuilder builder = new StringBuilder(); builder.AppendLine($"User Id : **{user.Id}**"); builder.AppendLine($"Username: **{user.Username}#{user.Discriminator} {(string.IsNullOrEmpty(user.Nickname) ? "" : $"({user.Nickname})")}**");
public async Task PingAsync(EventContext e) { IUserMessage message = await e.CreateEmbedBuilder() .WithTitle(new StringResource("Ping")) .WithDescription("ping_placeholder") .Build() .SendToChannel(e.Channel); await Task.Delay(100); if (message != null) { float ping = (float)(message.Timestamp - e.message.Timestamp).TotalMilliseconds; Embed embed = new EmbedBuilder() { Title = "Pong", Color = new Color(0, 1, 0).Lerp(new Color(1, 0, 0), ping / 1000) }.AddInlineField("Miki", ping + "ms").Build(); await message.ModifyAsync(x => { x.Embed = embed; }); } }
public Task PingAsync(EventContext e) { e.CreateEmbedBuilder() .WithTitle(new RawResource("Ping")) .WithDescription("ping_placeholder") .Build() .QueueToChannel(e.Channel) .ThenWait(200) .Then(async x => { float ping = (float)(x.Timestamp - e.message.Timestamp).TotalMilliseconds; DiscordEmbed embed = new EmbedBuilder() .SetTitle("Pong - " + Environment.MachineName) .SetColor(Color.Lerp(new Color(0.0f, 1.0f, 0.0f), new Color(1.0f, 0.0f, 0.0f), Math.Min(ping / 1000, 1f))) .AddInlineField("Miki", ((int)ping).ToFormattedString() + "ms").ToEmbed(); await x.EditAsync(new EditMessageArgs { content = "", embed = embed }); }); return(Task.CompletedTask); }
public async Task WhoIsAsync(EventContext e) { ArgObject arg = e.Arguments.Join(); if (arg == null) { throw new ArgumentNullException(); } IDiscordGuildUser user = await arg.GetUserAsync(e.Guild); //if (user == null) //{ // user = e.Author as IGuildUser; //} var embed = e.CreateEmbedBuilder(); embed.WithTitle("whois_title", user.Username); embed.EmbedBuilder.SetColor(0.5f, 0f, 1.0f); embed.EmbedBuilder.ImageUrl = user.GetAvatarUrl(); var roles = (await e.Guild.GetRolesAsync()).Where(x => user.RoleIds.Contains(x.Id) && x.Color.Value != 0).OrderByDescending(x => x.Position); Color c = roles.FirstOrDefault()?.Color ?? new Color(0); StringBuilder builder = new StringBuilder(); builder.AppendLine($"User Id : **{user.Id}**"); builder.AppendLine( $"Username: **{user.Username}#{user.Discriminator} {(string.IsNullOrEmpty((user as IDiscordGuildUser).Nickname) ? "" : $"({(user as IDiscordGuildUser).Nickname})")}**"); //builder.AppendLine($"Created at: **{user.CreatedAt.ToString()}**"); builder.AppendLine($"Joined at : **{user.JoinedAt.ToString()}**"); builder.AppendLine($"Color Hex : **#{c.ToHexString()}**"); embed.AddField( e.CreateResource("miki_module_whois_tag_personal"), new StringResource(builder.ToString()) ); string r = string.Join(" ", roles.Select(x => x.Name)); if (string.IsNullOrEmpty(r)) { r = "none (yet!)"; } if (r.Length <= 1000) { embed.AddField( e.CreateResource("miki_module_general_guildinfo_roles"), new StringResource(r) ); } embed.Build().QueueToChannel(e.Channel); }
public async Task GuildBankInfoAsync(EventContext e, GuildUser c) { string prefix = await e.EventSystem.GetCommandHandler <SimpleCommandHandler>().GetDefaultPrefixValueAsync(e.Guild.Id); e.CreateEmbedBuilder() .WithTitle(new LanguageResource("guildbank_title", e.Guild.Name)) .WithDescription(new LanguageResource("guildbank_info_description")) .WithColor(new Color(255, 255, 255)) .WithThumbnailUrl("https://imgur.com/KXtwIWs.png") .AddField( new LanguageResource("guildbank_info_help"), new LanguageResource("guildbank_info_help_description", prefix), true ).Build().QueueToChannel(e.Channel); }
public async Task GuildBankBalance(EventContext e, MikiContext context, GuildUser c) { var account = await BankAccount.GetAsync(context, e.Author.Id, e.Guild.Id); e.CreateEmbedBuilder() .WithTitle(new LanguageResource("guildbank_title", e.Guild.Name)) .WithColor(new Color(255, 255, 255)) .WithThumbnailUrl("https://imgur.com/KXtwIWs.png") .AddField( new LanguageResource("guildbank_balance_title"), new LanguageResource("guildbank_balance", c.Currency), true ) .AddField( new LanguageResource("guildbank_contributed", "{0}"), new StringResource(account.TotalDeposited.ToString()) ).Build().QueueToChannel(e.Channel); }
public void GuildBankBalance(EventContext e, MikiContext context, GuildUser c) { BankAccount.GetAsync(context, c, e.Author); e.CreateEmbedBuilder() .WithTitle(new LanguageResource("guildbank_title", e.Guild.Name)) .WithColor(new Color(255, 255, 255)) .WithThumbnailUrl("https://imgur.com/KXtwIWs.png") .AddField( new LanguageResource("guildbank_balance_title"), new LanguageResource("guildbank_balance", c.Currency), true ) .AddField( new LanguageResource("guildbank_balance_total_deposited", ) ).Build().QueueToChannel(e.Channel); }
public async Task GuildBankDepositAsync(EventContext e, MikiContext context, GuildUser c) { int?totalDeposited = e.Arguments.Get(1).AsInt() ?? 0; User user = await User.GetAsync(context, e.Author); await user.AddCurrencyAsync(-totalDeposited.Value); c.AddCurrency(totalDeposited.Value, user); e.CreateEmbedBuilder() .WithTitle(new LanguageResource("guildbank_deposit_title", e.Author.Username, totalDeposited)) .WithColor(new Color(255, 255, 255)) .WithThumbnailUrl("https://imgur.com/KXtwIWs.png") .Build().QueueToChannel(e.Channel); await context.SaveChangesAsync(); }
public async Task GuildBankDepositAsync(EventContext e, MikiContext context, GuildUser c) { int totalDeposited = e.Arguments.Get(1).TakeInt() ?? 0; User user = await User.GetAsync(context, e.Author.Id, e.Author.Username); await user.AddCurrencyAsync(-totalDeposited); c.Currency += totalDeposited; BankAccount account = await BankAccount.GetAsync(context, e.Author.Id, e.Guild.Id); account.Deposit(totalDeposited); e.CreateEmbedBuilder() .WithTitle("guildbank_deposit_title", e.Author.Username, totalDeposited) .WithColor(new Color(255, 255, 255)) .WithThumbnailUrl("https://imgur.com/KXtwIWs.png") .Build().QueueToChannel(e.Channel); }