[Bug]: Can't use Bearer token Login after v3.1.0
See original GitHub issueCheck 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:
- Created a year ago
- Comments:6 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
We dont support selfbots.