示例#1
0
        public async Task <WebhookWrapper> UpdateWebhookAsync(SocketTextChannel channel, WebhookWrapper old,
                                                              WebhookOptions options)
        {
            var hook = !(_client.GetChannel(old.TextChannel) is SocketTextChannel getChannel)
                ? await GetWebhookAsync(channel.Guild, new WebhookOptions { Webhook = old })
                : await GetWebhookAsync(getChannel, new WebhookOptions { Webhook = old });

            if (channel.Id == old.TextChannel && hook != null)
            {
                return(old);
            }
            if (hook != null)
            {
                await hook.DeleteAsync();
            }
            var New = await channel.CreateWebhookAsync(options.Name, AvatarStream());

            return(new WebhookWrapper
            {
                TextChannel = channel.Id,
                WebhookId = New.Id,
                WebhookToken = New.Token
            });
        }
示例#2
0
        public async Task <WebhookWrapper> UpdateWebhookAsync(SocketTextChannel Channel, WebhookWrapper Old, WebhookOptions Options)
        {
            var Hook = !(SocketClient.GetChannel(Old.TextChannel) is SocketTextChannel GetChannel) ?
                       await GetWebhookAsync(Channel.Guild, new WebhookOptions { Webhook = Old }) :
                       await GetWebhookAsync(GetChannel, new WebhookOptions { Webhook = Old });

            if (Channel.Id == Old.TextChannel && Hook != null)
            {
                return(Old);
            }
            else if (Hook != null)
            {
                await Hook.DeleteAsync();
            }
            var New = await Channel.CreateWebhookAsync(Options.Name, AvatarStream());

            return(new WebhookWrapper
            {
                TextChannel = Channel.Id,
                WebhookId = New.Id,
                WebhookToken = New.Token
            });
        }