Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in PluginContext.get_CancellationToken() on dev branch #42

Closed
maxisoft opened this issue Oct 29, 2023 · 0 comments · Fixed by #41
Closed

NullReferenceException in PluginContext.get_CancellationToken() on dev branch #42

maxisoft opened this issue Oct 29, 2023 · 0 comments · Fixed by #41
Assignees
Labels
bug Something isn't working

Comments

@maxisoft
Copy link
Owner

Describe the bug When I try to use the FreeGamesCommand on my bot, I get a NullReferenceException in PluginContext.get_CancellationToken(). This prevents me from saving the options and executing the command.

To Reproduce Steps to reproduce the behavior:

  1. Clone the dev branch of https://github.com/maxisoft/ASFFreeGames
  2. Build and run the plugin with ASF
  3. Send a command like Freegames set VERBOSE
  4. See error

Expected behavior I expected the command to save the options and execute without any errors.

Here is a copy of the error log:

2023-10-29 18:25:24|dotnet-2326|ERROR|ASF|OnBotCommand() System.NullReferenceException: Object reference not set to an instance of an object.
   at Maxisoft.ASF.PluginContext.get_CancellationToken()
   at ASFFreeGames.Commands.FreeGamesCommand.SaveOptions()
   at ASFFreeGames.Commands.FreeGamesCommand.HandleSetCommand(Bot bot, String[] args)
   at ASFFreeGames.Commands.FreeGamesCommand.Execute(Bot bot, String message, String[] args, UInt64 steamID, CancellationToken cancellationToken)
   at ASFFreeGames.Commands.CommandDispatcher.Execute(Bot bot, String message, String[] args, UInt64 steamID, CancellationToken cancellationToken)
   at Maxisoft.ASF.ASFFreeGamesPlugin.OnBotCommand(Bot bot, EAccess access, String message, String[] args, UInt64 steamID)
   at ArchiSteamFarm.Core.Utilities.InParallelT
   at ArchiSteamFarm.Plugins.PluginsCore.OnBotCommand(Bot bot, EAccess access, String message, String[] args, UInt64 steamID)

Desktop (please complete the following information):

OS: Windows 10
ASF: 5.4.12.5
Plugin build with 4e97524

@maxisoft maxisoft self-assigned this Oct 29, 2023
@maxisoft maxisoft added the bug Something isn't working label Oct 29, 2023
@maxisoft maxisoft linked a pull request Oct 29, 2023 that will close this issue
@maxisoft maxisoft pinned this issue Oct 29, 2023
maxisoft added a commit that referenced this issue Oct 31, 2023
This commit adds some checks and methods to ensure that the PluginContext is valid and initialized before using it. It also adds a cancellationToken parameter to some of the methods that use the PluginContext cancellation token. This should resolve the issue #42 (#42) that was reported.
@maxisoft maxisoft unpinned this issue Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant