public async Task HandleUnlistMissionCommand(CommandContext context) { string channelname = context.Channel.Name; string message = string.Empty; bool error = true; if (ulong.TryParse(context.Args[1], out ulong parsedChannelId)) { if (MissionModel.missionList.Contains(parsedChannelId)) { MissionModel.missionList.Remove(parsedChannelId); await MissionModel.SaveMissions(); message = string.Format("Successfully removed mission `{0}` from missionlist!", context.Args[1]); error = false; } else { message = string.Format("Could not find mission Id `{0}` in missionlist!", context.Args[1]); } } else { message = "Could not parse second argument as an uInt64!"; } await context.Channel.SendEmbedAsync(message, error); }
public static async Task InitiateBasicFiles() { Directory.CreateDirectory(BaseDirectory); await SettingsModel.SaveSettings(); await MissionSettingsModel.SaveMissionSettings(); await MissionModel.SaveMissions(); Directory.CreateDirectory(ShitpostingDirectory); Directory.CreateDirectory(QuotesDirectory); }
public async Task HandleCreateRoomCommand(CommandContext context) { if (context.Message.MentionedUsers.Count > 0) { RestTextChannel NewMissionChannel = await MissionModel.CreateMission(context.Args[1], context.Message.MentionedUsers, context.Guild, context.User); await context.Channel.SendEmbedAsync("Successfully created new Mission. Check it out: " + NewMissionChannel.Mention); } else { await context.Channel.SendEmbedAsync("You need to mention explorers (Example: @Explorer#0001)!"); } }
public async Task HandleCompleteMissionCommand(CommandContext context) { if (MissionModel.IsMissionChannel(context.Channel.Id, context.Guild.Id)) { ITextChannel channel = context.Channel as ITextChannel; if (channel != null) { await context.Channel.SendEmbedAsync(channel.Topic); } await context.Channel.SendEmbedAsync(MissionSettingsModel.TestimonialPrompt); await context.Channel.SendEmbedAsync(MissionSettingsModel.FileReportPrompt); } else { await context.Channel.SendEmbedAsync("Could not verify this channel as a mission channel!", true); } }
public async Task HandleCloseMissionCommand(CommandContext context) { string channelname = context.Channel.Name; ulong? channelId = null; if (context.Args[1].Equals("this")) { channelId = context.Channel.Id; } else if (context.Message.MentionedChannels.Count > 0) { channelId = new List <SocketGuildChannel>(context.Message.MentionedChannels)[0].Id; } else if (ulong.TryParse(context.Args[1], out ulong parsedChannelId)) { channelId = parsedChannelId; } if (channelId != null) { if (MissionModel.IsMissionChannel((ulong)channelId, context.Guild.Id)) { await MissionModel.DeleteMission((ulong)channelId, context.Guild.Id); if ((ulong)channelId != context.Channel.Id) { await context.Channel.SendEmbedAsync("Successfully deleted mission channel!", false); } await SettingsModel.SendDebugMessage(string.Format("Closed mission {0}", channelname), DebugCategories.missions); } else { await context.Channel.SendEmbedAsync("Could not verify this channel as a mission channel! Ask an admin to delete it.", true); } } else { await context.Channel.SendEmbedAsync("Second argument must specify a channel!", true); } }
/// <summary> /// Main Programs method running asynchronously /// </summary> /// <returns></returns> public async Task MainAsync() { Console.Title = "Ciridium Wing Bot v" + Var.VERSION.ToString(); Thread.CurrentThread.CurrentCulture = Var.Culture; Var.client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Info }); bool filesExist = false; bool foundToken = false; if (ResourcesModel.CheckSettingsFilesExistence()) { filesExist = true; if (await SettingsModel.LoadSettingsAndCheckToken(Var.client)) { foundToken = true; } } if (foundToken) { await MissionSettingsModel.LoadMissionSettings(); await MissionModel.LoadMissions(); await QuoteService.LoadQuotes(); Var.client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Info }); InitCommands(); #if WELCOMING_MESSAGES Var.client.UserJoined += HandleUserJoined; Var.client.UserLeft += HandleUserLeft; #endif Var.client.Log += Logger; SettingsModel.DebugMessage += Logger; Var.client.Connected += ScheduleConnectDebugMessage; Var.client.ReactionAdded += HandleReactionAdded; QuoteReactions quoteReact = new QuoteReactions(); await Var.client.LoginAsync(TokenType.Bot, SettingsModel.token); await Var.client.StartAsync(); await TimingThread.UpdateTimeActivity(); while (Var.running) { await Task.Delay(100); } if (string.IsNullOrEmpty(Var.RestartPath)) { await SettingsModel.SendDebugMessage("Shutting down ...", DebugCategories.misc); } else { await SettingsModel.SendDebugMessage("Restarting ...", DebugCategories.misc); } Var.client.Dispose(); } else { if (!filesExist) { await Logger(new LogMessage(LogSeverity.Critical, "SETTINGS", string.Format("Could not find config files! Standard directory is \"{0}\".\nReply with 'y' if you want to generate basic files now!", ResourcesModel.BaseDirectory))); if (Console.ReadLine().ToCharArray()[0] == 'y') { await ResourcesModel.InitiateBasicFiles(); } } else { await Logger(new LogMessage(LogSeverity.Critical, "SETTINGS", string.Format("Could not find a valid token in Settings file ({0}). Press any key to exit!", ResourcesModel.SettingsFilePath))); Console.ReadLine(); } } if (!string.IsNullOrEmpty(Var.RestartPath)) { System.Diagnostics.Process.Start(Var.RestartPath); } }