Exemple #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                _webhook?.DeleteAsync().ConfigureAwait(false).GetAwaiter().GetResult();
            }

            IsDisposed = true;
        }
Exemple #2
0
            public async Task DeleteAsync(CommandContext ctx,
                                          [Description("Name.")] string name,
                                          [Description("Channel to list webhooks for.")] DiscordChannel channel = null)
            {
                channel = channel ?? ctx.Channel;

                IEnumerable <DiscordWebhook> whs = await channel.GetWebhooksAsync();

                DiscordWebhook wh = whs.SingleOrDefault(w => w.Name.ToLowerInvariant() == name.ToLowerInvariant());

                if (wh is null)
                {
                    throw new CommandFailedException($"Webhook with name {Formatter.InlineCode(name)} does not exist!");
                }

                await wh.DeleteAsync();

                await this.InformAsync(ctx, $"Successfully deleted webhook {Formatter.InlineCode(wh.Name)}!", important : false);
            }