private async Task CheckConfigsAsync() { BotConfig conf = BotConfig.Load(); if (configType == ConfigType.Individual) { foreach (var guild in GetBot().Guilds) { IndividualConfig gconf = conf.GetConfig(guild.Id); if (gconf == null) { gconf = conf.FreshConfig(guild.Id); conf.Configs.Add(gconf); } } } await Util.LoggerAsync(new LogMessage(LogSeverity.Info, "Gateway", $"Successfully connected to {bot.Guilds.Count} guilds")); conf.LastStartup = DateTime.UtcNow; conf.Save(); var restart = Task.Run(async() => { await Task.Delay(RestartEveryMs); // Code to restart bot Process.Start(AppContext.BaseDirectory + ExecutableName + ".exe"); // Close this instance Environment.Exit(0); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var voteNotifier = new UpvoteNotifier(); IBotConfig botConfig = BotConfig.GetConfig(); services.AddControllers(); services.AddOptions(); services.AddScoped <KaguyaDb>(); services.AddScoped <KaguyaApiConfig>(); services.AddSingleton(botConfig); services.AddSingleton(new KaguyaDbSettings(new KaguyaApiConfig(botConfig))); services.AddSingleton(voteNotifier); var dbSettings = services.BuildServiceProvider().GetRequiredService <KaguyaDbSettings>(); services.AddCors(options => { options.AddPolicy("AllowAll", builder => { builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); // Initialize connection to database. DataConnection.DefaultSettings = dbSettings; LinqToDB.Common.Configuration.Linq.AllowMultipleQuery = true; }
private async Task CensorAsync(string censor = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (censor == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}settings censor <True/False>`", false); return; } char c = censor.ToLower()[0]; if (c == 't') { gconf.Censor = true; conf.Save(); await Context.Channel.SendMessageAsync($"The message censor feature has been enabled in this guild."); } else if (c == 'f') { gconf.Censor = false; conf.Save(); await Context.Channel.SendMessageAsync($"The message censor feature has been disabled in this guild."); } else { await Context.Channel.SendMessageAsync($"Incorrect use of command: Please use the command as follows `" + gconf.Prefix + "settings censor true` or `" + gconf.Prefix + "settings censor false`"); } }
private async Task TieAsync(IUser user = null, [Remainder] string obj = null) { await Context.Message.DeleteAsync(); if (!(Context.Channel as ITextChannel).IsNsfw) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "NSFW Error", $"This command can only be used inside channels marked as nsfw...", false); return; } if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}tie <@user>` or `{gconf.Prefix}tie <@user> <object>`", false); return; } if (obj == null) { obj = "the bed"; } await Context.Channel.SendMessageAsync($"{Context.User.Mention} tied {user.Mention} to {obj}!"); }
private async Task BinaryAsync([Remainder] string text = null) { await Context.Message.DeleteAsync(); if (text != null) { var binary = ToBinary(ConvertToByteArray(text, Encoding.ASCII)); EmbedBuilder embed = new EmbedBuilder() { Title = $"Text to Binary", Description = $"''{text}''\n\n{binary}", Color = Color.DarkPurple }; embed.Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Requested by {Context.User.Username}#{Context.User.Discriminator}." }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); } else { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}binary <message>`", false); return; } }
private async Task BankTransferAsync(IUser user = null, float amount = 0) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (user == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}bank transfer <@user> <amount>`", false); return; } if (amount <= 0) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"The amount must be greater than 0."); return; } LoriUser profile = ProfileDatabase.GetUser(Context.User.Id); if (profile == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find your bank account."); return; } LoriUser profile2 = ProfileDatabase.GetUser(user.Id); if (profile2 == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find {user.Username}'s bank account."); return; } if (profile.GetCurrency() >= amount) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", "You can not afford this transfer."); return; } ProfileDatabase.AddCurrency(Context.User.Id, -amount); ProfileDatabase.AddCurrency(user.Id, amount); float newAmt = profile.GetCurrency(); EmbedBuilder embed = new EmbedBuilder() { Color = Color.DarkPurple, Title = "Transfer successful", Description = $"Successfully transferred ${amount} to {user.Username}.\nNew balance: ${newAmt}" }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
private async Task AddCensorAsync(string censor = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (censor == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}settings addcensor <word>`", false); return; } string word = censor.ToLower().Trim(); if (word != string.Empty) { gconf.AddCensoredWord(word); conf.Save(); await Context.Channel.SendMessageAsync($"The word {word} has been added to the guilds censor."); } else { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}settings addcensor <word>`", false); return; } }
private async Task PunishMeAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (!(Context.Channel as ITextChannel).IsNsfw) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "NSFW Error", $"This command can only be used inside channels marked as nsfw...", false); return; } if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}punishme <@user>`", false); return; } Random rnd = new Random(); List <FunObject> punishments = await FunDatabase.GetOfTypeAsync("punish"); int r = rnd.Next(0, punishments.Count); string punishment = punishments[r].Text.Replace("USER1", StringUtil.ToUppercaseFirst(user.Mention)).Replace("USER2", StringUtil.ToUppercaseFirst(Context.User.Mention)); await Context.Channel.SendMessageAsync(punishment); }
private async Task KillAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}kill <@user>`", false); return; } Random rnd = new Random(); List <FunObject> deaths = await FunDatabase.GetOfTypeAsync("death"); int d = rnd.Next(0, deaths.Count); string death = deaths[d].Text.Replace("USER1", StringUtil.ToUppercaseFirst(Context.User.Mention)).Replace("USER2", StringUtil.ToUppercaseFirst(user.Mention)); EmbedBuilder embed = new EmbedBuilder() { Description = death, Footer = new EmbedFooterBuilder() { Text = "❄️ React with a snowflake to mark as too offensive..." }, Color = Color.DarkPurple }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
private async Task CuckAsync(IUser user = null, IUser person = null) { await Context.Message.DeleteAsync(); if (!(Context.Channel as ITextChannel).IsNsfw) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "NSFW Error", $"This command can only be used inside channels marked as nsfw...", false); return; } if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}cuck <@user>` or `{gconf.Prefix}cuck <@user> <@secondUser>`", false); return; } string with = ""; if (person != null) { with = $" with {person.Mention}"; } await Context.Channel.SendMessageAsync($"{Context.User.Mention} cucked {user.Mention}{with}!"); }
private async Task HugAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}hug <@user>`", false); return; } List <FunObject> hugs = await FunDatabase.GetOfTypeAsync("hug"); Random rnd = new Random(); int g = rnd.Next(0, hugs.Count); string GIF = hugs[g].Extra; EmbedBuilder embed = new EmbedBuilder() { Title = $"{Context.User.Username} hugged {user.Username}", ImageUrl = GIF, Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Requested by {Context.User.ToString()}" } }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
private async Task ComplimentsAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}compliment <@user>`", false); return; } Random rnd = new Random(); if (Context.User.Id != user.Id) { List <FunObject> compliments = await FunDatabase.GetOfTypeAsync("compliment"); int d = rnd.Next(0, compliments.Count); string compliment = compliments[d].Text.Replace("USER", StringUtil.ToUppercaseFirst(user.Mention)); await Context.Channel.SendMessageAsync(compliment); } else { List <FunObject> roasts = await FunDatabase.GetOfTypeAsync("roast"); int d = rnd.Next(0, roasts.Count); string roast = roasts[d].Text.Replace("USER", StringUtil.ToUppercaseFirst(user.Mention)); await Context.Channel.SendMessageAsync(roast); } }
private async Task SnakesAsync(IUser user = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); IndividualConfig gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Unimplemented Game", $"This game has not yet been reimplemented into Lori's Angel v2. Try again in a couple days!\n `{gconf.Prefix}changelog` for more information", false); }
private async Task HandleCommandAsync(SocketMessage pMsg) { if (pMsg.Author.IsBot) { return; } var cmd = Task.Run(async() => { SocketUserMessage message = pMsg as SocketUserMessage; if (message == null) { return; } var context = new SocketCommandContext(bot, message); string prefix = ""; BotConfig config = BotConfig.Load(); if (configType == ConfigType.Solo) { prefix = config.SoloConfig.Prefix; } else { prefix = config.GetConfig((message.Channel as IGuildChannel).GuildId).Prefix; } if (message.Content.StartsWith(bot.CurrentUser.Mention) && message.Content.Length == bot.CurrentUser.Mention.Length) { await ModuleHelp.HelpAsync(context, ""); return; } int argPos = 0; if (message.HasStringPrefix(prefix, ref argPos) || message.HasMentionPrefix(bot.CurrentUser, ref argPos)) { var result = await commands.ExecuteAsync(context, argPos, map); if (!result.IsSuccess && result.ErrorReason != "Unknown command.") { if (result.ErrorReason.Contains("Collection was modified")) { return; // We dont wanna log this warning } //await Util.Logger(new LogMessage(LogSeverity.Warning, "Commands", result.ErrorReason, null)); EmbedBuilder embed = new EmbedBuilder() { Title = "Command Error", Description = result.ErrorReason + $"\nTry mentioning the bot for help!", Color = new Color(230, 100, 75) }; await context.Channel.SendMessageAsync(null, false, embed.Build()); } } }); }
private async Task LeaderboardAsync([Remainder] string lb = "") { await Context.Message.DeleteAsync(); if (lb.Equals("")) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}leaderboard <game name>`", false); return; } string leaderboard = ""; if (lb.ToLower().Equals("connect 4") || lb.ToLower().Equals("connect4") || lb.ToLower().Equals("c4")) { leaderboard = "Connect 4"; } else if (lb.ToLower().Equals("tic tac toe") || lb.ToLower().Equals("tictactoe") || lb.ToLower().Equals("ttt")) { leaderboard = "Tic Tac Toe"; } else { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Leaderboard Error", $"Leaderboard with name '{lb}' could not be found."); return; } LoriLeaderboard fullLb = await LeaderboardDatabase.GetLeaderboardAsync(leaderboard, 10); var top10 = fullLb.GetTop(10); string board = $"`{"pos", 5} {"Name", 30} {"score",5}`"; for (int i = 0; i < top10.Count; i++) { board += $"\n`[{i+1,3}] {top10[i].Name,30} - {top10[i].Score,5}`"; } EmbedBuilder embed = new EmbedBuilder() { Title = $"{leaderboard} - Top 10", Color = Color.DarkPurple, Description = board, Footer = new EmbedFooterBuilder() { Text = fullLb.GetPositionAsString(Context.User.Id) } }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
public static string GetPrefix(ulong id = 0L) { BotConfig conf = BotConfig.Load(); if (configType == ConfigType.Individual) { return(conf.GetConfig(id).Prefix); } else { return(conf.SoloConfig.Prefix); } }
private async Task EightBallAsync([Remainder] string question = null) { await Context.Message.DeleteAsync(); if (question != null) { string reply; Random rnd = new Random(); int random = rnd.Next(0, 3); switch (random) { case 0: int y = rnd.Next(0, YES_REPLIES.Length); reply = YES_REPLIES[y]; break; case 1: int n = rnd.Next(0, NO_REPLIES.Length); reply = NO_REPLIES[n]; break; default: int m = rnd.Next(0, MAYBE_REPLIES.Length); reply = MAYBE_REPLIES[m]; break; } EmbedBuilder embed = new EmbedBuilder() { Title = question, Description = reply + "!", Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Requested by {Context.User.Username}#{Context.User.Discriminator}." }, }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); } else { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}8ball <question>`", false); return; } }
private async Task JoinGuildAsync(SocketGuild guild) { if (configType == ConfigType.Individual) { BotConfig conf = BotConfig.Load(); IndividualConfig gconf = conf.GetConfig(guild.Id); if (gconf == null) { gconf = conf.FreshConfig(guild.Id); conf.Configs.Add(gconf); conf.Save(); } } }
private async Task MessageOwnerAsync([Remainder] string message = null) { if (message == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}messageowner <message>`", false); return; } var logChannel = LCommandHandler.GetBot().GetGuild(730573219374825523).GetTextChannel(808283416533270549); await logChannel.SendMessageAsync($"-- -- -- -- --\n**From:** {Context.User.Username}#{Context.User.Discriminator} ({Context.User.Id})\n**Time:** {DateTime.Now}\n\n{message}\n-- -- -- -- --"); await Context.Channel.SendMessageAsync("Message sent."); }
private async Task WhoAsync([Remainder] string question = null) { await Context.Message.DeleteAsync(); if (question == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}who <question>`", false); return; } ulong[] mentions = Context.Message.MentionedUserIds.ToArray <ulong>(); IGuildUser answerUser; if (mentions.Length > 0) { Random rnd = new Random(); int answer = rnd.Next(0, mentions.Length); answerUser = await Context.Guild.GetUserAsync(mentions[answer]); } else { var users = await Context.Guild.GetUsersAsync(); Random rnd = new Random(); int answer = rnd.Next(0, users.Count); answerUser = users.ToArray()[answer]; } EmbedBuilder embed = new EmbedBuilder() { Title = $"Who {await StringUtil.GetReadableMentionsAsync(Context.Guild as IGuild, question.ToLower())}", Description = $"The answer to that would be {answerUser.Username}.", Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Requested by {Context.User.Username}#{Context.User.Discriminator}" } }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
private async Task ProfileAsync(ulong id) { await Context.Message.DeleteAsync(); var user = CommandHandler.GetBot().GetUser(id); if (user != null) { await ViewProfileAsync(Context, user); } else { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}profile <@user>`", false); return; } }
private async Task ConnectAsync(IUser playerTwo = null) { await Context.Message.DeleteAsync(); if (playerTwo == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}c4 <@user>`", false); return; } IUser playerOne = Context.User as IUser; if (playerTwo.IsBot || playerOne.Id == playerTwo.Id) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Connect4 Error", "You can not play against yourself or a bot.", false); return; } if (GameHandler.DoesGameExist(Context.Guild.Id, GameType.CONNECT)) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Connect4 Error", "There is already a game in this guild.", false); return; } ulong[] players = { playerOne.Id, playerTwo.Id }; ConnectGame newGame = new ConnectGame(Context.Guild.Id, players); GameHandler.AddNewGame(newGame); string render = newGame.RenderGame(); IUser currentPlayer = await Context.Guild.GetUserAsync(newGame.Players[newGame.Turn]); var msg = await Context.Channel.SendFileAsync(render, $"**Connect 4**\n" + $"Next Up: {currentPlayer.Mention}\n" + $"`{CommandHandler.GetPrefix(Context.Guild.Id)}c4 <column>` to take your turn\n`{CommandHandler.GetPrefix(Context.Guild.Id)}c4 end` to end the game"); newGame.RenderId = msg.Id; }
private async Task PrefixAsync(string prefix = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (prefix == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}settings prefix <prefix>`", false); return; } gconf.Prefix = prefix; conf.Save(); await Context.Channel.SendMessageAsync($"The prefix for the bot in this server has been successfully changed to ''{prefix}''."); }
private async Task PickupAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}pickup <@user>`", false); return; } Random rnd = new Random(); List <FunObject> pickups = await FunDatabase.GetOfTypeAsync("pickup"); int p = rnd.Next(0, pickups.Count); string pickup = pickups[p].Text.Replace("USER1", StringUtil.ToUppercaseFirst(Context.User.Mention)).Replace("USER2", StringUtil.ToUppercaseFirst(user.Mention)); await Context.Channel.SendMessageAsync(pickup); }
private async Task SettingsAsync() { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); EmbedBuilder embed = new EmbedBuilder() { Title = "Modify Guild Settings", Description = "Use the command `" + gconf.Prefix + " <setting> <newSetting>` to adjust settings. (Example: `" + gconf.Prefix + "settings prefix :` to set the command prefix to ':'`", Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = "These settings will later be moved to a webpanel." } }; embed.AddField(new EmbedFieldBuilder() { Name = "Prefix", Value = gconf.Prefix, IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Censor", Value = gconf.Censor, IsInline = true }); string words = ""; foreach (string word in gconf.CensoredWords) { words += "," + word; } embed.AddField(new EmbedFieldBuilder() { Name = "Censored Words", Value = $"{gconf.Prefix}settings addcensor <word>\n{words}" }); await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
private async Task TempBanMemberAsync(IUser user = null, int time = 60, string reason = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (user == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}ban <user> <time> [reason]`", false); return; } if (reason == null) { reason = "Banned by " + Context.User.Username + "#" + Context.User.Discriminator + " for " + time + " minutes"; } else { reason += " - Banned by " + Context.User.Username + "#" + Context.User.Discriminator + " for " + time + " minutes"; } await BanMemberAsync(user, reason); await ModerationDatabase.AddTempBanAsync(Context.Guild.Id, user.Id, DateTime.Now.AddMinutes(time)); EmbedBuilder embed = new EmbedBuilder() { Title = user.Username + " was temp banned", Description = reason, Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Edit moderation settings on the webpanel." } }; await CreateLogAsync(gconf, embed); }
private async Task PegAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (!(Context.Channel as ITextChannel).IsNsfw) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "NSFW Error", $"This command can only be used inside channels marked as nsfw...", false); return; } if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}peg <@user>`", false); return; } await Context.Channel.SendMessageAsync($"{Context.User.Mention} pegged {user.Mention}!"); }
private async Task KickMemberAsync(IUser user = null, string reason = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (user == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}kick <user> <reason>`", false); return; } if (reason == null) { reason = "Kicked by " + Context.User.Username + "#" + Context.User.Discriminator; } else { reason += " - Kicked by " + Context.User.Username + "#" + Context.User.Discriminator; } await KickMemberAsync(user, reason); EmbedBuilder embed = new EmbedBuilder() { Title = user.Username + " was kicked", Description = reason, Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Edit moderation settings on the webpanel." } }; await CreateLogAsync(gconf, embed); }
public static void ToggleCommandLogs(ulong guild = 0L, ulong channel = 0L) { BotConfig conf = BotConfig.Load(); if (conf.Type == ConfigType.Solo || guild == 0L) { conf.SoloConfig.LogCommands = !conf.SoloConfig.LogCommands; if (conf.SoloConfig.LogCommands && channel != 0L) { conf.SoloConfig.LogChannel = channel; } } else { IndividualConfig gconf = conf.GetConfig(guild); gconf.LogCommands = !gconf.LogCommands; if (gconf.LogCommands && channel != 0L) { gconf.LogChannel = channel; } } conf.Save(); }
public async Task ReverseAsync([Remainder] string message = null) { if (message != null) { await Context.Message.DeleteAsync(); string newMessage = ""; foreach (char l in message) { newMessage = l + newMessage; } await Context.Channel.SendMessageAsync(newMessage); } else { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}reverse <message>`", false); return; } }