Changelog, license update, Implement stage channels, implements new permissions

Remove unnecessary stuff from tests and analyzer options, remove travis config file
This commit is contained in:
Szymon Uglis 2021-04-07 22:54:14 +02:00
parent e01a670a19
commit c71d310d6e
No known key found for this signature in database
GPG key ID: 112376C5BEE91FE2
26 changed files with 156 additions and 122 deletions

View file

@ -1,20 +0,0 @@
language: dart
dart:
# - dev
- stable
script: ./travis.sh
after_success:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh success $WEBHOOK_URL
after_failure:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh failure $WEBHOOK_URL
cache:
directories:
- $HOME/.pub-cache

View file

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 2018, Szymon Uglis, Zach Vacura Copyright (C) 2018-2021, Szymon Uglis, Zach Vacura and contributors
Preamble Preamble

View file

@ -1,7 +1,11 @@
## 1.1.0 ## 2.0.0-rc.2
_xx.xx.2020_ _07.04.2020_
> **Release Candidate 2 for stable version. Requires dart sdk 2.12**
- Support for aliases for Commander (580e55c) - Support for aliases for Commander (580e55c)
- Fix command aliases (17187c5) @WasserEsser
- Fix command recognition in Commander (7fff136) @WasserEsser
## 1.0.1 ## 1.0.1
_03.09.2020_ _03.09.2020_

View file

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 2018, Szymon Uglis, Zach Vacura Copyright (C) 2018-2021, Szymon Uglis, Zach Vacura and contributors
Preamble Preamble

View file

@ -1,10 +1,6 @@
analyzer: analyzer:
enable-experiment:
- non-nullable
strong-mode: strong-mode:
implicit-casts: false implicit-casts: false
exclude:
- example/**
linter: linter:
rules: rules:
- avoid_empty_else - avoid_empty_else

View file

@ -1,5 +1,5 @@
name: nyxx_commander name: nyxx_commander
version: 2.0.0-rc.1 version: 2.0.0-rc.2
description: A Discord library for Dart. description: A Discord library for Dart.
homepage: https://github.com/l7ssha/nyxx homepage: https://github.com/l7ssha/nyxx
repository: https://github.com/l7ssha/nyxx repository: https://github.com/l7ssha/nyxx
@ -12,4 +12,4 @@ environment:
dependencies: dependencies:
http: "^0.13.1" http: "^0.13.1"
logging: "^1.0.1" logging: "^1.0.1"
nyxx: "^2.0.0-rc.1" nyxx: "2.0.0-rc.1"

View file

@ -1,3 +1,11 @@
## 2.0.0-rc.2
_07.04.2020_
> **Release Candidate 2 for stable version. Requires dart sdk 2.12**
- Added compatifility for nyxx 2.0.0-rc2
- Implemented mutual guilds extension method (9a8bb35)
## 1.0.0 ## 1.0.0
_24.08.2020_ _24.08.2020_
@ -5,9 +13,9 @@ _24.08.2020_
> **`1.0.0` drops support for browser. Nyxx will now run only on VM** > **`1.0.0` drops support for browser. Nyxx will now run only on VM**
* New emoji module for fetching available emoji info - New emoji module for fetching available emoji info
* Pagination module for created paginated messages - Pagination module for created paginated messages
* Scheduler module for invoking repeatable actions - Scheduler module for invoking repeatable actions
* Additional general utils - Additional general utils
* Message resolver module for resolving raw message content into human readable form - Message resolver module for resolving raw message content into human readable form
* Attachment extensions for vm - Attachment extensions for vm

View file

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 2018, Szymon Uglis, Zach Vacura Copyright (C) 2018-2021, Szymon Uglis, Zach Vacura and contributors
Preamble Preamble

View file

@ -1,10 +1,6 @@
analyzer: analyzer:
enable-experiment:
- non-nullable
strong-mode: strong-mode:
implicit-casts: false implicit-casts: false
exclude:
- example/**
linter: linter:
rules: rules:
- avoid_empty_else - avoid_empty_else

View file

@ -1,5 +1,5 @@
name: nyxx_extensions name: nyxx_extensions
version: 2.0.0-rc.1 version: 2.0.0-rc.2
description: Extensions for Nyxx library description: Extensions for Nyxx library
homepage: https://github.com/l7ssha/nyxx homepage: https://github.com/l7ssha/nyxx
repository: https://github.com/l7ssha/nyxx repository: https://github.com/l7ssha/nyxx
@ -11,4 +11,4 @@ environment:
dependencies: dependencies:
http: "^0.13.1" http: "^0.13.1"
nyxx: "^2.0.0-rc.1" nyxx: "2.0.0-rc.2"

View file

@ -1,3 +1,12 @@
## 2.0.0-rc.2
_07.04.2020_
> **Release Candidate 2 for stable version. Requires dart sdk 2.12**
- Interactions (Slash command) initial implementation (3128388) @HarryET
- Implemented Commander like interface (8fae519)
- Added `subCommand` property to InteractionEvent to ease out recognizing subcommands (5b30b29)
## 1.1-dev.1 ## 1.1-dev.1
- Initial version - Initial version @HarryET

View file

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 2018, Szymon Uglis, Zach Vacura Copyright (C) 2018-2021, Szymon Uglis, Zach Vacura and contributors
Preamble Preamble

View file

@ -1,10 +1,6 @@
analyzer: analyzer:
enable-experiment:
- non-nullable
strong-mode: strong-mode:
implicit-casts: false implicit-casts: false
exclude:
- example/**
linter: linter:
rules: rules:
- avoid_empty_else - avoid_empty_else

View file

@ -1,5 +1,5 @@
name: nyxx_interactions name: nyxx_interactions
version: 2.0.0-rc.1 version: 2.0.0-rc.2
description: Interactions for Nyxx library description: Interactions for Nyxx library
homepage: https://github.com/l7ssha/nyxx homepage: https://github.com/l7ssha/nyxx
repository: https://github.com/l7ssha/nyxx repository: https://github.com/l7ssha/nyxx
@ -11,4 +11,4 @@ environment:
dependencies: dependencies:
logging: "^1.0.1" logging: "^1.0.1"
nyxx: "2.0.0-rc.1" nyxx: "2.0.0-rc.2"

View file

@ -1,5 +1,7 @@
## 1.1.0 ## 2.0.0-rc.2
_xx.xx.2020_ _07.04.2020_
> **Release Candidate 2 for stable version. Requires dart sdk 2.12**
- Removed `w_transport` and replaced it with `http` package for http module and websockets from `dart:io` (18d0163, 5644937, 9b863a4, 06482f9) - Removed `w_transport` and replaced it with `http` package for http module and websockets from `dart:io` (18d0163, 5644937, 9b863a4, 06482f9)
- Fix replacing embed field. Order of fields is now preserved (f667c2a) - Fix replacing embed field. Order of fields is now preserved (f667c2a)
@ -8,7 +10,17 @@ _xx.xx.2020_
- Expose raw api call api (f297cc0) - Expose raw api call api (f297cc0)
- Add support for gateway transport compression (fd090dd) - Add support for gateway transport compression (fd090dd)
- Moved to v8 on REST and gateway (423173d) - Moved to v8 on REST and gateway (423173d)
- Intents value is now required and added to Nyxx constructor (2b3e002) - Intents value is now required and added to Nyxx constructor (2b3e002)
- Added ability to configure cache (163eca9)
- Implemented stickers (16f2b79)
- Implemented inline replies (e412ec9)
- Added raw shard event stream (627f4a0)
- Fix message reaction events were not triggered when cache misses message (fedbd88)
- New utils related to slash commands (8e46b71) @HarryET
- Fixed bug where message with only files cannot be sent (1092624)
- Fixed setPresence method (fbb9c39) @One-Nub
- Added missing delete() method to IChannel (131ecc0)
- Added support for stage channels
## 1.0.2 ## 1.0.2
_08.09.2020_ _08.09.2020_

View file

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 2018, Szymon Uglis, Zach Vacura Copyright (C) 2018-2021, Szymon Uglis, Zach Vacura and contributors
Preamble Preamble

View file

@ -1,6 +1,4 @@
analyzer: analyzer:
enable-experiment:
- non-nullable
strong-mode: strong-mode:
implicit-casts: false implicit-casts: false
linter: linter:

View file

@ -26,6 +26,8 @@ abstract class IChannel extends SnowflakeEntity implements Disposable {
return TextGuildChannel._new(client, raw, guildId); return TextGuildChannel._new(client, raw, guildId);
case 2: case 2:
return VoiceGuildChannel._new(client, raw, guildId); return VoiceGuildChannel._new(client, raw, guildId);
case 13:
return StageVoiceGuildChannel._new(client, raw, guildId);
case 4: case 4:
return CategoryGuildChannel._new(client, raw, guildId); return CategoryGuildChannel._new(client, raw, guildId);
default: default:

View file

@ -1,5 +1,6 @@
part of nyxx; part of nyxx;
/// Represents channel within [Guild]. Shares logic for both [TextGuildChannel] and [VoiceGuildChannel].
abstract class GuildChannel extends IChannel { abstract class GuildChannel extends IChannel {
/// The channel"s name. /// The channel"s name.
late final String name; late final String name;

View file

@ -46,3 +46,7 @@ class VoiceGuildChannel extends GuildChannel {
} }
} }
} }
class StageVoiceGuildChannel extends VoiceGuildChannel {
StageVoiceGuildChannel._new(INyxx client, Map<String, dynamic> raw, [Snowflake? guildId]) : super._new(client, raw, guildId);
}

View file

@ -98,6 +98,12 @@ class Permissions implements Convertable<PermissionsBuilder> {
/// Allows for viewing guild insights /// Allows for viewing guild insights
late final bool viewGuildInsights; late final bool viewGuildInsights;
/// Allows members to use slash commands in text channels
late final bool useSlashCommands;
/// Allows for requesting to speak in stage channels
late final bool requestToSpeak;
/// Makes a [Permissions] object from a raw permission code. /// Makes a [Permissions] object from a raw permission code.
Permissions.fromInt(int permissions) { Permissions.fromInt(int permissions) {
_construct(permissions); _construct(permissions);
@ -109,6 +115,7 @@ class Permissions implements Convertable<PermissionsBuilder> {
} }
/// Permissions with max value /// Permissions with max value
@Deprecated("Needs to be updated")
Permissions.all() { Permissions.all() {
_construct(PermissionsConstants.allPermissions); _construct(PermissionsConstants.allPermissions);
} }
@ -121,48 +128,85 @@ class Permissions implements Convertable<PermissionsBuilder> {
void _construct(int permissions) { void _construct(int permissions) {
this.raw = permissions; this.raw = permissions;
this.createInstantInvite = PermissionsUtils.isApplied(permissions, PermissionsConstants.createInstantInvite); this.createInstantInvite = PermissionsUtils.isApplied(
this.kickMembers = PermissionsUtils.isApplied(permissions, PermissionsConstants.kickMembers); permissions, PermissionsConstants.createInstantInvite);
this.banMembers = PermissionsUtils.isApplied(permissions, PermissionsConstants.banMembers); this.kickMembers = PermissionsUtils.isApplied(
this.administrator = PermissionsUtils.isApplied(permissions, PermissionsConstants.administrator); permissions, PermissionsConstants.kickMembers);
this.manageChannels = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageChannels); this.banMembers = PermissionsUtils.isApplied(
this.manageGuild = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageGuild); permissions, PermissionsConstants.banMembers);
this.addReactions = PermissionsUtils.isApplied(permissions, PermissionsConstants.addReactions); this.administrator = PermissionsUtils.isApplied(
this.viewAuditLog = PermissionsUtils.isApplied(permissions, PermissionsConstants.viewAuditLog); permissions, PermissionsConstants.administrator);
this.viewChannel = PermissionsUtils.isApplied(permissions, PermissionsConstants.viewChannel); this.manageChannels = PermissionsUtils.isApplied(
this.sendMessages = PermissionsUtils.isApplied(permissions, PermissionsConstants.sendMessages); permissions, PermissionsConstants.manageChannels);
this.prioritySpeaker = PermissionsUtils.isApplied(permissions, PermissionsConstants.prioritySpeaker); this.manageGuild = PermissionsUtils.isApplied(
this.sendTtsMessages = PermissionsUtils.isApplied(permissions, PermissionsConstants.sendTtsMessages); permissions, PermissionsConstants.manageGuild);
this.manageMessages = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageMessages); this.addReactions = PermissionsUtils.isApplied(
this.embedLinks = PermissionsUtils.isApplied(permissions, PermissionsConstants.embedLinks); permissions, PermissionsConstants.addReactions);
this.attachFiles = PermissionsUtils.isApplied(permissions, PermissionsConstants.attachFiles); this.viewAuditLog = PermissionsUtils.isApplied(
this.readMessageHistory = PermissionsUtils.isApplied(permissions, PermissionsConstants.readMessageHistory); permissions, PermissionsConstants.viewAuditLog);
this.mentionEveryone = PermissionsUtils.isApplied(permissions, PermissionsConstants.mentionEveryone); this.viewChannel = PermissionsUtils.isApplied(
this.useExternalEmojis = PermissionsUtils.isApplied(permissions, PermissionsConstants.externalEmojis); permissions, PermissionsConstants.viewChannel);
this.connect = PermissionsUtils.isApplied(permissions, PermissionsConstants.connect); this.sendMessages = PermissionsUtils.isApplied(
this.speak = PermissionsUtils.isApplied(permissions, PermissionsConstants.speak); permissions, PermissionsConstants.sendMessages);
this.muteMembers = PermissionsUtils.isApplied(permissions, PermissionsConstants.muteMembers); this.prioritySpeaker = PermissionsUtils.isApplied(
this.deafenMembers = PermissionsUtils.isApplied(permissions, PermissionsConstants.deafenMembers); permissions, PermissionsConstants.prioritySpeaker);
this.moveMembers = PermissionsUtils.isApplied(permissions, PermissionsConstants.moveMembers); this.sendTtsMessages = PermissionsUtils.isApplied(
this.useVad = PermissionsUtils.isApplied(permissions, PermissionsConstants.useVad); permissions, PermissionsConstants.sendTtsMessages);
this.changeNickname = PermissionsUtils.isApplied(permissions, PermissionsConstants.changeNickname); this.manageMessages = PermissionsUtils.isApplied(
this.manageNicknames = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageNicknames); permissions, PermissionsConstants.manageMessages);
this.manageRoles = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageRolesOrPermissions); this.embedLinks = PermissionsUtils.isApplied(
this.manageWebhooks = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageWebhooks); permissions, PermissionsConstants.embedLinks);
this.attachFiles = PermissionsUtils.isApplied(
permissions, PermissionsConstants.attachFiles);
this.readMessageHistory = PermissionsUtils.isApplied(
permissions, PermissionsConstants.readMessageHistory);
this.mentionEveryone = PermissionsUtils.isApplied(
permissions, PermissionsConstants.mentionEveryone);
this.useExternalEmojis = PermissionsUtils.isApplied(
permissions, PermissionsConstants.externalEmojis);
this.connect =
PermissionsUtils.isApplied(permissions, PermissionsConstants.connect);
this.speak =
PermissionsUtils.isApplied(permissions, PermissionsConstants.speak);
this.muteMembers = PermissionsUtils.isApplied(
permissions, PermissionsConstants.muteMembers);
this.deafenMembers = PermissionsUtils.isApplied(
permissions, PermissionsConstants.deafenMembers);
this.moveMembers = PermissionsUtils.isApplied(
permissions, PermissionsConstants.moveMembers);
this.useVad =
PermissionsUtils.isApplied(permissions, PermissionsConstants.useVad);
this.changeNickname = PermissionsUtils.isApplied(
permissions, PermissionsConstants.changeNickname);
this.manageNicknames = PermissionsUtils.isApplied(
permissions, PermissionsConstants.manageNicknames);
this.manageRoles = PermissionsUtils.isApplied(
permissions, PermissionsConstants.manageRolesOrPermissions);
this.manageWebhooks = PermissionsUtils.isApplied(
permissions, PermissionsConstants.manageWebhooks);
this.manageEmojis = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageEmojis); this.manageEmojis = PermissionsUtils.isApplied(
this.stream = PermissionsUtils.isApplied(permissions, PermissionsConstants.stream); permissions, PermissionsConstants.manageEmojis);
this.viewGuildInsights = PermissionsUtils.isApplied(permissions, PermissionsConstants.viewGuildInsights); this.stream =
PermissionsUtils.isApplied(permissions, PermissionsConstants.stream);
this.viewGuildInsights = PermissionsUtils.isApplied(
permissions, PermissionsConstants.viewGuildInsights);
this.useSlashCommands = PermissionsUtils.isApplied(
permissions, PermissionsConstants.useSlashCommands);
this.requestToSpeak = PermissionsUtils.isApplied(
permissions, PermissionsConstants.useSlashCommands);
} }
/// Returns true if this permissions has [permission] /// Returns true if this permissions has [permission]
bool hasPermission(int permission) => PermissionsUtils.isApplied(this.raw, permission); bool hasPermission(int permission) =>
PermissionsUtils.isApplied(this.raw, permission);
@override @override
int get hashCode => raw.hashCode; int get hashCode => raw.hashCode;
@override @override
bool operator ==(other) { bool operator ==(dynamic other) {
if (other is Permissions) return other.raw == this.raw; if (other is Permissions) return other.raw == this.raw;
if (other is int) return other == this.raw; if (other is int) return other == this.raw;

View file

@ -95,6 +95,13 @@ class PermissionsConstants {
/// Allows for viewing guild insights /// Allows for viewing guild insights
static const int viewGuildInsights = 1 << 19; static const int viewGuildInsights = 1 << 19;
/// Allows members to use slash commands in text channels
static const int useSlashCommands = 1 << 31;
/// Allows for requesting to speak in stage channels
static const int requestToSpeak = 1 << 32;
/// All of the permissions /// All of the permissions
@Deprecated("Needs to be updated")
static const int allPermissions = 0x7FFFFFFF; static const int allPermissions = 0x7FFFFFFF;
} }

View file

@ -33,6 +33,9 @@ class VoiceState {
/// Whether this user's camera is enabled /// Whether this user's camera is enabled
late final bool selfVideo; late final bool selfVideo;
/// The time at which the user requested to speak
late final DateTime? requestToSpeakTimeStamp;
VoiceState._new(INyxx client, Map<String, dynamic> raw) { VoiceState._new(INyxx client, Map<String, dynamic> raw) {
if (raw["channel_id"] != null) { if (raw["channel_id"] != null) {
this.channel = _ChannelCacheable(client, Snowflake(raw["channel_id"])); this.channel = _ChannelCacheable(client, Snowflake(raw["channel_id"]));
@ -47,6 +50,10 @@ class VoiceState {
this.selfStream = raw["self_stream"] as bool? ?? false; this.selfStream = raw["self_stream"] as bool? ?? false;
this.selfVideo = raw["self_video"] as bool; this.selfVideo = raw["self_video"] as bool;
this.requestToSpeakTimeStamp = raw["request_to_speak_timestamp"] == null
? null
: DateTime.parse(raw["request_to_speak_timestamp"] as String);
this.suppress = raw["suppress"] as bool; this.suppress = raw["suppress"] as bool;
this.sessionId = raw["session_id"] as String; this.sessionId = raw["session_id"] as String;

View file

@ -29,7 +29,7 @@ class Constants {
static const String baseUri = "/api/v8"; static const String baseUri = "/api/v8";
/// Version of Nyxx /// Version of Nyxx
static const String version = "2.0.0-rc.1"; static const String version = "2.0.0-rc.2";
/// Url to Nyxx repo /// Url to Nyxx repo
static const String repoUrl = "https://github.com/l7ssha/nyxx"; static const String repoUrl = "https://github.com/l7ssha/nyxx";

View file

@ -1,5 +1,5 @@
name: nyxx name: nyxx
version: 2.0.0-rc.1 version: 2.0.0-rc.2
description: A Discord library for Dart. description: A Discord library for Dart.
homepage: https://github.com/l7ssha/nyxx homepage: https://github.com/l7ssha/nyxx
repository: https://github.com/l7ssha/nyxx repository: https://github.com/l7ssha/nyxx

View file

@ -3,15 +3,6 @@ import "dart:io";
import "package:nyxx/nyxx.dart"; import "package:nyxx/nyxx.dart";
// Replacement for assert. Throws if [test] isn't true.
void test(bool test, [String? name]) {
if (!test) {
throw AssertionError();
} else {
print("Test ${name != null ? "[$name] " : ""}passed");
}
}
// Messages content on which we delete message // Messages content on which we delete message
const toDeleteMessageContent = [ const toDeleteMessageContent = [
"--trigger-test", "--trigger-test",
@ -23,14 +14,10 @@ const toDeleteMessageContent = [
"Converting successfull" "Converting successfull"
]; ];
// -------------------------------------------------------
EmbedBuilder createTestEmbed() => EmbedBuilder() EmbedBuilder createTestEmbed() => EmbedBuilder()
..title = "Test title" ..title = "Test title"
..addField(name: "Test field", content: "Test value", inline: true); ..addField(name: "Test field", content: "Test value", inline: true);
// -------------------------------------------------------
void main() { void main() {
final env = Platform.environment; final env = Platform.environment;
final bot = Nyxx(env["TEST_TOKEN"]!, GatewayIntents.guildMessages, ignoreExceptions: false); final bot = Nyxx(env["TEST_TOKEN"]!, GatewayIntents.guildMessages, ignoreExceptions: false);
@ -51,23 +38,6 @@ void main() {
await channel.sendMessage(content: "Testing new local build"); await channel.sendMessage(content: "Testing new local build");
} }
print("TESTING CLIENT INTERNALS");
final snowflakeA = Snowflake.fromDateTime(DateTime(2017));
final snowflakeB = Snowflake.fromDateTime(DateTime(2018));
test(snowflakeA.timestamp.isBefore(snowflakeB.timestamp), "Snowflake should be before timestamp");
test(snowflakeB.timestamp.isAfter(snowflakeA.timestamp), "Snowflake should be after timestamp");
test(snowflakeA.timestamp.isAtSameMomentAs(DateTime(2017)), "Snowflake should repsresent proper date");
test(snowflakeB.timestamp.isAtSameMomentAs(DateTime(2018)), "Snowflake should repsresent proper date");
// test(bot.channels.count > 0, "Channel count shouldn't be less or equal zero");
// test(bot.users.count > 0, "Users coutn count should n't be less or equal zero");
test(bot.shards == 1, "Shard count should be one");
test(bot.ready, "Bot should be ready");
//test(bot.inviteLink != null, "Bot's invite link shouldn't be null");
print("TESTING BASIC FUNCTIONALITY!"); print("TESTING BASIC FUNCTIONALITY!");
final m = await channel.sendMessage(content: "Message test."); final m = await channel.sendMessage(content: "Message test.");
await m.edit(content: "Edit test."); await m.edit(content: "Edit test.");