private async Task Client_GuildMemberAdded(GuildMemberAddEventArgs e) { var guildSettings = await _guildSettingsService.GetGuildSettingsByIdAsync(e.Guild.Id); if (guildSettings == null) { return; } if (guildSettings.AutoWelcomeMessage) { await SendWelcomeMessage(e.Member, GetWelcomeMessagEmbed(e.Member, e.Guild)); } if (guildSettings.AutoRole) { await GrantDefaultRole(e.Member, guildSettings.AutoRoleName); } }
public override async Task <bool> CanExecute(CommandContext ctx, bool help) { if (ctx.Guild == null || ctx.Member == null) { return(false); } _serverSettings = await _serverSettingsService.GetGuildSettingsByIdAsync(ctx.Guild.Id); var userRealType = GetUserType(ctx.Member); return(_checkMode switch { UserTypeCheckMode.Any => _userTypes.Any(x => x == userRealType), UserTypeCheckMode.None => _userTypes.All(x => x != userRealType), UserTypeCheckMode.MineOrParentAny => (_userTypes.Any(x => x == userRealType) == true || _userTypes.Where(x => x != userRealType) .Any(userType => userRealType == userType - 1)), _ => throw new ArgumentOutOfRangeException() });