private async Task InsertQuote(ICommandContext context, Server server, string text) { var quote = new Quote { UserId = context.User.Id, ServerId = context.Guild.Id, Text = text, TimeStamp = DateTime.Now.ToOADate() }; int quoteId = await DatabaseQueries.SafeAddQuoteAsync(server, quote); var embed = new KaguyaEmbedBuilder { Fields = new List <EmbedFieldBuilder> { new EmbedFieldBuilder { Name = $"Quote #{quoteId}", Value = $"Successfully added the quote!\nQuote: `{text}`" } } }; await SendEmbedAsync(embed); server.NextQuoteId += 1; await DatabaseQueries.UpdateAsync(server); }
public async Task Command([Remainder] string text) { Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); IEnumerable <Quote> quotes = server.Quotes; int quoteCount = quotes?.Count() ?? 0; if (quoteCount > 0) { if (server.Quotes.Any(x => x.Text.Equals(text))) { var cEmbed = new KaguyaEmbedBuilder(EmbedColor.YELLOW) { Description = "A quote with the same text already exists. Do you want to create this one anyway?" }; var data = new ReactionCallbackData("", cEmbed.Build(), true, true, TimeSpan.FromSeconds(120)); data.AddCallBack(GlobalProperties.CheckMarkEmoji(), async(c, r) => { await InsertQuote(Context, server, text); }); data.AddCallBack(GlobalProperties.NoEntryEmoji(), async(c, r) => { await SendBasicErrorEmbedAsync("Okay, no action will be taken."); }); await InlineReactionReplyAsync(data); return; } } await InsertQuote(Context, server, text); }
public async Task Command([Remainder] string text) { char[] chars = text.ToCharArray(); Array.Reverse(chars); string reversedText = new string(chars); var embed = new KaguyaEmbedBuilder { Description = $"{Context.User.Mention} Here's your reversed text!", Fields = new List <EmbedFieldBuilder> { new EmbedFieldBuilder { Name = "Reversed Text", Value = reversedText } } }; // ReSharper disable once PossibleNullReferenceException if ((embed.Description.Length + embed.Fields[0].Value.ToString().Length) > 1800) { await SendBasicErrorEmbedAsync("Sorry, you're at the character limit! Please try something shorter."); } await SendEmbedAsync(embed); }
public async Task Command() { List <User> players = await DatabaseQueries.GetLimitAsync <User>(10, x => x.FishExp > 0, x => x.FishExp, true); DiscordShardedClient client = ConfigProperties.Client; var embed = new KaguyaEmbedBuilder(); embed.Title = "Kaguya Fishing Leaderboard"; int i = 0; foreach (User player in players) { i++; SocketUser socketUser = client.GetUser(player.UserId); List <Fish> fish = await DatabaseQueries.GetAllForUserAsync <Fish>(player.UserId, x => x.FishType != FishType.BAIT_STOLEN); embed.Fields.Add(new EmbedFieldBuilder { Name = $"{i}. {socketUser?.ToString().Split('#').First() ?? $"[Unknown User: {player.UserId}]"}", Value = $"Fish Level: `{player.FishLevel():0}` | Fish Exp: `{player.FishExp:N0}` | " + $"Fish Caught: `{fish.Count:N0}`" }); } await SendEmbedAsync(embed); }
public async Task Command() { Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); IEnumerable <Quote> quotes = server.Quotes; int quoteCount = quotes.Count(); if (quoteCount == 0) { await SendBasicErrorEmbedAsync($"This server's quote collection is empty.\nCreate some with `{server.CommandPrefix}addquote`."); return; } if (quoteCount <= 5) { var embed = new KaguyaEmbedBuilder { Title = $"Quotes for {Context.Guild}" }; foreach (Quote quote in quotes) { embed.AddField($"Quote #{quote.Id}", QuoteString(quote)); } await SendEmbedAsync(embed); return; } DateTime n = DateTime.Now; using (var s = new MemoryStream()) { var sw = new StreamWriter(s); await sw.WriteLineAsync($"### Quotes for: {Context.Guild.Name} ###"); foreach (Quote quote in quotes) { await sw.WriteLineAsync(QuoteString(quote, true)); } await sw.FlushAsync(); s.Seek(0, SeekOrigin.Begin); try { await Context.User.SendFileAsync(s, $"Quotes_{Context.Guild.Name}-{n.Day}-{n.Month}-{n.Year}--{n.Hour:00}-{n.Minute:00}-{n.Second:00}.txt"); } catch (Exception) { throw new KaguyaSupportException("Failed to DM you the quotes. Do you allow DMs from me/bots?"); } } await SendBasicSuccessEmbedAsync("All quotes have been sent to your DM."); }
public async Task Command() { List <User> top50 = (await DatabaseQueries.GetLimitAsync <User>(50, x => x.Experience > 0, x => x.Experience, true)).Where(x => !x.IsBlacklisted).ToList(); int i = 1; var embed = new KaguyaEmbedBuilder { Fields = new List <EmbedFieldBuilder>() }; foreach (User user in top50) { if (i > 10) { break; } SocketUser socketUser = Client.GetUser(user.UserId); embed.Fields.Add(new EmbedFieldBuilder { IsInline = false, Name = $"{i}. {socketUser?.ToString().Split('#').First() ?? $"[Unknown User: {user.UserId}]"}", Value = $"Level: {user.GlobalLevel():N0} ({user.PercentToNextLevel() * 100:N0}% {Centvrio.Emoji.Arrow.Right}" + $" Lvl {user.GlobalLevel() + 1:N0}) " + $"- Exp: {user.Experience:N0}" }); i++; } await SendEmbedAsync(embed); }
public async Task GiveRole(IGuildUser user, params string[] args) { int i = 0; foreach (string roleName in args) { SocketRole role = roleName.AsUlong(false) != 0 ? Context.Guild.GetRole(roleName.AsUlong()) : Context.Guild.Roles.FirstOrDefault(x => x.Name.ToLower() == roleName.ToLower()); try { await user.AddRoleAsync(role); i++; } catch (Exception ex) { await ConsoleLogger.LogAsync($"Exception thrown when adding role to user through command addrole: {ex.Message}", LogLvl.WARN); } } var embed = new KaguyaEmbedBuilder { Description = $"`{user.Username}` has been given `{i.ToWords()}` roles." }; await ReplyAsync(embed : embed.Build()); }
public async Task Command() { LavaNode node = ConfigProperties.LavaNode; LavaPlayer player = node.GetPlayer(Context.Guild); if (player.Queue.Count > 0) { var skipEmbed = new KaguyaEmbedBuilder { Title = $"Kaguya Music: Skip {Centvrio.Emoji.AudioVideo.FastForward}", Description = $"Successfully skipped `{player.Track.Title}`.\n" + $"Now playing: `{((LavaTrack) player.Queue.Peek()).Title}`" }; await SendEmbedAsync(skipEmbed); } try { await player.SkipAsync(); } catch (Exception) { var skipEmbed = new KaguyaEmbedBuilder { Title = $"Kaguya Music: Skip {Centvrio.Emoji.AudioVideo.FastForward}", Description = $"Successfully skipped `{player.Track.Title}`.\n" + $"There are no more tracks in the queue." }; await SendEmbedAsync(skipEmbed); await player.StopAsync(); } }
public async Task OsuSetCommand([Remainder] string username) { KaguyaEmbedBuilder embed; User playerObject = username.AsUlong(false) == 0 ? await OsuBase.Client.GetUserByUsernameAsync(username, GameMode.Standard) : await OsuBase.Client.GetUserByUserIdAsync((long)username.AsUlong(), GameMode.Standard); if (playerObject == null) { await SendBasicErrorEmbedAsync($"The username you provided doesn't match an existing osu! player."); return; } //Getting user profile database object and updating it. DataStorage.DbData.Models.User user = await DatabaseQueries.GetOrCreateUserAsync(Context.User.Id); user.OsuId = (int)playerObject.UserId; await DatabaseQueries.UpdateAsync(user); embed = new KaguyaEmbedBuilder { Title = "osu! Username", Description = $"Your osu! username has been set to `{playerObject.Username}`." }; await ReplyAsync(embed : embed.Build()); }
public async Task ResetLogChannel(string logType) { KaguyaEmbedBuilder embed; List <string> logTypes = await LogQuery.LogSwitcher(logType, false, Context.Guild.Id); if (logTypes.Count == 0) { embed = new KaguyaEmbedBuilder { Description = $"Please specify a valid log type." }; embed.SetColor(EmbedColor.RED); goto Reply; } if (logTypes.Any(x => x.Equals("all", System.StringComparison.OrdinalIgnoreCase))) { embed = new KaguyaEmbedBuilder { Description = $"Successfully disabled all log types." }; } else { embed = new KaguyaEmbedBuilder { Description = $"Successfully disabled logtype `{string.Join(", ", logTypes).ToUpper()}`." }; } Reply: await ReplyAsync(embed : embed.Build()); }
public async Task BanUser(SocketGuildUser user, [Remainder] string reason = null) { var embed = new KaguyaEmbedBuilder(); reason ??= "<No reason provided>"; try { await user.BanAsync(reason : reason); if (user.Id != 159985870458322944) { embed.Description = $"Successfully banned `{user}` with reason `{reason}`\n"; } else // Easter egg lol { embed.Description = $"Successfully banned `{user}` with reason `{reason}`\n" + $"*Nice choice* <:Kaguya:581581938884608001> 👍"; } } catch (Exception) { embed.Description = $"Failed to ban `{user}`\n"; } await ReplyAsync(embed : embed.Build()); }
public async Task InviteDm() { string devInviteUrl = $"[[Kaguya Dev Invite]]({ConfigProperties.KAGUYA_DEV_INVITE_URL})\n"; string inviteUrl = $"[[Invite Kaguya to your server]]({ConfigProperties.KAGUYA_INVITE_URL})\n"; string discordUrl = $"[[Kaguya Support Discord]]({ConfigProperties.KAGUYA_SUPPORT_DISCORD_URL})\n"; if (Context.User.Id != ConfigProperties.BotConfig.BotOwnerId) { devInviteUrl = null; } var embed = new KaguyaEmbedBuilder { Title = "Kaguya Invite Links", Description = $"{inviteUrl}{discordUrl}{devInviteUrl}" }; try { await Context.User.SendMessageAsync(embed : embed.Build()); } catch (HttpException) { await ConsoleLogger.LogAsync("Tried to DM a user the Kaguya invite links " + "but an HttpException was thrown.", LogLvl.WARN); } await ReplyAsync(embed : new KaguyaEmbedBuilder { Description = "Links sent! Check your DM <:Kaguya:581581938884608001>" } .Build()); }
public async Task SetPrefix(string prefix) { var embed = new KaguyaEmbedBuilder(); if (prefix.Length > 5) { await ConsoleLogger.LogAsync("Command prefix was too long. Not set.", DataStorage.JsonStorage.LogLvl.DEBUG); embed.WithDescription("Your command prefix may not be longer than 5 characters."); embed.SetColor(EmbedColor.RED); await ReplyAsync(embed : embed.Build()); return; } Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); server.CommandPrefix = prefix; await DatabaseQueries.UpdateAsync(server); embed.WithDescription($"Command prefix has been changed to `{prefix}`."); embed.WithFooter($"Use this command again without specifying a prefix to reset it."); embed.SetColor(EmbedColor.VIOLET); await ReplyAsync(embed : embed.Build()); }
private async Task SendEmbedToBotOwner(ICommandContext context, IKey key) { SocketUser owner = Client.GetUser(ConfigProperties.BotConfig.BotOwnerId); var fields = new List <EmbedFieldBuilder> { new EmbedFieldBuilder { IsInline = false, Name = "Key Properties", Value = $"Key: `{key.Key}`\nCreated by: `{owner}`\nExpires: " + $"`{DateTime.Now.AddSeconds(key.LengthInSeconds).Humanize(false)}`" } }; if (key.GetType() == typeof(PremiumKey)) { var embed = new KaguyaEmbedBuilder { Description = $"User `{context.User}` has just redeemed a " + $"Kaguya Premium key!", Fields = fields }; try { await owner.SendMessageAsync(embed : embed.Build()); } catch (HttpException) { await ConsoleLogger.LogAsync("Attempted to DM an owner a notification about a " + "Kaguya Premium key redemption, but a " + "Discord.Net.HttpException was thrown.", LogLvl.WARN); } } }
public async Task SwapLogLevel(string level) { LogLvl curLog = ConfigProperties.LogLevel; string validSeverities = "Trace, Debug, Info, Warn, Error"; ConfigProperties.LogLevel = level.ToLower() switch { "trace" => LogLvl.TRACE, "debug" => LogLvl.DEBUG, "info" => LogLvl.INFO, "warn" => LogLvl.WARN, "error" => LogLvl.ERROR, _ => throw new ArgumentOutOfRangeException($"Valid logtypes are `{validSeverities}`", new Exception()) }; var embed = new KaguyaEmbedBuilder { Description = $"Successfully changed LogLevel from `{curLog.Humanize()}` to `{ConfigProperties.LogLevel.Humanize()}`", Footer = new EmbedFooterBuilder { Text = $"Note: This loglevel will return back to `{curLog.Humanize()}` after a restart." } }; embed.SetColor(EmbedColor.VIOLET); await ReplyAsync(embed : embed.Build()); } }
public async Task Command(int level, [Remainder] SocketRole role) { const int PREMIUM_LIMIT = Int32.MaxValue; const int REG_LIMIT = 3; Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); int limit = server.IsPremium ? PREMIUM_LIMIT : REG_LIMIT; if (level < 1) { await SendBasicErrorEmbedAsync("The `level` parameter must be at least `1`."); return; } if (level > 100000) { await SendBasicErrorEmbedAsync($"The maximum level for a role reward is `{100000:N0}`"); return; } if (server.RoleRewards.Count() == limit) { string limitStr = server.IsPremium ? $"Your premium limit: {PREMIUM_LIMIT:N0}." : $"Your non-premium limit: {REG_LIMIT}."; string baseLimitStr = "You have reached your limit of allowed " + $"concurrent role rewards. Please delete one " + $"if you still wish to create this reward.\n\n {limitStr}"; if (server.IsPremium) { throw new KaguyaSupportException(baseLimitStr); } else { throw new KaguyaPremiumException($"More than {REG_LIMIT} role rewards.\n" + baseLimitStr); } } var rr = new ServerRoleReward { ServerId = Context.Guild.Id, RoleId = role.Id, Level = level, Server = server }; await DatabaseQueries.InsertIfNotExistsAsync(rr); var embed = new KaguyaEmbedBuilder { Title = $"Kaguya Role Rewards", Description = $"{Context.User.Mention} Whenever a user reaches " + $"`Server Level {level}`, I will now reward them with {role.Mention}." }; await SendEmbedAsync(embed); }
public async Task ShadowbanUser(SocketGuildUser user, [Remainder] string reason = null) { SocketGuild guild = Context.Guild; IRole role = guild.Roles.FirstOrDefault(x => x.Name == SB_ROLE); Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); if (role == null) { await ReplyAsync($"{Context.User.Mention} Could not find role `{SB_ROLE}`. Creating..."); RestRole newRole = await guild.CreateRoleAsync(SB_ROLE, GuildPermissions.None, null, false, false, null); role = newRole; await ReplyAsync($"{Context.User.Mention} Created role `{SB_ROLE}` with permissions: `none`."); await ReplyAsync($"{Context.User.Mention} Scanning permission overwrites for channels..."); } if (string.IsNullOrWhiteSpace(reason)) { reason = "<No reason provided>"; } try { await ScanChannelsForPermissions(role); if (user.Roles.Contains(role)) { await SendBasicErrorEmbedAsync($"{user.Mention} already has the role {role.Mention}."); return; } await user.AddRoleAsync(role); } catch (Exception e) { throw new KaguyaSupportException("Failed to add `kaguya-mute` role to user!\n\n" + $"Error Log: ```{e}```"); } IEnumerable <SocketRole> roles = user.Roles.Where(x => !x.IsManaged && x.Name != "@everyone"); await user.RemoveRolesAsync(roles); var successEmbed = new KaguyaEmbedBuilder { Description = $"`{user}` has been transported to the shadowlands...", Footer = new EmbedFooterBuilder { Text = "In the shadowlands, users may not interact with any text or voice channel, " + "or view who is in the server.\n\n" + "Use the unshadowban command to undo this action." } }; KaguyaEvents.TriggerShadowban(new ModeratorEventArgs(server, guild, user, (SocketGuildUser)Context.User, reason, null)); await ReplyAsync(embed : successEmbed.Build()); }
public async Task UnWarnUser(SocketGuildUser user, [Remainder] string reason = null) { Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); List <WarnedUser> warnings = await DatabaseQueries.GetAllForServerAndUserAsync <WarnedUser>(user.Id, server.ServerId); int warnCount = warnings.Count; var fields = new List <EmbedFieldBuilder>(); reason ??= "<No reason provided>"; if (warnCount > 4 && !server.IsPremium) { warnCount = 4; } if (warnCount > 9 && server.IsPremium) { warnCount = 9; } if (warnings.Count == 0) { var reply = new KaguyaEmbedBuilder { Description = $"{user.Username} has no warnings to remove!" }; reply.SetColor(EmbedColor.RED); await ReplyAsync(embed : reply.Build()); return; } for (int i = 0; i < warnCount; i++) { var field = new EmbedFieldBuilder { Name = $"Warning #{i + 1}", Value = $"Reason: `{warnings.ElementAt(i).Reason}`" }; fields.Add(field); } var embed = new KaguyaEmbedBuilder { Title = $"Warnings for {user}", Fields = fields, Footer = new EmbedFooterBuilder { Text = "Select a reaction to remove the warning." } }; await ReactionReply(user, warnings, embed.Build(), warnCount, server, reason); }
/// <summary> /// Sends a basic reply in chat with the default embed color. /// </summary> /// <param name="description"></param> /// <returns></returns> protected async Task SendBasicSuccessEmbedAsync(string description) { var embed = new KaguyaEmbedBuilder { Description = description }; await SendEmbedAsync(embed); }
/// <summary> /// Sends a basic <see cref="KaguyaEmbedBuilder"/> in chat with a red color. /// </summary> /// <param name="description"></param> /// <returns></returns> protected async Task SendBasicErrorEmbedAsync(string description) { var embed = new KaguyaEmbedBuilder(EmbedColor.RED) { Description = description }; await SendEmbedAsync(embed); }
public async Task Command(params string[] args) { var users = new List <SocketGuildUser>(); var invalidUsers = new List <string>(); foreach (string a in args) { SocketGuildUser user = DiscordHelpers.ParseGuildUser(a, Context.Guild); if (user != null) { users.Add(user); } else { invalidUsers.Add(a); } } // Embolden all users, format them in a comma separated list. string kickString = users.Humanize(x => x.ToString().ToDiscordBold(), ""); var errorSb = new StringBuilder("Failed to kick users:\n"); if (invalidUsers.Any()) { errorSb.AppendLine(invalidUsers.Humanize(x => x.ToDiscordBold(), "")); } List <Task> awaiters = new List <Task>(); foreach (SocketGuildUser user in users) { awaiters.Add(user.KickAsync()); } await Task.WhenAll(awaiters); var finalSb = new StringBuilder(); if (!String.IsNullOrWhiteSpace(kickString)) { finalSb.AppendLine(kickString); } if (!String.IsNullOrWhiteSpace(errorSb.ToString())) { finalSb.AppendLine("\n\n" + errorSb); } var embed = new KaguyaEmbedBuilder { Title = "Masskick", Description = finalSb.ToString() }; await SendEmbedAsync(embed); }
/* * Some extensions here are also present in KaguyaBase. It is important they are * left here as extensions in the event that an ISocketMessageChannel needs it where * the current command's Context isn't available or is not in use. */ /// <summary> /// Sends a basic reply in chat with the default embed color. /// </summary> /// <param name="channel"></param> /// <param name="description"></param> /// <returns></returns> public static async Task SendBasicSuccessEmbedAsync(this IMessageChannel channel, string description) { var embed = new KaguyaEmbedBuilder { Description = description }; await channel.SendMessageAsync(embed : embed.Build()); }
public async Task Command() { Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); List <FilteredPhrase> fp = server.FilteredPhrases.ToList(); int chars = fp.Sum(phrase => phrase.Phrase.Length); string fpStr = ""; if (chars < 1750) { fpStr = fp.Aggregate(fpStr, (current, phrase) => current + $"`{phrase.Phrase}`\n"); if (chars == 0) { await SendBasicErrorEmbedAsync("This server currently has no registered filtered phrases."); return; } var embed = new KaguyaEmbedBuilder { Title = $"Filtered Phrases for {Context.Guild.Name}", Description = fpStr }; await SendEmbedAsync(embed); return; } using (var stream = new MemoryStream()) { var sr = new StreamWriter(stream); foreach (FilteredPhrase phrase in fp) { await sr.WriteLineAsync(phrase.Phrase); } stream.Seek(0, SeekOrigin.Begin); await stream.FlushAsync(); var embed = new KaguyaEmbedBuilder { Title = $"Filtered Phrases for {Context.Guild.Name}", Description = $"{Context.User.Mention}, your filtered phrases were too long to send in one message, " + $"so I put them in a text file for you!" }; await Context.Channel.SendFileAsync(stream, $"Filtered_Phrases_{Context.Guild.Name}_{DateTime.Now.ToLongDateString()}.txt", embed : embed.Build()); } }
public async Task UnmuteUser(SocketGuildUser user, [Remainder] string reason = null) { Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); var mutedObject = await DatabaseQueries.GetFirstMatchAsync <MutedUser>(x => x.UserId == user.Id && x.ServerId == server.ServerId); reason ??= "<No reason provided>"; if (mutedObject != null) { await DatabaseQueries.DeleteAsync(mutedObject); } if (server.IsPremium) { await DatabaseQueries.UpdateAsync(server); } try { SocketRole muteRole = Context.Guild.Roles.FirstOrDefault(x => x.Name.ToLower() == "kaguya-mute"); if (!user.Roles.Contains(muteRole)) { await ReplyAsync($"{Context.User.Mention} **{user}** is not muted."); return; } await user.RemoveRoleAsync(muteRole); await ReplyAsync($"{Context.User.Mention} Successfully unmuted **{user}**."); KaguyaEvents.TriggerUnmute(new ModeratorEventArgs(server, Context.Guild, user, (SocketGuildUser)Context.User, reason, null)); } catch (NullReferenceException) { var errorEmbed = new KaguyaEmbedBuilder { Description = "User was never muted because the mute role doesn't exist.", Footer = new EmbedFooterBuilder { Text = "Use the mute command to generate the mute role." } }; errorEmbed.SetColor(EmbedColor.RED); await ReplyAsync(embed : errorEmbed.Build()); } catch (Exception e) { throw new KaguyaSupportException($"An unexpected error occurred.\n\nError Log: {e}"); } }
public async Task SetPrefix() { Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id); var embed = new KaguyaEmbedBuilder(EmbedColor.VIOLET) { Description = $"Your current command prefix is `{server.CommandPrefix}`" }; await ReplyAsync(embed : embed.Build()); }
public async Task AddPhrase(params string[] args) { string s = "s"; if (args.Length == 1) { s = ""; } Server server = DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id).Result; List <FilteredPhrase> allFp = server.FilteredPhrases.ToList(); if (args.Length == 0) { var embed0 = new KaguyaEmbedBuilder { Description = "Please specify at least one phrase." }; embed0.SetColor(EmbedColor.RED); await SendEmbedAsync(embed0); return; } foreach (string element in args) { var fp = new FilteredPhrase { ServerId = server.ServerId, Phrase = element }; if (allFp.Contains(fp)) { continue; } await DatabaseQueries.InsertIfNotExistsAsync(fp); await ConsoleLogger.LogAsync($"Server {server.ServerId} has added the phrase \"{element}\" to their word filter.", DataStorage.JsonStorage.LogLvl.DEBUG); } var embed = new KaguyaEmbedBuilder { Description = $"Successfully added {args.Length} phrase{s} to the filter." }; embed.SetColor(EmbedColor.VIOLET); await ReplyAsync(embed : embed.Build()); }
public async Task Command(params string[] args) { string[] cl = await File.ReadAllLinesAsync(Path.Combine(FileConstants.RootDir, @"..\", "changelog.md")); KaguyaEmbedBuilder embed = await GenerateChangelogEmbed(cl, args); if (embed != null) { await SendEmbedAsync(embed); } }
/// <summary> /// Sends a basic error message in chat. /// </summary> /// <param name="channel"></param> /// <param name="description"></param> /// <returns></returns> public static async Task SendBasicErrorEmbedAsync(this IMessageChannel channel, string description) { var embed = new KaguyaEmbedBuilder { Description = description }; embed.SetColor(EmbedColor.RED); await channel.SendMessageAsync(embed : embed.Build()); }
public async Task Command(params SocketGuildUser[] users) { if (users.Length == 0) { var errorEmbed = new KaguyaEmbedBuilder { Description = "Please specify one (or more) users to action." }; await ReplyAsync(embed : errorEmbed.Build()); return; } await ReplyAsync($"{Context.User.Mention} Processing, please wait..."); List <SocketRole> roles = Context.Guild.Roles.Where(x => !x.IsManaged && x.Name != "@everyone").ToList(); var namesList = new List <string>(users.Length); int errorRoles = Context.Guild.Roles.Count(x => x.IsManaged); foreach (SocketGuildUser user in users) { namesList.Add(user.ToString()); await user.AddRolesAsync(roles); } string nameString = $""; foreach (string name in namesList) { nameString += $"`{name}`, "; } nameString = nameString.Substring(0, nameString.Length - 2); var embed = new KaguyaEmbedBuilder { Description = $"Successfully applied `{(Context.Guild.Roles.Count - errorRoles).ToWords()}` roles to " + $"{nameString}." }; if (errorRoles > 0) { embed.Description += $"\n\nI failed to assign `{errorRoles.ToWords()}` roles. These " + $"roles are managed by integrations or other bots, therefore it " + $"cannot be assigned to any users."; } await ReplyAsync(embed : embed.Build()); }
public async Task Command() { // Pasted from the store. string premString = "All perks below will last until your time as a premium subscriber runs out.\n**(SW)** = Works across all servers you own!!\n\n****Unlimited access to features that require a vote to use.***\n* Bet many more points than usual on gambling games.\n* 25,000 points for every 30 days of premium time purchased.\n* 2x points and exp from $daily\n* 2x points and exp from $vote\n* 25% off $bait cost\n* Special $profile badge\n* Significantly reduced $fish cooldown\n* More lenient rate limit (able to use commands more frequently than other users).\n* Access to $doujin\n* Access to $react\n* Access to $weekly\n* Access to $serverstats\n* Access to $hyperban\n* Access to $deleteunusedroles\n* Access to $soundcloud, $twitchaudio\n* Bonus luck on all gambling commands (including $fish)\n* Store up to 1,000 fish bait instead of 100\n* Deleted messages logged via \"$log DeletedMessages \" will now include archives of deleted images and attachments. **(SW)**\n* Unlimited role rewards **(SW)**\n* Access to the $logtype \"ModLog\" - logs many various administrative actions **(SW)**\n* View more of a user's warn history via $unwarn **(SW)**\n* Unlimited song duration (compared to 10 minutes) **(SW)**\n* Unlimited music queue size **(SW)**\n* Unlimited + enhanced $nsfw usage **(SW)**\n\n__**Purchase Kaguya Premium at the [Kaguya Store](https://sellix.io/KaguyaStore) for only $4.99 a month!**__"; var embed = new KaguyaEmbedBuilder { Title = "Kaguya Premium", Description = premString }; await SendEmbedAsync(embed); }