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
Version 2, June 1991
Copyright (C) 2018, Szymon Uglis, Zach Vacura
Copyright (C) 2018-2021, Szymon Uglis, Zach Vacura and contributors
Preamble

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
name: nyxx_commander
version: 2.0.0-rc.1
version: 2.0.0-rc.2
description: A Discord library for Dart.
homepage: https://github.com/l7ssha/nyxx
repository: https://github.com/l7ssha/nyxx
@ -12,4 +12,4 @@ environment:
dependencies:
http: "^0.13.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
_24.08.2020_
@ -5,9 +13,9 @@ _24.08.2020_
> **`1.0.0` drops support for browser. Nyxx will now run only on VM**
* New emoji module for fetching available emoji info
* Pagination module for created paginated messages
* Scheduler module for invoking repeatable actions
* Additional general utils
* Message resolver module for resolving raw message content into human readable form
* Attachment extensions for vm
- New emoji module for fetching available emoji info
- Pagination module for created paginated messages
- Scheduler module for invoking repeatable actions
- Additional general utils
- Message resolver module for resolving raw message content into human readable form
- Attachment extensions for vm

View File

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

View File

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

View File

@ -1,5 +1,5 @@
name: nyxx_extensions
version: 2.0.0-rc.1
version: 2.0.0-rc.2
description: Extensions for Nyxx library
homepage: https://github.com/l7ssha/nyxx
repository: https://github.com/l7ssha/nyxx
@ -11,4 +11,4 @@ environment:
dependencies:
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
- Initial version
- Initial version @HarryET

View File

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

View File

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

View File

@ -1,5 +1,5 @@
name: nyxx_interactions
version: 2.0.0-rc.1
version: 2.0.0-rc.2
description: Interactions for Nyxx library
homepage: https://github.com/l7ssha/nyxx
repository: https://github.com/l7ssha/nyxx
@ -11,4 +11,4 @@ environment:
dependencies:
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
_xx.xx.2020_
## 2.0.0-rc.2
_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)
- Fix replacing embed field. Order of fields is now preserved (f667c2a)
@ -8,7 +10,17 @@ _xx.xx.2020_
- Expose raw api call api (f297cc0)
- Add support for gateway transport compression (fd090dd)
- 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
_08.09.2020_

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
part of nyxx;
/// Represents channel within [Guild]. Shares logic for both [TextGuildChannel] and [VoiceGuildChannel].
abstract class GuildChannel extends IChannel {
/// The channel"s 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
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.
Permissions.fromInt(int permissions) {
_construct(permissions);
@ -109,6 +115,7 @@ class Permissions implements Convertable<PermissionsBuilder> {
}
/// Permissions with max value
@Deprecated("Needs to be updated")
Permissions.all() {
_construct(PermissionsConstants.allPermissions);
}
@ -121,48 +128,85 @@ class Permissions implements Convertable<PermissionsBuilder> {
void _construct(int permissions) {
this.raw = permissions;
this.createInstantInvite = PermissionsUtils.isApplied(permissions, PermissionsConstants.createInstantInvite);
this.kickMembers = PermissionsUtils.isApplied(permissions, PermissionsConstants.kickMembers);
this.banMembers = PermissionsUtils.isApplied(permissions, PermissionsConstants.banMembers);
this.administrator = PermissionsUtils.isApplied(permissions, PermissionsConstants.administrator);
this.manageChannels = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageChannels);
this.manageGuild = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageGuild);
this.addReactions = PermissionsUtils.isApplied(permissions, PermissionsConstants.addReactions);
this.viewAuditLog = PermissionsUtils.isApplied(permissions, PermissionsConstants.viewAuditLog);
this.viewChannel = PermissionsUtils.isApplied(permissions, PermissionsConstants.viewChannel);
this.sendMessages = PermissionsUtils.isApplied(permissions, PermissionsConstants.sendMessages);
this.prioritySpeaker = PermissionsUtils.isApplied(permissions, PermissionsConstants.prioritySpeaker);
this.sendTtsMessages = PermissionsUtils.isApplied(permissions, PermissionsConstants.sendTtsMessages);
this.manageMessages = PermissionsUtils.isApplied(permissions, PermissionsConstants.manageMessages);
this.embedLinks = PermissionsUtils.isApplied(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.createInstantInvite = PermissionsUtils.isApplied(
permissions, PermissionsConstants.createInstantInvite);
this.kickMembers = PermissionsUtils.isApplied(
permissions, PermissionsConstants.kickMembers);
this.banMembers = PermissionsUtils.isApplied(
permissions, PermissionsConstants.banMembers);
this.administrator = PermissionsUtils.isApplied(
permissions, PermissionsConstants.administrator);
this.manageChannels = PermissionsUtils.isApplied(
permissions, PermissionsConstants.manageChannels);
this.manageGuild = PermissionsUtils.isApplied(
permissions, PermissionsConstants.manageGuild);
this.addReactions = PermissionsUtils.isApplied(
permissions, PermissionsConstants.addReactions);
this.viewAuditLog = PermissionsUtils.isApplied(
permissions, PermissionsConstants.viewAuditLog);
this.viewChannel = PermissionsUtils.isApplied(
permissions, PermissionsConstants.viewChannel);
this.sendMessages = PermissionsUtils.isApplied(
permissions, PermissionsConstants.sendMessages);
this.prioritySpeaker = PermissionsUtils.isApplied(
permissions, PermissionsConstants.prioritySpeaker);
this.sendTtsMessages = PermissionsUtils.isApplied(
permissions, PermissionsConstants.sendTtsMessages);
this.manageMessages = PermissionsUtils.isApplied(
permissions, PermissionsConstants.manageMessages);
this.embedLinks = PermissionsUtils.isApplied(
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.stream = PermissionsUtils.isApplied(permissions, PermissionsConstants.stream);
this.viewGuildInsights = PermissionsUtils.isApplied(permissions, PermissionsConstants.viewGuildInsights);
this.manageEmojis = PermissionsUtils.isApplied(
permissions, PermissionsConstants.manageEmojis);
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]
bool hasPermission(int permission) => PermissionsUtils.isApplied(this.raw, permission);
bool hasPermission(int permission) =>
PermissionsUtils.isApplied(this.raw, permission);
@override
int get hashCode => raw.hashCode;
@override
bool operator ==(other) {
bool operator ==(dynamic other) {
if (other is Permissions) return other.raw == this.raw;
if (other is int) return other == this.raw;

View File

@ -95,6 +95,13 @@ class PermissionsConstants {
/// Allows for viewing guild insights
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
@Deprecated("Needs to be updated")
static const int allPermissions = 0x7FFFFFFF;
}

View File

@ -33,6 +33,9 @@ class VoiceState {
/// Whether this user's camera is enabled
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) {
if (raw["channel_id"] != null) {
this.channel = _ChannelCacheable(client, Snowflake(raw["channel_id"]));
@ -47,6 +50,10 @@ class VoiceState {
this.selfStream = raw["self_stream"] as bool? ?? false;
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.sessionId = raw["session_id"] as String;

View File

@ -29,7 +29,7 @@ class Constants {
static const String baseUri = "/api/v8";
/// 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
static const String repoUrl = "https://github.com/l7ssha/nyxx";

View File

@ -1,5 +1,5 @@
name: nyxx
version: 2.0.0-rc.1
version: 2.0.0-rc.2
description: A Discord library for Dart.
homepage: 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";
// 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
const toDeleteMessageContent = [
"--trigger-test",
@ -23,14 +14,10 @@ const toDeleteMessageContent = [
"Converting successfull"
];
// -------------------------------------------------------
EmbedBuilder createTestEmbed() => EmbedBuilder()
..title = "Test title"
..addField(name: "Test field", content: "Test value", inline: true);
// -------------------------------------------------------
void main() {
final env = Platform.environment;
final bot = Nyxx(env["TEST_TOKEN"]!, GatewayIntents.guildMessages, ignoreExceptions: false);
@ -51,23 +38,6 @@ void main() {
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!");
final m = await channel.sendMessage(content: "Message test.");
await m.edit(content: "Edit test.");