예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemporaryGuildMemberPoolValues"/> struct.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="id">The id.</param>
 /// <param name="guild">The guild.</param>
 /// <param name="rank">The rank.</param>
 public TemporaryGuildMemberPoolValues(string name, int id, IGuild guild, GuildRank rank)
 {
     _name  = name;
     _id    = id;
     _guild = guild;
     _rank  = rank;
 }
예제 #2
0
 /// <summary>
 /// Initializes the <see cref="TemporaryGuildMember"/>'s values.
 /// </summary>
 /// <param name="values">The values to use.</param>
 public void Initialize(ref TemporaryGuildMemberPoolValues values)
 {
     _name  = values.Name;
     _id    = values.ID;
     _guild = values.Guild;
     _rank  = values.Rank;
 }
예제 #3
0
        /// <summary>
        /// Ensures a guild member invoking an event meets the rank requirements to invoke the event.
        /// </summary>
        /// <param name="invoker">The guild member invoking the event.</param>
        /// <param name="minRequiredRank">The minimum rank required to invoke the event.</param>
        /// <returns>True if the <paramref name="invoker"/> is a high enough rank to invoke the event;
        /// otherwise false.</returns>
        static bool EnsureValidRank(IGuildMember invoker, GuildRank minRequiredRank)
        {
            if (invoker.GuildRank < minRequiredRank)
            {
                const string errmsg =
                    "Guild member `{0}` from guild `{1}` tried to invoke an event, but their rank was not" +
                    " high enough (rank: `{2}` req: `{3}`).";
                if (log.IsInfoEnabled)
                {
                    log.InfoFormat(errmsg, invoker, invoker.Guild, invoker.GuildRank, minRequiredRank);
                }
                return(false);
            }

            return(true);
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuildMemberNameRank"/> struct.
 /// </summary>
 /// <param name="name">The guild member's name.</param>
 /// <param name="rank">The guild member's rank.</param>
 public GuildMemberNameRank(string name, GuildRank rank)
 {
     _name = name;
     _rank = rank;
 }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GuildSettings"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException"><paramref name="rankNames" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="nameRules" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="tagRules" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">There must be exactly one rank name for each rank.</exception>
        /// <exception cref="ArgumentException">Guild rank names may not be empty or null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><c>inviteResponseTime</c> is out of range.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><c>minRankRename</c> is out of range.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><c>minRankViewLog</c> is out of range.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><c>minRankKick</c> is out of range.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><c>minRankInvite</c> is out of range.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><c>minRankPromote</c> is out of range.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><c>minRankDemote</c> is out of range.</exception>
        public GuildSettings(int inviteResponseTime, GuildRank highestRank, string[] rankNames, StringRules nameRules,
                             StringRules tagRules, GuildRank minRankRename, GuildRank minRankViewLog, GuildRank minRankKick,
                             GuildRank minRankInvite, GuildRank minRankPromote, GuildRank minRankDemote)
        {
            if (rankNames == null)
            {
                throw new ArgumentNullException("rankNames");
            }
            if (rankNames.Length != highestRank + 1)
            {
                throw new ArgumentException("There must be exactly one rank name for each rank.", "rankNames");
            }
            if (rankNames.Any(x => string.IsNullOrEmpty(x)))
            {
                throw new ArgumentException("Guild rank names may not be empty or null.", "rankNames");
            }
            if (nameRules == null)
            {
                throw new ArgumentNullException("nameRules");
            }
            if (tagRules == null)
            {
                throw new ArgumentNullException("tagRules");
            }
            if (inviteResponseTime <= 0)
            {
                throw new ArgumentOutOfRangeException("inviteResponseTime");
            }

            if (minRankRename > highestRank)
            {
                throw new ArgumentOutOfRangeException("minRankRename");
            }
            if (minRankViewLog > highestRank)
            {
                throw new ArgumentOutOfRangeException("minRankViewLog");
            }
            if (minRankKick > highestRank)
            {
                throw new ArgumentOutOfRangeException("minRankKick");
            }
            if (minRankInvite > highestRank)
            {
                throw new ArgumentOutOfRangeException("minRankInvite");
            }
            if (minRankPromote > highestRank)
            {
                throw new ArgumentOutOfRangeException("minRankPromote");
            }
            if (minRankDemote > highestRank)
            {
                throw new ArgumentOutOfRangeException("minRankDemote");
            }

            _inviteResponseTime = inviteResponseTime;

            _highestRank = highestRank;
            _rankNames   = rankNames;
            _nameRules   = nameRules;
            _tagRules    = tagRules;

            _minRankRename  = minRankRename;
            _minRankViewLog = minRankViewLog;
            _minRankKick    = minRankKick;
            _minRankInvite  = minRankInvite;
            _minRankPromote = minRankPromote;
            _minRankDemote  = minRankDemote;
        }
예제 #6
0
 /// <summary>
 /// Gets the name of the given <paramref name="rank"/>.
 /// </summary>
 /// <param name="rank">The guild rank.</param>
 /// <returns>The name of the given <paramref name="rank"/>.</returns>
 public string GetRankName(GuildRank rank)
 {
     return(_rankNames[rank]);
 }
예제 #7
0
 /// <summary>
 /// When overridden in the derived class, handles when the <see cref="GuildMemberInfo{T}.Owner"/> is promoted.
 /// </summary>
 /// <param name="rank">The new rank.</param>
 protected virtual void HandlePromotion(GuildRank rank)
 {
 }