示例#1
0
        public async Task ReactionsAsync(bool?setting = null)
        {
            using (var db = new DataContext())
            {
                var match = db.TranslateGuilds.FirstOrDefault(x => x.GuildId == Context.Guild.Id);
                if (match == null)
                {
                    match = new TranslateGuild()
                    {
                        GuildId = Context.Guild.Id,

                        // Enable by default.
                        ReactionsEnabled = setting ?? true
                    };
                    db.TranslateGuilds.Add(match);
                }
                else
                {
                    if (setting.HasValue)
                    {
                        match.ReactionsEnabled = setting.Value;
                        db.TranslateGuilds.Update(match);
                    }
                    else
                    {
                        // Display setting value
                        await ReplyAsync("", false, new LocalEmbedBuilder().WithDescription($"Reaction Translations Enabled: {match.ReactionsEnabled}").Build());

                        return;
                    }
                }

                await db.SaveChangesAsync();
                await ReplyAsync("", false, new LocalEmbedBuilder().WithDescription($"Reaction Translations Enabled: {match.ReactionsEnabled}").Build());
            }
        }