public override async Task PerformAction(SocketReaction option) { switch (option.Emote.ToString()) { case ReactionHandler.CHECK_STR: Program.Settings.AdminUsers.Add(User.Id); Program.Settings.SaveJson(); await Context.Channel.SendMessageAsync(BotUtils.KamtroText($"Added user {BotUtils.GetFullUsername(User)} as an admin.")); KLog.Important($"User {BotUtils.GetFullUsername(User)} added as an admin"); EventQueueManager.RemoveEvent(this); await Message.DeleteAsync(); break; case ReactionHandler.DECLINE_STR: EventQueueManager.RemoveEvent(this); await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Action Canceled.")); await Message.DeleteAsync(); break; } }
public async Task ToggleDebugAsync([Remainder] string args = "") { if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN)) { return; // permissions checking } if (string.IsNullOrWhiteSpace(args)) { Program.Debug = !Program.Debug; await ReplyAsync(BotUtils.KamtroText($"Debug mode turned {(Program.Debug ? "on" : "off")}.")); return; } if (args.ToLower() == "on") { Program.Debug = true; KLog.Important("Debug mode turned on"); await ReplyAsync(BotUtils.KamtroText("Debug mode turned on.")); } else if (args.ToLower() == "off") { Program.Debug = false; KLog.Important("Debug mode turned off"); await ReplyAsync(BotUtils.KamtroText("Debug mode turned off.")); } else if (args.ToLower() == "mode") { await ReplyAsync(BotUtils.KamtroText($"Debug mode is {(Program.Debug ? "on" : "off")}")); } else { await ReplyAsync(BotUtils.KamtroText("Invalid arguments. No args to toggle, '!debug on' to turn debug mode on, '!debug off' to turn debug mode off, '!debug mode' to see current debug mode.")); } }
public static async Task AddTitle(SocketGuildUser user, int titleid) { if (!NodeMap.ContainsKey(titleid)) { KLog.Error($"Attempted to give user {BotUtils.GetFullUsername(user)} invalid title ID #{titleid}"); return; } TitleNode node = NodeMap[titleid]; if (node == null) { KLog.Error($"Attempted to give user {BotUtils.GetFullUsername(user)} null title with ID #{titleid}"); return; } UserDataNode u = UserDataManager.GetUserData(user); if (u.Titles == null) { u.Titles = new List <int>(); } if (u.Titles.Contains(titleid)) { return; // Don't give duplicate titles } u.Titles.Add(titleid); node.OnComplete(user); KLog.Important($"User {BotUtils.GetFullUsername(user)} has earned title {node.Name}"); UserDataManager.SaveUserData(); await AnnounceAchievement(user, node); }