Ejemplo n.º 1
0
 public DiscordCommandContext(IDiscordClient client, IUserMessage message, IGuildConfiguration guildConfiguration, IDiscordBot discordBot, IGuildUser guildUser)
     : base(client, message)
 {
     GuildConfiguration = guildConfiguration;
     DiscordBot         = discordBot;
     GuildUser          = guildUser;
 }
Ejemplo n.º 2
0
        public GuildManager(ILogger <IGuildManager> logger, IGuildConfiguration config, IGuildHouseConfiguration houseConfig, IDatabase database, IGameWorld gameWorld, ITimeService timeService)
        {
            _logger      = logger;
            _database    = database;
            _gameWorld   = gameWorld;
            _timeService = timeService;

            _config      = config;
            _houseConfig = houseConfig;
        }
Ejemplo n.º 3
0
        public string GetSyntax(CommandInfo cmd, IBotConfiguration botConfig, IGuildConfiguration guildConfiguration = null)
        {
            char prefix = botConfig.DirectMessageCommandPrefix;

            if (guildConfiguration != null)
            {
                prefix = guildConfiguration.CommandPrefix;
            }

            return(Syntax
                   .Replace("{prefix}", prefix.ToString(), StringComparison.OrdinalIgnoreCase)
                   .Replace("{command}", cmd.Name, StringComparison.OrdinalIgnoreCase));
        }
Ejemplo n.º 4
0
        public GuildManager(ILogger <IGuildManager> logger, IGuildConfiguration config, IGuildHouseConfiguration houseConfig, IDatabase database, IGameWorld gameWorld, ITimeService timeService, IInventoryManager inventoryManager, IPartyManager partyManager, ICountryProvider countryProvider, IEtinManager etinManager)
        {
            _logger           = logger;
            _database         = database;
            _gameWorld        = gameWorld;
            _timeService      = timeService;
            _inventoryManager = inventoryManager;
            _partyManager     = partyManager;
            _countryProvider  = countryProvider;
            _etinManager      = etinManager;
            _config           = config;
            _houseConfig      = houseConfig;
#if DEBUG
            _logger.LogDebug("GuildManager {hashcode} created", GetHashCode());
#endif
        }
Ejemplo n.º 5
0
 public LlectroBotCardContext(IDiscordClient discordClient, IGuild guild, IMessageChannel channel, IUser user, IUserMessage message, IBotConfiguration botConfiguration, IGuildConfiguration guildConfiguration) : base(discordClient, guild, channel, user, message)
 {
     BotConfiguration   = botConfiguration;
     GuildConfiguration = guildConfiguration;
 }
Ejemplo n.º 6
0
        public static RoleLevel GetRole(this IGuildUser user, IBotConfiguration botConfiguration, IGuildConfiguration guildConfiguration)
        {
            if (user is null)
            {
                return(RoleLevel.None);
            }
            if (botConfiguration is null)
            {
                return(RoleLevel.None);
            }
            if (guildConfiguration is null)
            {
                return(RoleLevel.None);
            }

            if (user.Id == botConfiguration.GlobalAdminId)
            {
                return(RoleLevel.GlobalAdministrator);
            }

            if (user.GuildPermissions.Administrator)
            {
                return(RoleLevel.GuildAdministrator);
            }

            // get a list of guild roles
            var roles = guildConfiguration.Roles
                        .OrderByDescending(r => (int)r.Level);

            foreach (var role in roles)
            {
                ulong guildRoleId = role.RoleId;
                if (user.RoleIds.Any(roleId => roleId == guildRoleId))
                {
                    return(role.Level);
                }
            }
            return(RoleLevel.None);
        }