Example #1
0
        public async Task BanAsync(IGuildUser author, IGuildUser user, IGuild guild, string reason)
        {
            var dbGuild = await _guildService.ObtainAsync(guild);

            var ban = new Data.Models.Ban
            {
                CreatorId = author.Id.ToLong(),
                UserId    = user.Id.ToLong(),
                Reason    = reason,
                Guild     = dbGuild,
            };

            await _context.Bans.AddAsync(ban);

            await _context.SaveChangesAsync();
        }
Example #2
0
        public IRole GetRoleByPermission(ICommandContext context, Permissions perms)
        {
            var guild = GuildService.ObtainAsync(context.Guild).Result;

            if (guild.Config == null)
            {
                throw new GuildConfigException(
                          "DiscordGuild is not configured yet. Please use the config module to set it up!");
            }

            switch (perms)
            {
            case Permissions.Administrator:
                return(context.Guild.GetRole(guild.Config.AdminRoleId.ToUlong()));

            case Permissions.Moderator:
                return(context.Guild.GetRole(guild.Config.ModeratorRoleId.ToUlong()));
            }
            // If I ever f**k this up, blame obsi :D
            throw new GuildConfigException(
                      "DiscordGuild is not configured yet. Please use the config module to set it up!");
        }
 public GuildConfigService(IGuild guild, ModixContext context)
 {
     _guildService = new DiscordGuildService(context);
     _guild        = _guildService.ObtainAsync(guild).Result;
 }
Example #4
0
 public GuildConfigService(IGuild guild)
 {
     _guild = _guildService.ObtainAsync(guild).Result;
 }