From b94054afffb19e613d1e0590668bf2606c08c06e Mon Sep 17 00:00:00 2001 From: Azarow Date: Fri, 24 Feb 2023 10:35:46 +0100 Subject: [PATCH 1/8] feat: implement CI:CD --- .github/workflows/publish.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..b3f2820e9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,10 @@ +name: Publish to pub.dev + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + +jobs: + publish: + uses: dart-lang/setup-dart/.github/workflows/publish.yml \ No newline at end of file From f048fc2480aa96ebb64b324997d218496ca3b086 Mon Sep 17 00:00:00 2001 From: Azarow Date: Fri, 24 Feb 2023 14:47:37 +0100 Subject: [PATCH 2/8] fix: fix script deploy --- .github/workflows/publish.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b3f2820e9..27fbd79d9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,8 +3,20 @@ name: Publish to pub.dev on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+*' + - 'v[0-9]+.[0-9]+.[0-9]+*' # tag pattern on pub.dev: 'v' +# Publish using custom workflow jobs: publish: - uses: dart-lang/setup-dart/.github/workflows/publish.yml \ No newline at end of file + permissions: + id-token: write # This is required for authentication using OIDC + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dart-lang/setup-dart@v1 + - name: Install dependencies + run: dart pub get + # Here you can insert custom steps you need + # - run: dart tool/generate-code.dart + - name: Publish + run: dart pub publish --force \ No newline at end of file From e9821a8aa37c7bd5381beb48e034d56ed98c5663 Mon Sep 17 00:00:00 2001 From: Victor G <34095646+vic256@users.noreply.github.com> Date: Sun, 19 Mar 2023 15:09:07 +0100 Subject: [PATCH 3/8] ci: Add doc generation --- .github/workflows/publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 27fbd79d9..b2e12b513 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,5 +18,7 @@ jobs: run: dart pub get # Here you can insert custom steps you need # - run: dart tool/generate-code.dart + - name: Doc + run: dart doc - name: Publish run: dart pub publish --force \ No newline at end of file From 71e8457fc1fe004f569a78890590caccbff4437a Mon Sep 17 00:00:00 2001 From: Victor G <34095646+vic256@users.noreply.github.com> Date: Sun, 19 Mar 2023 17:08:26 +0100 Subject: [PATCH 4/8] hotfix: Change pubspec version --- CHANGELOG.md | 15 +++++++++++++++ pubspec.yaml | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a4eeb86..a940ac0e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## 3.0.0 +- Implement cli & refactor +- Implement new features +- Assign true templates +- Improve core +- Add commands git +- Implement Attachments +- Channel not initialized +- Implement http builder & split http service +- Edit attachments in messages +- Implement message bulk delete +- Improve cache +- Interaction and commands in dm channels +- Improve users + ## 2.6.2 - Fix bad guild id - Remove nullable content of `Message` diff --git a/pubspec.yaml b/pubspec.yaml index c6e0e8276..00cc7959e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: mineral description: Mineral is a Discord framework for designing discord bots in Dart. -version: 2.6.2 +version: 3.0.0 repository: https://github.com/mineral-dart/core # homepage: https://www.example.com From da97ac45c1a79fd11f31361c07cfe0e9865bba31 Mon Sep 17 00:00:00 2001 From: Victor G <34095646+vic256@users.noreply.github.com> Date: Sun, 19 Mar 2023 17:20:15 +0100 Subject: [PATCH 5/8] chore: Remove doc in actions --- .github/workflows/publish.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b2e12b513..ef16d43b0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,7 +18,5 @@ jobs: run: dart pub get # Here you can insert custom steps you need # - run: dart tool/generate-code.dart - - name: Doc - run: dart doc - name: Publish - run: dart pub publish --force \ No newline at end of file + run: dart pub publish --force From 185c1981501e8ada256720d161c9da7c7600fc17 Mon Sep 17 00:00:00 2001 From: Azarow Date: Mon, 20 Mar 2023 04:50:49 +0100 Subject: [PATCH 6/8] feat: implement events GuildDelete --- lib/src/constants.dart | 1 + .../websockets/events/guild_delete_event.dart | 7 ++++++ .../packets/guild_delete_packet.dart | 24 +++++++++++++++++++ .../websockets/websocket_dispatcher.dart | 2 ++ 4 files changed, 34 insertions(+) create mode 100644 lib/src/internal/websockets/events/guild_delete_event.dart create mode 100644 lib/src/internal/websockets/packets/guild_delete_packet.dart diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 0f172347a..953ac2c57 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -21,6 +21,7 @@ enum PacketType { ready('READY'), guildCreate('GUILD_CREATE'), guildUpdate('GUILD_UPDATE'), + guildDelete('GUILD_DELETE'), guildIntegrationsUpdate('GUILD_INTEGRATIONS_UPDATE'), diff --git a/lib/src/internal/websockets/events/guild_delete_event.dart b/lib/src/internal/websockets/events/guild_delete_event.dart new file mode 100644 index 000000000..12f311c8b --- /dev/null +++ b/lib/src/internal/websockets/events/guild_delete_event.dart @@ -0,0 +1,7 @@ +import 'package:mineral/framework.dart'; + +class GuildDeleteEvent extends Event { + final String _id; + + GuildDeleteEvent(this._id); +} \ No newline at end of file diff --git a/lib/src/internal/websockets/packets/guild_delete_packet.dart b/lib/src/internal/websockets/packets/guild_delete_packet.dart new file mode 100644 index 000000000..142114ae8 --- /dev/null +++ b/lib/src/internal/websockets/packets/guild_delete_packet.dart @@ -0,0 +1,24 @@ +import 'package:mineral/core/api.dart'; +import 'package:mineral/core/extras.dart'; +import 'package:mineral/framework.dart'; +import 'package:mineral/internal.dart'; +import 'package:mineral/src/internal/services/event_service.dart'; +import 'package:mineral/src/internal/websockets/events/guild_delete_event.dart'; + +class GuildDeletePacket with Container implements WebsocketPacket { + @override + Future handle(WebsocketResponse websocketResponse) async { + EventService eventService = container.use(); + MineralClient client = container.use(); + + dynamic payload = websocketResponse.payload; + + Guild? guild = client.guilds.cache.get(payload['guild_id']); + + if (guild != null) { + eventService.controller.add(GuildDeleteEvent(guild.id)); + client.guilds.cache.remove(payload['guild_id']); + } + } + +} \ No newline at end of file diff --git a/lib/src/internal/websockets/websocket_dispatcher.dart b/lib/src/internal/websockets/websocket_dispatcher.dart index bbc484ddd..934c6a6e3 100644 --- a/lib/src/internal/websockets/websocket_dispatcher.dart +++ b/lib/src/internal/websockets/websocket_dispatcher.dart @@ -6,6 +6,7 @@ import 'package:mineral/src/internal/websockets/packets/channel_create_packet.da import 'package:mineral/src/internal/websockets/packets/channel_delete_packet.dart'; import 'package:mineral/src/internal/websockets/packets/channel_update_packet.dart'; import 'package:mineral/src/internal/websockets/packets/guild_create_packet.dart'; +import 'package:mineral/src/internal/websockets/packets/guild_delete_packet.dart'; import 'package:mineral/src/internal/websockets/packets/guild_integrations_update.dart'; import 'package:mineral/src/internal/websockets/packets/guild_scheduled_event_create.dart'; import 'package:mineral/src/internal/websockets/packets/guild_scheduled_event_delete.dart'; @@ -37,6 +38,7 @@ class WebsocketDispatcher { register(PacketType.resumed, ResumedPacket()); register(PacketType.guildCreate, GuildCreatePacket()); register(PacketType.guildUpdate, GuildUpdatePacket()); + register(PacketType.guildDelete, GuildDeletePacket()); register(PacketType.presenceUpdate, PresenceUpdatePacket()); register(PacketType.messageDelete, MessageDeletePacket()); register(PacketType.messageCreate, MessageCreatePacket()); From eae62012688c2cd27cc3e55e4136da012f47a779 Mon Sep 17 00:00:00 2001 From: Azarow Date: Mon, 20 Mar 2023 15:29:18 +0100 Subject: [PATCH 7/8] feat: rename file & retur instance guild for event GUILD_DELETE --- lib/src/internal/websockets/events/guild_delete_event.dart | 7 +++++-- .../{guild_delete_packet.dart => guild_remove_packet.dart} | 6 +++--- lib/src/internal/websockets/websocket_dispatcher.dart | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) rename lib/src/internal/websockets/packets/{guild_delete_packet.dart => guild_remove_packet.dart} (78%) diff --git a/lib/src/internal/websockets/events/guild_delete_event.dart b/lib/src/internal/websockets/events/guild_delete_event.dart index 12f311c8b..8a4082be8 100644 --- a/lib/src/internal/websockets/events/guild_delete_event.dart +++ b/lib/src/internal/websockets/events/guild_delete_event.dart @@ -1,7 +1,10 @@ +import 'package:mineral/core/api.dart'; import 'package:mineral/framework.dart'; class GuildDeleteEvent extends Event { - final String _id; + final Guild _guild; - GuildDeleteEvent(this._id); + GuildDeleteEvent(this._guild); + + Guild get guild => _guild; } \ No newline at end of file diff --git a/lib/src/internal/websockets/packets/guild_delete_packet.dart b/lib/src/internal/websockets/packets/guild_remove_packet.dart similarity index 78% rename from lib/src/internal/websockets/packets/guild_delete_packet.dart rename to lib/src/internal/websockets/packets/guild_remove_packet.dart index 142114ae8..68c7a72d6 100644 --- a/lib/src/internal/websockets/packets/guild_delete_packet.dart +++ b/lib/src/internal/websockets/packets/guild_remove_packet.dart @@ -5,7 +5,7 @@ import 'package:mineral/internal.dart'; import 'package:mineral/src/internal/services/event_service.dart'; import 'package:mineral/src/internal/websockets/events/guild_delete_event.dart'; -class GuildDeletePacket with Container implements WebsocketPacket { +class GuildRemovePacket with Container implements WebsocketPacket { @override Future handle(WebsocketResponse websocketResponse) async { EventService eventService = container.use(); @@ -16,8 +16,8 @@ class GuildDeletePacket with Container implements WebsocketPacket { Guild? guild = client.guilds.cache.get(payload['guild_id']); if (guild != null) { - eventService.controller.add(GuildDeleteEvent(guild.id)); - client.guilds.cache.remove(payload['guild_id']); + eventService.controller.add(GuildDeleteEvent(guild)); + client.guilds.cache.remove(guild.id); } } diff --git a/lib/src/internal/websockets/websocket_dispatcher.dart b/lib/src/internal/websockets/websocket_dispatcher.dart index 934c6a6e3..2ba603ffd 100644 --- a/lib/src/internal/websockets/websocket_dispatcher.dart +++ b/lib/src/internal/websockets/websocket_dispatcher.dart @@ -6,8 +6,8 @@ import 'package:mineral/src/internal/websockets/packets/channel_create_packet.da import 'package:mineral/src/internal/websockets/packets/channel_delete_packet.dart'; import 'package:mineral/src/internal/websockets/packets/channel_update_packet.dart'; import 'package:mineral/src/internal/websockets/packets/guild_create_packet.dart'; -import 'package:mineral/src/internal/websockets/packets/guild_delete_packet.dart'; import 'package:mineral/src/internal/websockets/packets/guild_integrations_update.dart'; +import 'package:mineral/src/internal/websockets/packets/guild_remove_packet.dart'; import 'package:mineral/src/internal/websockets/packets/guild_scheduled_event_create.dart'; import 'package:mineral/src/internal/websockets/packets/guild_scheduled_event_delete.dart'; import 'package:mineral/src/internal/websockets/packets/guild_scheduled_event_update.dart'; @@ -38,7 +38,7 @@ class WebsocketDispatcher { register(PacketType.resumed, ResumedPacket()); register(PacketType.guildCreate, GuildCreatePacket()); register(PacketType.guildUpdate, GuildUpdatePacket()); - register(PacketType.guildDelete, GuildDeletePacket()); + register(PacketType.guildDelete, GuildRemovePacket()); register(PacketType.presenceUpdate, PresenceUpdatePacket()); register(PacketType.messageDelete, MessageDeletePacket()); register(PacketType.messageCreate, MessageCreatePacket()); From c97ea13a82c7213a791dc984b4c41addaf6c0566 Mon Sep 17 00:00:00 2001 From: Azarow Date: Wed, 22 Mar 2023 00:55:23 +0100 Subject: [PATCH 8/8] feat: change get to getOrFail GuildRemovePacket --- .../internal/websockets/packets/guild_remove_packet.dart | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/src/internal/websockets/packets/guild_remove_packet.dart b/lib/src/internal/websockets/packets/guild_remove_packet.dart index 68c7a72d6..30f913b48 100644 --- a/lib/src/internal/websockets/packets/guild_remove_packet.dart +++ b/lib/src/internal/websockets/packets/guild_remove_packet.dart @@ -13,12 +13,10 @@ class GuildRemovePacket with Container implements WebsocketPacket { dynamic payload = websocketResponse.payload; - Guild? guild = client.guilds.cache.get(payload['guild_id']); + Guild? guild = client.guilds.cache.getOrFail(payload['guild_id']); - if (guild != null) { - eventService.controller.add(GuildDeleteEvent(guild)); - client.guilds.cache.remove(guild.id); - } + eventService.controller.add(GuildDeleteEvent(guild)); + client.guilds.cache.remove(guild.id); } } \ No newline at end of file