discord-net/Discord.Net

Weird bot behaviour

sillyMirai opened this issue · 0 comments

Check The Docs

  • I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • I double checked that I have the required intents.

Description

Yesterday I've noticed my bot started throwing this exception when I start it:

System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at System.UInt64.Parse(String s, NumberStyles style, IFormatProvider provider)

The most weird part is, the problem is specific to one of my bots. If I start my code with other bot's token, the problem do not appear at all. I also tried starting it on 2 different pc's and the results are the same

image

Version

3.13.0

Working Version

No response

Logs

This is what I see when I launch my bot (the error repeats itself way more times but I cut it because of character limit):

18:15:00 Discord     Discord.Net v3.13.0 (API v10)
18:15:01 Shard #1    Connecting
18:15:01 Shard #0    Connecting
18:15:02 Shard #1    Connected
18:15:02 Shard #1    Left
18:15:02 Shard #1    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at System.UInt64.Parse(String s, NumberStyles style, IFormatProvider provider)
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:02 Shard #1    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at System.UInt64.Parse(String s, NumberStyles style, IFormatProvider provider)
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:08 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:08 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:08 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:08 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:08 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:08 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:09 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:09 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:09 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:09 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:09 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
Executed a slash command: help
18:15:10 Shard #0    A SlashCommandExecuted handler has thrown an unhandled exception.:
Discord.Net.HttpException: The server responded with error 10062: Unknown interaction
   at Discord.Net.Queue.RequestBucket.SendAsync(RestRequest request)
   at Discord.Net.Queue.RequestQueue.SendAsync(RestRequest request)
   at Discord.API.DiscordRestApiClient.SendInternalAsync(String method, String endpoint, RestRequest request)
   at Discord.WebSocket.SocketCommandBase.RespondAsync(String text, Embed[] embeds, Boolean isTTS, Boolean ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options)
   at DiscordGPTBot.Program.Help(SocketSlashCommand command) in C:\Users\lolo\source\repos\mirai420\ConsoleApp1\ConsoleApp1\Program.cs:line 1755
   at DiscordGPTBot.Program.ExecuteCommand(SocketSlashCommand slashCommand) in C:\Users\lolo\source\repos\mirai420\ConsoleApp1\ConsoleApp1\Program.cs:line 917
   at DiscordGPTBot.Program.HandleCommandAsync(SocketSlashCommand slashCommand) in C:\Users\lolo\source\repos\mirai420\ConsoleApp1\ConsoleApp1\Program.cs:line 820
   at Discord.EventExtensions.InvokeAsync[T](AsyncEvent`1 eventHandler, T arg)
   at Discord.EventExtensions.InvokeAsync[T](AsyncEvent`1 eventHandler, T arg)
   at Discord.WebSocket.DiscordSocketClient.TimeoutWrap(String name, Func`1 action)
18:15:10 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:10 Shard #0    Serializer Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's')
   at Discord.Net.Converters.UInt64Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
18:15:12 Shard #0    Ready
Bot is in 2106 servers
18:15:16 Shard #1    Ready

Sample

using Discord;
using Discord.WebSocket;

namespace DiscordGPTBot
{ 

    class Program
    {
        private DiscordSocketClient _client = new DiscordSocketClient();

        private const string token = "token";

        static void Main(string[] args) => new Program().RunBotAsync().GetAwaiter().GetResult();

        private async Task RunBotAsync()
        {
            _client.Log += LogAsync;

            //Literally just starting the bot causes it to spam errors
            await _client.LoginAsync(TokenType.Bot, token);
            await _client.StartAsync();

            await Task.Delay(-1);
        }

        private Task LogAsync(LogMessage log)
        {
            Console.WriteLine(log);
            return Task.CompletedTask;
        }
    }      
}

Packages

    <PackageReference Include="Discord.Net" Version="3.13.0" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />

Environment

Windows 10 Pro 22H2 (OS build 19045.3803)
x64
.net 6.0