public async Task <bool> AddServerInfo(DbDiscordServer newServer) { var database = _mongodb.GetDatabase(_mongodbName); var serverCollection = database.GetCollection <DbDiscordServer>("servers"); await serverCollection.InsertOneAsync(newServer); return(true); }
public async Task <bool> RemoveServerInfo(DbDiscordServer server) { var database = _mongodb.GetDatabase(_mongodbName); var serverCollection = database.GetCollection <DbDiscordServer>("servers"); var filter = Builders <DbDiscordServer> .Filter.Eq("server_id", server.ServerId); await serverCollection.DeleteOneAsync(filter); return(true); }
public async Task ConfigureServerAsync() { ulong configChannelId; ulong reminderChannelId; // config channel await ReplyAndDeleteAsync($"Tag the channel you want **configuration** messages sent to (for example, {MentionUtils.MentionChannel(Context.Channel.Id)}).", false, null, TimeSpan.FromMinutes(1)); var response = await NextMessageAsync(true, true, TimeSpan.FromSeconds(30)); if (response != null) { if (response.MentionedChannels.FirstOrDefault() != null) { configChannelId = MentionUtils.ParseChannel(response.Content); } else { await ReplyAsync("You didn't correctly tag a channel. Follow the instructions, dingus."); return; } } else { await ReplyAsync("I didn't get a response in time. Try again."); return; } // reminder channel await ReplyAndDeleteAsync($"Tag the channel you want **reminders & the schedule** sent to (for example, {MentionUtils.MentionChannel(Context.Channel.Id)}).", false, null, TimeSpan.FromMinutes(1)); response = await NextMessageAsync(true, true, TimeSpan.FromSeconds(30)); if (response != null) { if (response.MentionedChannels.FirstOrDefault() != null) { reminderChannelId = MentionUtils.ParseChannel(response.Content); } else { await ReplyAsync("You didn't correctly tag a channel. Follow the instructions, dingus."); return; } } else { await ReplyAsync("I didn't get a response in time. Try again."); return; } // build our new server object var newServer = new DbDiscordServer() { ConfigChannelId = configChannelId.ToString(), ReminderChannelId = reminderChannelId.ToString(), ServerId = Context.Guild.Id.ToString(), ServerName = Context.Guild.Name, RemindersEnabled = true }; // add this server's data to the database await DatabaseServers.AddServerInfo(newServer); // initialize this server RaidEventsService.SetServerDiscordObjects(newServer); // update the ServerList with the new server DbDiscordServers.ServerList.Add(newServer); // set up google api authentication await AuthAsync(); }