Example #1
0
        public static async Task <DiscordInvite> CreateInviteAsync(this DiscordClient client, ulong channelId, InviteProperties properties = null)
        {
            if (properties == null)
            {
                properties = new InviteProperties();
            }

            return((await client.HttpClient.PostAsync($"/channels/{channelId}/invites", properties))
                   .ParseDeterministic <DiscordInvite>().SetClient(client));
        }
Example #2
0
        /// <summary>
        /// Creates an invite for a channel
        /// </summary>
        /// <param name="channelId">ID of the channel</param>
        /// <param name="properties">Options for creating the invite</param>
        /// <returns>The created invite</returns>
        public static Invite CreateInvite(this DiscordClient client, ulong channelId, InviteProperties properties = null)
        {
            if (properties == null)
            {
                properties = new InviteProperties();
            }

            return(client.HttpClient.Post($"/channels/{channelId}/invites", properties)
                   .Deserialize <Invite>().SetClient(client));
        }
Example #3
0
        public static PartialInvite CreateInvite(this DiscordClient client, long channelId, InviteProperties properties = null)
        {
            if (properties == null)
            {
                properties = new InviteProperties();
            }

            return(client.HttpClient.Post($"/channels/{channelId}/invites", JsonConvert.SerializeObject(properties))
                   .Deserialize <PartialInvite>().SetClient(client));
        }
Example #4
0
        public static Invite CreateInvite(this DiscordClient client, long channelId, InviteProperties properties)
        {
            var resp = client.HttpClient.Post($"/channels/{channelId}/invites", JsonConvert.SerializeObject(properties));

            if (resp.StatusCode == HttpStatusCode.NotFound)
            {
                throw new ChannelNotFoundException(client, channelId);
            }

            Invite invite = JsonConvert.DeserializeObject <Invite>(resp.Content.ReadAsStringAsync().Result);

            invite.Client = client;
            return(invite);
        }
Example #5
0
 public PartialInvite CreateInvite(InviteProperties properties = null)
 {
     return(Client.CreateInvite(Id, properties));
 }
Example #6
0
 /// <summary>
 /// Creates an invite
 /// </summary>
 /// <param name="properties">Options for creating the invite</param>
 /// <returns></returns>
 public DiscordInvite CreateInvite(InviteProperties properties = null)
 {
     return(Client.CreateInvite(Id, properties));
 }
Example #7
0
 /// <summary>
 /// Creates an invite for the channel
 /// </summary>
 /// <param name="properties">Options for creating the invite</param>
 /// <returns>The created invite</returns>
 public DiscordInvite CreateInvite(InviteProperties properties = null)
 {
     return(CreateInviteAsync(properties).GetAwaiter().GetResult());
 }
Example #8
0
 public async Task <DiscordInvite> CreateInviteAsync(InviteProperties properties = null)
 {
     return(await Client.CreateInviteAsync(Id, properties));
 }
Example #9
0
 public Invite CreateInvite(InviteProperties properties)
 {
     return(Client.CreateInvite(Id, properties));
 }
Example #10
0
 /// <summary>
 /// Creates an invite for a channel
 /// </summary>
 /// <param name="channelId">ID of the channel</param>
 /// <param name="properties">Options for creating the invite</param>
 /// <returns>The created invite</returns>
 public static DiscordInvite CreateInvite(this DiscordClient client, ulong channelId, InviteProperties properties = null)
 {
     return(client.CreateInviteAsync(channelId, properties).GetAwaiter().GetResult());
 }