question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Can't use Bearer token Login after v3.1.0

See original GitHub issue

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

After upgrading from v3.1.0. I’ve started receiving Exception when using the Bearer token to Login.

Version

3.7.2

Working Version

3.1.0

Logs

Gateway: System.Exception: Processing READY failed
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Discord.WebSocket.DiscordSocketClient.ProcessMessageAsync(GatewayOpCode opCode, Nullable`1 seq, String type, Object payload)
   --- End of inner exception stack trace ---
   at Discord.ConnectionManager.WaitAsync()
   at Discord.WebSocket.DiscordSocketClient.OnConnectingAsync()
   at Discord.ConnectionManager.ConnectAsync(CancellationTokenSource reconnectCancelToken)
   at Discord.ConnectionManager.<>c__DisplayClass29_0.<<StartAsync>b__0>d.MoveNext()

Sample

using Discord;
using Discord.Commands;
using Discord.WebSocket;

internal class Startup
{
	private readonly String dateFormat = @"yyyy-MM-dd";
	private readonly String timeFormat = @"hh:mm:ss.fffffff";

	private readonly String _logDirectory;
	private readonly String _logFile;

	private String[] args;

	public Startup(String[] args)
	{
		this.args = args;

		_logDirectory = Path.Combine(AppContext.BaseDirectory, "logs");
		_logFile = Path.Combine(_logDirectory, $"{DateTime.UtcNow.ToString(dateFormat)}.txt");
	}

	internal async Task RunAsync()
	{
		var discordSocketClient = new DiscordSocketClient(new DiscordSocketConfig
		{
			LogLevel = LogSeverity.Verbose,
			MessageCacheSize = 1000
		});

		var commandService = new CommandService(new CommandServiceConfig
		{
			LogLevel = LogSeverity.Verbose,
			DefaultRunMode = RunMode.Async
		});

		discordSocketClient.MessageReceived += OnMessageReceivedAsync;

		discordSocketClient.Log += OnLogAsync;
		commandService.Log += OnLogAsync;

		await discordSocketClient.LoginAsync(TokenType.Bearer, @"XXX");
		await discordSocketClient.StartAsync();

		// Keep the application alive
		await Task.Delay(-1);
	}

	private Task OnLogAsync(LogMessage msg)
	{
		if (!Directory.Exists(_logDirectory))     // Create the log directory if it doesn't exist
			Directory.CreateDirectory(_logDirectory);
		if (!File.Exists(_logFile))               // Create today's log file if it doesn't exist
			File.Create(_logFile).Dispose();

		string logText = $"{DateTime.UtcNow.ToString(timeFormat)} [{msg.Severity}] {msg.Source}: {msg.Exception?.ToString() ?? msg.Message}";
		File.AppendAllText(_logFile, logText + "\n");     // Write the log text to a file

		return Console.Out.WriteLineAsync(logText);       // Write the log text to the console
	}

	private async Task OnMessageReceivedAsync(SocketMessage s)
	{

	}
}

Packages

Discord.Net V3.7.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
csmircommented, Jul 29, 2022

To the above, bearer does not imply self-botting, this is an irrelevant comment.

Could you go further into your use case, so I can attempt to repro?

1reaction
SylveonDekocommented, Jul 10, 2022

We dont support selfbots.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error 403 even with valid endpoint and bearer token
I am using /2/tweets endpoint and I have valid bearer token as well but I kept getting 403 error. This is also happening...
Read more >
403 forbidden attempting to use user access token
Hi all, I'm trying to call the V2 API using the OAuth 2.0 user access tokens, but I keep getting 403 forbidden errors....
Read more >
Bug - Authentication fails with Invalid Token
Hello, You should not clear this token as it is used by anonymous login to access the account you were previously signed in...
Read more >
NPM ERR Code E401: Unable to authenticate, need
Open your . npmrc with your auth tokens in. Go to your Azure repo and click your profile and then personal access tokens....
Read more >
Etsy: After requesting an authorisation code, I cannot log in ...
I have gained an access token once before, but it was so long ago. I don't know if I'm logging in differently from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found