Beispiel #1
0
        public static async Task LookupAndSendAsync(SocketGuild guild, SocketCommandContext context, string channelName, string message, bool replyable, DataBase db)
        {
            var dbGuild = FindOrCreateGuild.Perform(guild, db);

            if (!UserHasRole.Perform(guild, context.User, dbGuild))
            {
                await context.Channel.SendMessageAsync("You do not have the role required to send messages to this server.");

                return;
            }

            var candidateChannels = guild.TextChannels.Where(x => x.Name.ToLower().Contains(channelName.ToLower()) || x.Id.ToString() == channelName);

            if (!candidateChannels.Any())
            {
                await context.Channel.SendMessageAsync("The channel you specified couldn't be found. Please specify your channel using the following command: `send (channel_name) (message)` ex: `send some-channel you guys suck`");

                return;
            }

            var prefix          = PrefixHelper.ComputePrefix(context, dbGuild);
            var channel         = candidateChannels.OrderBy(x => x.Name.Length).First();
            var messageFunction = Send.SendMessageToChannel(channel, replyable, context.User);

            await messageFunction(prefix, message);

            await Send.SendSentEmote(context);
        }
Beispiel #2
0
        public static async Task LookupAndSendAsync(SocketGuild guild, ShardedCommandContext context, string channelName, string message, bool replyable, DataBase db)
        {
            var dbGuild = FindOrCreateGuild.Perform(guild, db);

            if (!UserHasRole.Perform(guild, context.User, dbGuild))
            {
                await Send.SendErrorWithDeleteReaction(context, "You do not have the role required to send messages to this server.");

                return;
            }

            var candidateChannels = guild.TextChannels.Where(x => x.Name.ToLower().Contains(channelName.ToLower()) || x.Id.ToString() == channelName);

            if (!candidateChannels.Any())
            {
                await Send.SendErrorWithDeleteReaction(context, "The channel you specified couldn't be found. Please specify your channel using the following command: `send (channel_name) (message)` ex: `send some-channel you guys suck`");

                return;
            }

            if (PrefixHelper.UserBlocked(context.User.Id, dbGuild))
            {
                await context.Channel.SendMessageAsync("It appears that you have been banned from using Voltaire on the targeted server. If you think this is an error, contact one of your admins.");

                return;
            }

            if (!IncrementAndCheckMessageLimit.Perform(dbGuild, db))
            {
                await Send.SendErrorWithDeleteReaction(context, "This server has reached its limit of 50 messages for the month. To lift this limit, ask an admin or moderator to upgrade your server to Voltaire Pro.");

                return;
            }

            var prefix          = PrefixHelper.ComputePrefix(context, dbGuild);
            var channel         = candidateChannels.OrderBy(x => x.Name.Length).First();
            var messageFunction = Send.SendMessageToChannel(channel, replyable, context);

            await messageFunction(prefix, message);

            await Send.SendSentEmote(context);

            return;
        }
        private static bool FilterGuildByRole(SocketGuildUser reciver, IUser sender, DataBase db)
        {
            var guild = db.Guilds.FirstOrDefault(x => x.DiscordId == reciver.Guild.Id.ToString());

            return(UserHasRole.Perform(reciver.Guild, sender, guild));
        }