nyxx-discord / nyxx_commands

A framework for easily creating slash commands and text commands for Discord using the nyxx library.
Apache License 2.0
13 stars 5 forks source link

Command null assertion on prefix field, which can be null #130

Closed jr1221 closed 11 months ago

jr1221 commented 12 months ago

Describe the bug The prefix field of the CommandsPlugin is made null to indicate message commands should be disabled. However when passed in as null, a non-null assertion is thrown on the variable.

To Reproduce Steps to reproduce the behavior:

CommandsPlugin commands = CommandsPlugin(
      prefix: null
      ...

Throws on slash command recieve.

[2023-09-20 11:18:27.566508] [SHOUT] [IgnoreExceptions] Unhandled exception was thrown
Error: Null check operator used on a null value
Stack trace:
#0      EventManager.processMessageCreateEvent (package:nyxx_commands/src/event_manager.dart:144:43)
#1      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#2      CastStreamSubscription._onData (dart:_internal/async_cast.dart:85:11)
#3      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#4      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#5      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#6      _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#7      _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
#8      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#9      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#10     CastStreamSubscription._onData (dart:_internal/async_cast.dart:85:11)
#11     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#12     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#13     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#14     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#15     _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
#16     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#17     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#18     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#19     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#20     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#21     _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#22     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#23     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#24     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#25     _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#26     _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#27     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#28     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#29     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#30     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:123:13)
#31     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:190:5)

Expected behavior No error thrown, message prefix commands disabled.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Introduced in the 6.0.0 rewrite.