private async Task GuildUpdatedHandler(SocketGuild oldG, SocketGuild newG) { IInviteMetadata invite = null; try { invite = await newG.GetVanityInviteAsync(); } catch (HttpException) { } if (invite != null) { InviteTracker.AddInvite(invite.Guild.Id, new TrackedInvite(invite.Guild.Id, invite.Code, invite.Uses.GetValueOrDefault())); } }
public virtual Task <RestInviteMetadata> GetVanityInviteAsync(RequestOptions?options = null) { return(_socketGuild.GetVanityInviteAsync(options)); }
public async Task <List <InviteModel> > GetLatestInvitesOfGuildAsync(SocketGuild guild) { var resultInvites = new List <InviteModel>(); var vanityUrlInvite = string.IsNullOrEmpty(guild.VanityURLCode) ? null : await guild.GetVanityInviteAsync(); var vanityUses = await GetVanityUrlUsesAsync(guild); var guildInvites = await guild.GetInvitesAsync(); if (guildInvites.Count > 0) { resultInvites.AddRange(guildInvites.Select(o => new InviteModel(o))); } if (vanityUrlInvite != null) { var vanityModel = new InviteModel(vanityUrlInvite) { Uses = vanityUses }; resultInvites.Add(vanityModel); } return(resultInvites); }