Hi everyone.
Since plurial days, i'll send hooks with somes bots, but System.NullReferenceException is catched.
There's the used method:
public static async Task SendHook(DiscordChannel c, HookInfo h, string Message)
{
try
{
DiscordWebhook? Hook = null;
var Hooks = await c.GetWebhooksAsync();
foreach (DiscordWebhook H in Hooks)
if (H.Name == "OzBot") Hook = H;
if (Hook is null) Hook = await c.CreateWebhookAsync("OzBot");
DiscordWebhookBuilder b = new DiscordWebhookBuilder()
{
AvatarUrl = h.AvatarURL,
Username = h.NickName,
Content = Message
};
await Hook.ExecuteAsync(b);
} catch (Exception ex) { await Logs.CatchedEventException(c, ex, $"Messaging.SendHook"); }
}
For information, HookInfo is stocking AvatarURL, NickName and who is allowed to use this hook info, I'll just use AvatarURL and NickName for sending.
The exception is catched at await Hook.ExecuteAsync(b); and it were work before.
StackTrace :
ERREUR :
System.NullReferenceException
Object reference not set to an instance of an object.
STACKTRACE:
at DSharpPlus.Net.RestClient.GetBucket(RestRequestMethod method, String route, Object route_params, String& url)
at DSharpPlus.Net.DiscordApiClient.ExecuteWebhookAsync(UInt64 webhook_id, String webhook_token, DiscordWebhookBuilder builder)
at Barmaid.Libs.Messaging.SendHook(DiscordChannel c, HookInfo h, String Message) in F:\OneDrive\Documents\Sources\Barmaid\Barmaid3\Libs\Messaging.cs:line 110
Anyone having idea ?
PS : Lib is up to date.


