Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement events GuildDelete #88

Merged
merged 19 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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