diff --git a/nyxx.commander/pubspec.yaml b/nyxx.commander/pubspec.yaml index edc4e30d..29d7f4e5 100644 --- a/nyxx.commander/pubspec.yaml +++ b/nyxx.commander/pubspec.yaml @@ -11,5 +11,5 @@ environment: dependencies: http: "^0.13.0" - logging: "^1.0.0" + logging: "^1.0.1" nyxx: "^1.1.0-dev.5" diff --git a/nyxx.interactions/pubspec.yaml b/nyxx.interactions/pubspec.yaml index e27fa69d..1a9c12c5 100644 --- a/nyxx.interactions/pubspec.yaml +++ b/nyxx.interactions/pubspec.yaml @@ -10,5 +10,5 @@ environment: sdk: '>=2.12.0 <2.13.0' dependencies: - logging: "^1.0.0" + logging: "^1.0.1" nyxx: "1.1.0-dev.4" diff --git a/nyxx/lib/src/Nyxx.dart b/nyxx/lib/src/Nyxx.dart index 249c3b42..bb4f6239 100644 --- a/nyxx/lib/src/Nyxx.dart +++ b/nyxx/lib/src/Nyxx.dart @@ -183,17 +183,26 @@ class Nyxx implements Disposable { /// Gets an bot invite link with zero permissions String get inviteLink => app.getInviteUrl(); + /// Can be used to edit options after client initialised. Used by Nyxx.interactions to enable raw events + ClientOptions get options => this._options; + /// Returns handler for all available REST API action. IHttpEndpoints get httpEndpoints => this._httpEndpoints; /// Creates and logs in a new client. If [ignoreExceptions] is true (by default is) /// isolate will ignore all exceptions and continue to work. - Nyxx(this._token, this.intents, {ClientOptions? options, CacheOptions? cacheOptions, bool ignoreExceptions = true, bool useDefaultLogger = true, Level? defaultLoggerLogLevel}) { - if(useDefaultLogger) { + Nyxx(this._token, this.intents, + {ClientOptions? options, + CacheOptions? cacheOptions, + bool ignoreExceptions = true, + bool useDefaultLogger = true, + Level? defaultLoggerLogLevel}) { + if (useDefaultLogger) { Logger.root.level = defaultLoggerLogLevel ?? Level.ALL; Logger.root.onRecord.listen((LogRecord rec) { - print("[${rec.time}] [${rec.level.name}] [${rec.loggerName}] ${rec.message}"); + print( + "[${rec.time}] [${rec.level.name}] [${rec.loggerName}] ${rec.message}"); }); } @@ -203,7 +212,7 @@ class Nyxx implements Disposable { throw MissingTokenError(); } - if(!Platform.isWindows) { + if (!Platform.isWindows) { ProcessSignal.sigterm.watch().forEach((event) async { await this.dispose(); }); @@ -234,9 +243,12 @@ class Nyxx implements Disposable { this._httpEndpoints = _HttpEndpoints._new(this); this._events = _EventController(this); - this.onSelfMention = this.onMessageReceived.where((event) => event.message.mentions.contains(this.self)); - this.onDmReceived = this.onMessageReceived.where((event) => event.message is DMMessage); - + this.onSelfMention = this + .onMessageReceived + .where((event) => event.message.mentions.any((element) => element.id == this.self.id)); + this.onDmReceived = + this.onMessageReceived.where((event) => event.message is DMMessage); + this._ws = _ConnectionManager(this); } @@ -246,28 +258,27 @@ class Nyxx implements Disposable { /// [DateTime] when client was started DateTime get startTime => _startTime; - /// Returns guild even if the user is not in the guild. /// This endpoint is only for Public guilds if bot is not int the guild. Future fetchGuildPreview(Snowflake guildId) async => this._httpEndpoints.fetchGuildPreview(guildId); /// Returns guild with given [guildId] Future fetchGuild(Snowflake guildId) => - this._httpEndpoints.fetchGuild(guildId); + this._httpEndpoints.fetchGuild(guildId); /// Returns channel with specified id. /// ``` /// var channel = await client.getChannel(Snowflake("473853847115137024")); /// ``` Future fetchChannel(Snowflake channelId) => - this._httpEndpoints.fetchChannel(channelId); + this._httpEndpoints.fetchChannel(channelId); /// Get user instance with specified id. /// ``` /// var user = client.getUser(Snowflake("302359032612651009")); /// `` Future fetchUser(Snowflake userId) => - this._httpEndpoints.fetchUser(userId); + this._httpEndpoints.fetchUser(userId); /// Gets a webhook by its id and/or token. /// If token is supplied authentication is not needed. @@ -281,7 +292,7 @@ class Nyxx implements Disposable { /// var inv = client.getInvite("YMgffU8"); /// ``` Future getInvite(String code) => - this._httpEndpoints.fetchInvite(code); + this._httpEndpoints.fetchInvite(code); /// Returns number of shards int get shards => this.shardManager._shards.length; @@ -308,7 +319,7 @@ class Nyxx implements Disposable { Future dispose() async { this._logger.info("Disposing and closing bot..."); - if(this._options.shutdownHook != null) { + if (this._options.shutdownHook != null) { await this._options.shutdownHook!(this); } diff --git a/nyxx/pubspec.yaml b/nyxx/pubspec.yaml index a2397577..f68ac668 100644 --- a/nyxx/pubspec.yaml +++ b/nyxx/pubspec.yaml @@ -1,5 +1,5 @@ name: nyxx -version: 1.1.0-dev.4 +version: 1.1.0-dev.5 description: A Discord library for Dart. homepage: https://github.com/l7ssha/nyxx repository: https://github.com/l7ssha/nyxx @@ -11,7 +11,7 @@ environment: dependencies: http: "^0.13.0" - logging: "^1.0.0" + logging: "^1.0.1" path: "^1.8.0" dev_dependencies: