public async Task AddCommandChannel([Summary("The channel to add as a command channel")] ITextChannel channel) { await _context.CommandChannels.AddAsync(new Data.Models.CommandChannel { ChannelId = channel.Id, GuildId = Context.Channel.Id }); await _context.SaveChangesAsync(); await Context.AddConfirmation(); }
private async Task JoinedGuild(SocketGuild guild) { // Disable suggestion to simplify Data.Models.Guild to Guild // to avoid confusion between Data.Models.Guild and some flavor of Discord Guild. #pragma warning disable IDE0001 var guildConfig = new Data.Models.Guild() { GuildId = guild.Id, CommandPrefix = "." }; #pragma warning restore IDE0001 await _context.Guilds.AddAsync(guildConfig); await _context.SaveChangesAsync(); }
public async Task SetGreetUser([Summary("True if the bot should greet new users; otherwise, false")] bool shouldGreet) { var guild = await _context.Guilds.FindAsync(Context.Guild.Id); if (guild.GreetUser.Equals(shouldGreet)) { await Context.ReplyWithEmbed($"I was already {(shouldGreet ? "greeting" : "ignoring")} new users. No changes were made."); } else { guild.GreetUser = shouldGreet; await _context.SaveChangesAsync(); await Context.ReplyWithEmbed($"I will now {(shouldGreet ? "greet" : "ignore")} new users."); } }
public async Task RegisterRole(IRole role, IRole category, bool requireAdult = false) { var arole = new AssignableRole() { GuildId = Context.Guild.Id, Position = role.Position, Require18Plus = requireAdult, RoleCategory = category.Id, RoleId = role.Id }; await _dbContext.AssignableRoles.AddAsync(arole); await _dbContext.SaveChangesAsync(); await Context.AddConfirmation(); }
public async Task SetPrefix([NotNullOrWhiteSpace][Summary("The new prefix for this bot to use")] string newPrefix) { var guild = await _context.Guilds.FindAsync(Context.Guild.Id); var oldPrefix = guild.CommandPrefix; if (guild.CommandPrefix.Equals(newPrefix)) { await Context.ReplyWithEmbed($"Guild prefix was already '{oldPrefix}'. No changes were made."); } else { guild.CommandPrefix = newPrefix; await _context.SaveChangesAsync(); // await ReplyAsync($"Guild prefix updated: {oldPrefix} -> {guild.CommandPrefix}"); await Context.AddConfirmation(); } }