Beispiel #1
0
        public virtual string AllowExecution(SocketMessage e)
        {
            string errors = string.Empty;

            if (commandEnabled == false)
            {
                errors += "\n\tNot enabled on this server.";
            }

            if (!availableInDM && e.Channel as SocketDMChannel != null)
            {
                errors += "\n\tNot available in DM channels.";
            }

            if (isAdminOnly && !(e.Author as SocketGuildUser).GuildPermissions.Administrator)
            {
                errors += "\n\tUser is not administrator.";
            }

            if (!availableOnServer && e.Channel as SocketGuildChannel != null)
            {
                errors += "\n\tNot avaiable on server.";
            }

            if (requiredPermission != Permissions.Type.Null && !Permissions.HasPermission(e.Author as SocketGuildUser, requiredPermission))
            {
                errors += "\n\tNot permitted to use this command.";
            }

            return(errors);
        }
Beispiel #2
0
        // This entire function might need a rewrite.
        public static bool VoteForGame(ulong userID, int id)
        {
            SocketGuildUser user = Utility.GetServer().GetUser(userID);
            List <Vote>     userVotes;

            if (status == WeeklyEventStatus.Waiting)
            {
                string locText = onVotedPostCount;
                Program.messageControl.SendMessage(user, locText);
                return(false);
            }

            if (HasReachedVoteLimit(userID, out userVotes))
            {
                string locText = onMaxVotesReachedDM;
                Program.messageControl.SendMessage(user, locText);
                return(false);
            }

            if (!Permissions.HasPermission(user, Permissions.Type.VoteForEvents))
            {
                Program.messageControl.SendMessage(user, "Failed to vote for event - You do not have permission to do so.");
                return(false);
            }

            foreach (Vote v in userVotes)
            {
                if (v.votedGameID == id)
                {
                    string locText = onVotedForGameTwiceDM;
                    Program.messageControl.SendMessage(user, locText);
                    return(false);
                }
            }

            votes.Add(new Vote(userID, id));
            games [id].votes++;

            UpdateVoteMessage(false);
            SaveData();

            return(true);
        }