Exemple #1
0
        public async Task ToggleReaction()
        {
            LmaoBotServer serverSettings = await Database.GetServerSettings().GetServerSettings((long)Context.Guild.Id);

            int newChance;

            if (serverSettings.BotSettings.ReplaceAssChance != 0)
            {
                await Database.GetServerSettings().SetReactChance((long)Context.Guild.Id, 0);

                await Database.GetServerSettings().SetReplaceAssChance((long)Context.Guild.Id, 0);

                newChance = 0;
            }
            else
            {
                await Database.GetServerSettings().SetReactChance((long)Context.Guild.Id, 100);

                await Database.GetServerSettings().SetReplaceAssChance((long)Context.Guild.Id, 100);

                newChance = 100;
            }

            await ReplyAsync(Context.User.Mention + " You have set the ass replacement chance to `" + newChance + "%`.");
        }
Exemple #2
0
        public override async Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            DatabaseService db       = (DatabaseService)services.GetService(typeof(DatabaseService));
            LmaoBotServer   settings = await db.GetServerSettings().GetServerSettings((long)context.Guild.Id);

            if (settings.BotSettings.AllowNSFW)
            {
                return(await Task.FromResult(PreconditionResult.FromSuccess()));
            }
            else
            {
                return(await Task.FromResult(PreconditionResult.FromError("The bot is not allowed to use NSFW commands in this server. See `lmao nsfwtoggle` for more info.")));
            }
        }
Exemple #3
0
        public async Task ToggleNSFW()
        {
            LmaoBotServer settings = await Database.GetServerSettings().GetServerSettings((long)Context.Guild.Id);

            bool isEnabled = !settings.BotSettings.AllowNSFW;
            await Database.GetServerSettings().SetAllowNSFW((long)Context.Guild.Id, isEnabled);

            if (isEnabled)
            {
                await ReplyAsync("NSFW Commands have now been enabled for your guild. :smirk:");
            }
            else
            {
                await ReplyAsync("NSFW Commands are now disabled for your guild.");
            }
        }
Exemple #4
0
        public async Task ReplaceAss()
        {
            //We don't want to get server settings of a DM.
            if (Context.Channel is IDMChannel)
            {
                await ReplyAsync(Context.User.Mention + " You appear to have misplaced your ass while laughing. Here is a replacement: :peach:");
            }
            else
            {
                LmaoBotServer serverSettings = await Database.GetServerSettings().GetServerSettings((long)Context.Guild.Id);

                if (new Random().Next(1, 100) <= serverSettings.BotSettings.ReplaceAssChance)
                {
                    await ReplyAsync(Context.User.Mention + " You appear to have misplaced your ass while laughing. Here is a replacement: :peach:");
                }
                if (new Random().Next(1, 100) <= serverSettings.BotSettings.ReactChance)
                {
                    await Context.Message.AddReactionAsync(new Emoji("\U0001F351"));
                }
            }
            await Database.GetUserSettings().IncrementLmaoCount((long)Context.User.Id);
        }
        /// <summary>
        /// Retrieves the server settings for the specified ID
        /// </summary>
        /// <param name="serverID">The ID of the server</param>
        /// <returns>The specified server settings</returns>
        public async Task <LmaoBotServer> GetServerSettings(long serverID)
        {
            var filter = Builders <LmaoBotServer> .Filter.Eq("ServerID", serverID);

            if (await Collection.CountDocumentsAsync(filter) == 1)
            {
                LmaoBotServer serverSettings = await Collection.Find(filter).FirstAsync();

                return(serverSettings);
            }
            //TODO: FOR TESTING PURPOSES ONLY.
            //this shouldn't be required if the database is up to date.
            else
            {
                await CreateServerSettings(serverID);

                LmaoBotServer serverSettings = await Collection.Find(filter).FirstAsync();

                return(serverSettings);
            }
            //return null;
        }
Exemple #6
0
        public async Task Prefix(string prefix = null)
        {
            if (prefix == null)
            {
                var embed = new EmbedBuilder()
                {
                    Title       = "Prefix Settings",
                    Description = $"Current Prefix: **{await Database.GetPrefix((long)Context.Guild.Id)}**",
                    Color       = Color.Orange,
                    Footer      = new EmbedFooterBuilder()
                    {
                        Text = "Include your new prefix as an argument if you want to change it"
                    }
                }.Build();
                await ReplyAsync(embed : embed);
            }
            else
            {
                LmaoBotServer settings = await Database.GetServerSettings().GetServerSettings((long)Context.Guild.Id);

                string oldPrefix = settings.BotSettings.CommandPrefix;
                settings.BotSettings.CommandPrefix = prefix;

                await Database.GetServerSettings().SetServerPrefix((long)Context.Guild.Id, prefix);

                Database.SetPrefix((long)Context.Guild.Id, prefix);

                var embed = new EmbedBuilder()
                {
                    Title       = "Prefix Settings Changed",
                    Description = $"Old Prefix: {oldPrefix}\n**New Prefix: {prefix}**",
                    Color       = Color.Orange,
                    Footer      = new EmbedFooterBuilder()
                }.Build();
                await ReplyAsync(embed : embed);
            }
        }