Every time i try to call SendMessage, it puts out this error
Failed to call hook 'OnPlayerChat' on plugin 'DiscordChat v0.0.1' (NullReferenceException: Object reference not set to an instance of an object) at Oxide.Plugins.DiscordChat.OnPlayerChat (BasePlayer player, System.String message) [0x00000] in <c6002dba396d40f0a92b2690375d172e>:0 at Oxide.Plugins.DiscordChat.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00032] in <c6002dba396d40f0a92b2690375d172e>:0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <31122a27a2414cd799150f8677cf39d4>:0 at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <c2afd8354b8b4f3ca451cf5a1aa111c3>:0 at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <c2afd8354b8b4f3ca451cf5a1aa111c3>:0
The code in my plugin is this.
[PluginReference] private Plugin Discord;
private static DiscordChat ins;
private void OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel)
{
ins.Discord?.Call("SendMessage", message);
}
Whats causing this error?
Object reference not set to an instance of an object
that null ref dont happen my side with you exact code ... is your token and channel id correct