Skip to content

Commit

Permalink
Merge pull request #88 from ThibaultPointurier/main
Browse files Browse the repository at this point in the history
feat: implement events GuildDelete
  • Loading branch information
LeadcodeDev authored Mar 22, 2023
2 parents 56bd0e8 + c97ea13 commit 1bd488d
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish to pub.dev

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # tag pattern on pub.dev: 'v'

# Publish using custom workflow
jobs:
publish:
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
1 change: 1 addition & 0 deletions lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum PacketType {
ready('READY'),
guildCreate('GUILD_CREATE'),
guildUpdate('GUILD_UPDATE'),
guildDelete('GUILD_DELETE'),

guildIntegrationsUpdate('GUILD_INTEGRATIONS_UPDATE'),

Expand Down
10 changes: 10 additions & 0 deletions lib/src/internal/websockets/events/guild_delete_event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:mineral/core/api.dart';
import 'package:mineral/framework.dart';

class GuildDeleteEvent extends Event {
final Guild _guild;

GuildDeleteEvent(this._guild);

Guild get guild => _guild;
}
22 changes: 22 additions & 0 deletions lib/src/internal/websockets/packets/guild_remove_packet.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 GuildRemovePacket with Container implements WebsocketPacket {
@override
Future<void> handle(WebsocketResponse websocketResponse) async {
EventService eventService = container.use<EventService>();
MineralClient client = container.use<MineralClient>();

dynamic payload = websocketResponse.payload;

Guild? guild = client.guilds.cache.getOrFail(payload['guild_id']);

eventService.controller.add(GuildDeleteEvent(guild));
client.guilds.cache.remove(guild.id);
}

}
2 changes: 2 additions & 0 deletions lib/src/internal/websockets/websocket_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:mineral/src/internal/websockets/packets/channel_delete_packet.da
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_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';
Expand Down Expand Up @@ -37,6 +38,7 @@ class WebsocketDispatcher {
register(PacketType.resumed, ResumedPacket());
register(PacketType.guildCreate, GuildCreatePacket());
register(PacketType.guildUpdate, GuildUpdatePacket());
register(PacketType.guildDelete, GuildRemovePacket());
register(PacketType.presenceUpdate, PresenceUpdatePacket());
register(PacketType.messageDelete, MessageDeletePacket());
register(PacketType.messageCreate, MessageCreatePacket());
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 1bd488d

Please sign in to comment.