❔ Error when starting bot

hello
24 Replies
MasterDroid
MasterDroid2y ago
S C:\Users\pokey\OneDrive\Pulpit\Uno Bot C#> dotnet run
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at DiscordBotsList.Api.DiscordBotListApi.GetBotAsync[T](UInt64 id) at DiscordBotsList.Api.AuthDiscordBotListApi.GetMeAsync() at UNO.Program.MainAsync() in C:\Users\pokey\OneDrive\Pulpit\Uno Bot C#\Program.cs:line 40 at UNO.Program.Main(String[] args) in C:\Users\pokey\OneDrive\Pulpit\Uno Bot C#\Program.cs:line 14 this is the error I encounter when Running the code can someone help me? This is the entire code however I'm not sure what's causing it:
Angius
Angius2y ago
Well, something was null On like 40 most likely
MasterDroid
MasterDroid2y ago
this is line 40
_dblApi = await discordBotList.GetMeAsync();
_dblApi = await discordBotList.GetMeAsync();
however im confused
Angius
Angius2y ago
discordBotList is null, then
MasterDroid
MasterDroid2y ago
var discordBotList =
new AuthDiscordBotListApi(Config.BOT_CLIENT_ID,
System
.Environment
.GetEnvironmentVariable("UnoDblToken"));
var discordBotList =
new AuthDiscordBotListApi(Config.BOT_CLIENT_ID,
System
.Environment
.GetEnvironmentVariable("UnoDblToken"));
this is the code for discordBotList, would I put the bot token here or? cause im confused if u check the code I sent above
Angius
Angius2y ago
Idk What do the docs of this particular library say?
MasterDroid
MasterDroid2y ago
Im not sure I wasnt able to find anywhere the issue and its a discord bot so yea
Angius
Angius2y ago
Well, System.Environment.GetEnvironmentVariable("UnoDblToken") does attempt to get the token from env variables
MasterDroid
MasterDroid2y ago
hmm
MasterDroid
MasterDroid2y ago
MasterDroid
MasterDroid2y ago
Just not sure tbh where it could be coming from
Angius
Angius2y ago
From... environmental variables
MasterDroid
MasterDroid2y ago
so where do I find the variables?
Angius
Angius2y ago
You can pass them in the launch config Or you can set them globally in your system Or you can set them temporarily for the current terminal session
MasterDroid
MasterDroid2y ago
namespace UNO
{
public static class Config
{
public static bool USE_TOP_GG_API = true;
public static bool IS_DEBUG = false;
public static ulong DEBUG_GUILD_ID = ;
public static ulong BOT_CLIENT_ID = ;
public static int DISCORD_SHARD_COUNT = 20;
}
}
namespace UNO
{
public static class Config
{
public static bool USE_TOP_GG_API = true;
public static bool IS_DEBUG = false;
public static ulong DEBUG_GUILD_ID = ;
public static ulong BOT_CLIENT_ID = ;
public static int DISCORD_SHARD_COUNT = 20;
}
}
this is all that my config has, so idk whats easier
Angius
Angius2y ago
? What does this have to do with the token
MasterDroid
MasterDroid2y ago
Obviously to start a bot you need to use the discord bot token no?
Angius
Angius2y ago
Or with environmental variables Yeah? And this code takes said token from an environmental variable
MasterDroid
MasterDroid2y ago
ok How can Input the token manually or setup the env variable
Angius
Angius2y ago
If you're asking whether you can place this token somewhere else, then sure
Angius
Angius2y ago
Stack Overflow
How do I set specific environment variables when debugging in Visua...
On a class library project, I set the "Start Action" on the Debug tab of the project properties to "Start external program" (NUnit in this case). I want to set an environment variable in the enviro...
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts