示例#1
0
        public static async Task War_Prep_Started(IGuildConfig cfg, byte WarNo)
        {
            //Guild has elected out for this notification.
            if (!cfg[Setting_Key.WAR_PREP_STARTED].Enabled)
            {
                return;
            }
            //Guild elected out of this specific war.
            else if (!shouldSendSpecificWar(cfg, WarNo))
            {
                return;
            }

            ///Determine the message to send.
            string Message = "";

            if (cfg[Setting_Key.WAR_PREP_STARTED].HasValue)
            {
                Message = getMessageForSpecificWar(cfg[Setting_Key.WAR_PREP_STARTED].Value, WarNo);

                if (!string.IsNullOrEmpty(Message))
                {
                    await sendWarMessage(cfg, Message);

                    return;
                }

                //If the message is empty- will revert to using the default message instead.
            }

            //Send a default message.
            if (cfg.GetGuildRole(RoleLevel.Member).IsNotNull(out IRole role) && role.IsMentionable)
            {
                Message = $"{role.Mention}, WAR Placement has started! Please place your troops in the next two hours!";
            }
示例#2
0
        /// <summary>
        /// This will return a guild user's current WarBot Role.
        /// Only used inside of guild-context.
        /// </summary>
        /// <param name="User"></param>
        /// <param name="cfg"></param>
        /// <returns></returns>
        public static RoleLevel GetRole(this SocketGuildUser User, IGuildConfig cfg)
        {
            //Yup, this is my statically defined userID. Its stupid, and it works. Will update one day.
            //ToDo - Update global admin selection.
            if (User.Id == 381654208073433091)
            {
                return(RoleLevel.GlobalAdmin);
            }

            //If the user has Administrator permissions for the guild, return ServerAdmin role.
            if (User.GuildPermissions.Administrator)
            {
                return(RoleLevel.ServerAdmin);
            }

            //Loop through all Guild Roles, Highest to Lowest.
            //None is excluded, because it should never have a guild role assigned.
            //Global admin is excluded, because it is only specified by the first statement in this method.
            foreach (var Role in GetRoleValues().Where(o => o != RoleLevel.GlobalAdmin && o != RoleLevel.None).OrderByDescending(o => (int)o))
            {
                ulong?guildRoleId = cfg.GetGuildRole(Role)?.Id;
                if (guildRoleId.HasValue && User.Roles.Any(o => o.Id == guildRoleId))
                {
                    return(Role);
                }
            }

            //No roles found.
            return(RoleLevel.None);
        }
示例#3
0
        public static async Task Portal_Opened(IGuildConfig cfg)
        {
            ///Determine the message to send.
            string Message = "";

            if (!cfg[Setting_Key.PORTAL_STARTED].HasValue)
            {
                if (cfg.GetGuildRole(RoleLevel.Member).IsNotNull(out var role) && role.IsMentionable)
                {
                    Message = $"{role.Mention}, The portal has opened!";
                }
                else
                {
                    Message = "The portal has opened!";
                }
            }