From 4c7b1e19164ec9f0f227481808e8cc25de4d6b1e Mon Sep 17 00:00:00 2001 From: Vic256 Date: Wed, 6 Jul 2022 01:46:41 +0200 Subject: [PATCH 01/68] feat: Add join and leave events --- lib/src/api/guilds/member_role_manager.dart | 4 +-- lib/src/constants.dart | 2 ++ lib/src/internal/entities/event_manager.dart | 2 ++ .../websockets/packets/guild_member_add.dart | 29 ++++++++++++++++++ .../packets/guild_member_delete.dart | 30 +++++++++++++++++++ .../websockets/websocket_dispatcher.dart | 4 +++ 6 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 lib/src/internal/websockets/packets/guild_member_add.dart create mode 100644 lib/src/internal/websockets/packets/guild_member_delete.dart diff --git a/lib/src/api/guilds/member_role_manager.dart b/lib/src/api/guilds/member_role_manager.dart index d4b2062bd..15dfe3428 100644 --- a/lib/src/api/guilds/member_role_manager.dart +++ b/lib/src/api/guilds/member_role_manager.dart @@ -44,7 +44,7 @@ class MemberRoleManager implements CacheManager { } Response response = await http.put( - url: '/guilds/{guild.id}/members/$memberId/roles/$id', + url: '/guilds/${manager.guildId}/members/$memberId/roles/$id', payload: {}, headers: headers ); @@ -76,7 +76,7 @@ class MemberRoleManager implements CacheManager { } Response response = await http.destroy( - url: '/guilds/{guild.id}/members/$memberId/roles/$id', + url: '/guilds/${manager.guildId}/members/$memberId/roles/$id', headers: headers ); diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 33d6b121d..2c01f01ff 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -48,6 +48,8 @@ enum PacketType { interactionCreate('INTERACTION_CREATE'), memberUpdate('GUILD_MEMBER_UPDATE'), + memberDelete('GUILD_MEMBER_REMOVE'), + memberAdd('GUILD_MEMBER_ADD'), resumed('RESUMED'); diff --git a/lib/src/internal/entities/event_manager.dart b/lib/src/internal/entities/event_manager.dart index 3da661513..45c9344ae 100644 --- a/lib/src/internal/entities/event_manager.dart +++ b/lib/src/internal/entities/event_manager.dart @@ -83,7 +83,9 @@ enum Events { channelUpdate('update::channel', { 'before': Channel, 'after': Channel }), channelDelete('delete::channel', { 'channel': Channel }), + memberJoin('join::member', { 'member': GuildMember }), memberUpdate('update::member', { 'member': GuildMember }), + memberLeave('leave::member', { 'member': GuildMember }), memberRolesUpdate('update::roles-member', { 'before': Role, 'after': Role }), acceptRules('accept::rules', { 'member': GuildMember }), diff --git a/lib/src/internal/websockets/packets/guild_member_add.dart b/lib/src/internal/websockets/packets/guild_member_add.dart new file mode 100644 index 000000000..6a094dd58 --- /dev/null +++ b/lib/src/internal/websockets/packets/guild_member_add.dart @@ -0,0 +1,29 @@ +import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/websockets/websocket_packet.dart'; +import 'package:mineral/src/internal/websockets/websocket_response.dart'; + +class GuildMemberAdd implements WebsocketPacket { + @override + PacketType packetType = PacketType.memberAdd; + + @override + Future handle(WebsocketResponse websocketResponse) async { + EventManager manager = ioc.singleton(ioc.services.event); + MineralClient client = ioc.singleton(ioc.services.client); + + dynamic payload = websocketResponse.payload; + + Guild? guild = client.guilds.cache.get(payload['guild_id']); + + if(guild != null) { + User user = User.from(payload['user']); + GuildMember member = GuildMember.from(user: user, roles: guild.roles, member: payload, guildId: guild.id); + member.guild = guild; + + guild.members.cache.putIfAbsent(member.user.id, () => member); + manager.emit(event: Events.memberJoin, params: [member]); + } + } +} diff --git a/lib/src/internal/websockets/packets/guild_member_delete.dart b/lib/src/internal/websockets/packets/guild_member_delete.dart new file mode 100644 index 000000000..9bd6c2d93 --- /dev/null +++ b/lib/src/internal/websockets/packets/guild_member_delete.dart @@ -0,0 +1,30 @@ +import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/websockets/websocket_packet.dart'; +import 'package:mineral/src/internal/websockets/websocket_response.dart'; + +class GuildMemberDelete implements WebsocketPacket { + @override + PacketType packetType = PacketType.memberDelete; + + @override + Future handle(WebsocketResponse websocketResponse) async { + EventManager manager = ioc.singleton(ioc.services.event); + MineralClient client = ioc.singleton(ioc.services.client); + + dynamic payload = websocketResponse.payload; + + Guild? guild = client.guilds.cache.get(payload['guild_id']); + GuildMember? member = guild?.members.cache.get(payload['user']['id']); + + if(guild != null && member != null) { + manager.emit( + event: Events.memberLeave, + params: [member] + ); + + guild.members.cache.remove(member.user.id); + } + } +} diff --git a/lib/src/internal/websockets/websocket_dispatcher.dart b/lib/src/internal/websockets/websocket_dispatcher.dart index aa91dbf35..fd8e32d26 100644 --- a/lib/src/internal/websockets/websocket_dispatcher.dart +++ b/lib/src/internal/websockets/websocket_dispatcher.dart @@ -7,6 +7,8 @@ import 'package:mineral/src/internal/websockets/packets/channel_delete.dart'; import 'package:mineral/src/internal/websockets/packets/channel_update.dart'; import 'package:mineral/src/internal/websockets/packets/guild_create.dart'; import 'package:mineral/src/internal/websockets/packets/guild_integrations_update.dart'; +import 'package:mineral/src/internal/websockets/packets/guild_member_add.dart'; +import 'package:mineral/src/internal/websockets/packets/guild_member_delete.dart'; import 'package:mineral/src/internal/websockets/packets/guild_member_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'; @@ -43,6 +45,8 @@ class WebsocketDispatcher { register(PacketType.channelDelete, ChannelDelete()); register(PacketType.channelUpdate, ChannelUpdate()); register(PacketType.memberUpdate, GuildMemberUpdate()); + register(PacketType.memberDelete, GuildMemberDelete()); + register(PacketType.memberAdd, GuildMemberAdd()); register(PacketType.interactionCreate, InteractionCreate()); register(PacketType.autoModerationRuleCreate, AutoModerationRuleCreate()); register(PacketType.autoModerationRuleDelete, AutoModerationRuleDelete()); From 5bdc7d7a87267a28736dc74dbd143c993501a8dc Mon Sep 17 00:00:00 2001 From: Vic256 Date: Wed, 6 Jul 2022 01:59:43 +0200 Subject: [PATCH 02/68] feat: Add join request packet and rule event --- lib/src/constants.dart | 2 ++ .../packets/member_join_request.dart | 30 +++++++++++++++++++ .../websockets/websocket_dispatcher.dart | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 lib/src/internal/websockets/packets/member_join_request.dart diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 2c01f01ff..afd9d7d5e 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -51,6 +51,8 @@ enum PacketType { memberDelete('GUILD_MEMBER_REMOVE'), memberAdd('GUILD_MEMBER_ADD'), + memberJoinRequest('GUILD_JOIN_REQUEST_UPDATE'), + resumed('RESUMED'); final String _value; diff --git a/lib/src/internal/websockets/packets/member_join_request.dart b/lib/src/internal/websockets/packets/member_join_request.dart new file mode 100644 index 000000000..e3126ad3f --- /dev/null +++ b/lib/src/internal/websockets/packets/member_join_request.dart @@ -0,0 +1,30 @@ +import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/websockets/websocket_packet.dart'; +import 'package:mineral/src/internal/websockets/websocket_response.dart'; + +class MemberJoinRequest implements WebsocketPacket { + @override + PacketType packetType = PacketType.memberJoinRequest; + + @override + Future handle(WebsocketResponse websocketResponse) async { + EventManager manager = ioc.singleton(ioc.services.event); + MineralClient client = ioc.singleton(ioc.services.client); + + dynamic payload = websocketResponse.payload; + + Guild? guild = client.guilds.cache.get(payload['request']['guild_id']); + + if(payload['status'] == 'APPROVED' && guild != null) { + GuildMember? member = guild.members.cache.get(payload['request']['user_id']); + + manager.emit( + event: Events.acceptRules, + params: [member] + ); + } + + } +} diff --git a/lib/src/internal/websockets/websocket_dispatcher.dart b/lib/src/internal/websockets/websocket_dispatcher.dart index fd8e32d26..c3c627e35 100644 --- a/lib/src/internal/websockets/websocket_dispatcher.dart +++ b/lib/src/internal/websockets/websocket_dispatcher.dart @@ -17,6 +17,7 @@ import 'package:mineral/src/internal/websockets/packets/guild_scheduled_event_us import 'package:mineral/src/internal/websockets/packets/guild_scheduled_event_user_remove.dart'; import 'package:mineral/src/internal/websockets/packets/guild_update.dart'; import 'package:mineral/src/internal/websockets/packets/interaction_create.dart'; +import 'package:mineral/src/internal/websockets/packets/member_join_request.dart'; import 'package:mineral/src/internal/websockets/packets/message_create.dart'; import 'package:mineral/src/internal/websockets/packets/message_delete.dart'; import 'package:mineral/src/internal/websockets/packets/message_update.dart'; @@ -47,6 +48,7 @@ class WebsocketDispatcher { register(PacketType.memberUpdate, GuildMemberUpdate()); register(PacketType.memberDelete, GuildMemberDelete()); register(PacketType.memberAdd, GuildMemberAdd()); + register(PacketType.memberJoinRequest, MemberJoinRequest()); register(PacketType.interactionCreate, InteractionCreate()); register(PacketType.autoModerationRuleCreate, AutoModerationRuleCreate()); register(PacketType.autoModerationRuleDelete, AutoModerationRuleDelete()); From 45dd156258cef4c6e032d0c01fbf6bddbb2da01f Mon Sep 17 00:00:00 2001 From: Vic256 Date: Wed, 6 Jul 2022 09:24:20 +0200 Subject: [PATCH 03/68] fix: Remove rule accept when guild member is update --- .../internal/websockets/packets/guild_member_update.dart | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/src/internal/websockets/packets/guild_member_update.dart b/lib/src/internal/websockets/packets/guild_member_update.dart index 2e85e70ee..2c92b8e58 100644 --- a/lib/src/internal/websockets/packets/guild_member_update.dart +++ b/lib/src/internal/websockets/packets/guild_member_update.dart @@ -31,13 +31,6 @@ class GuildMemberUpdate implements WebsocketPacket { params: [before, after] ); - if (before?.isPending != after.isPending) { - manager.emit( - event: Events.acceptRules, - params: [after] - ); - } - if (before?.roles.cache.length != after.roles.cache.length) { manager.emit( event: Events.memberRolesUpdate, From 0dde1b3aacc9c01a533e090de886ebc770268d5c Mon Sep 17 00:00:00 2001 From: Vic256 Date: Thu, 7 Jul 2022 00:37:32 +0200 Subject: [PATCH 04/68] refactor: Rename delete by remove --- lib/src/constants.dart | 2 +- lib/src/internal/entities/event_manager.dart | 2 +- ...{guild_member_delete.dart => guild_member_remove.dart} | 8 ++++---- lib/src/internal/websockets/websocket_dispatcher.dart | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename lib/src/internal/websockets/packets/{guild_member_delete.dart => guild_member_remove.dart} (83%) diff --git a/lib/src/constants.dart b/lib/src/constants.dart index afd9d7d5e..8c9514008 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -48,7 +48,7 @@ enum PacketType { interactionCreate('INTERACTION_CREATE'), memberUpdate('GUILD_MEMBER_UPDATE'), - memberDelete('GUILD_MEMBER_REMOVE'), + memberRemove('GUILD_MEMBER_REMOVE'), memberAdd('GUILD_MEMBER_ADD'), memberJoinRequest('GUILD_JOIN_REQUEST_UPDATE'), diff --git a/lib/src/internal/entities/event_manager.dart b/lib/src/internal/entities/event_manager.dart index 45c9344ae..b93e1e623 100644 --- a/lib/src/internal/entities/event_manager.dart +++ b/lib/src/internal/entities/event_manager.dart @@ -84,7 +84,7 @@ enum Events { channelDelete('delete::channel', { 'channel': Channel }), memberJoin('join::member', { 'member': GuildMember }), - memberUpdate('update::member', { 'member': GuildMember }), + memberUpdate('update::member', { 'before': GuildMember, 'after': GuildMember }), memberLeave('leave::member', { 'member': GuildMember }), memberRolesUpdate('update::roles-member', { 'before': Role, 'after': Role }), acceptRules('accept::rules', { 'member': GuildMember }), diff --git a/lib/src/internal/websockets/packets/guild_member_delete.dart b/lib/src/internal/websockets/packets/guild_member_remove.dart similarity index 83% rename from lib/src/internal/websockets/packets/guild_member_delete.dart rename to lib/src/internal/websockets/packets/guild_member_remove.dart index 9bd6c2d93..613cee743 100644 --- a/lib/src/internal/websockets/packets/guild_member_delete.dart +++ b/lib/src/internal/websockets/packets/guild_member_remove.dart @@ -4,9 +4,9 @@ import 'package:mineral/src/internal/entities/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; -class GuildMemberDelete implements WebsocketPacket { +class GuildMemberRemove implements WebsocketPacket { @override - PacketType packetType = PacketType.memberDelete; + PacketType packetType = PacketType.memberRemove; @override Future handle(WebsocketResponse websocketResponse) async { @@ -20,8 +20,8 @@ class GuildMemberDelete implements WebsocketPacket { if(guild != null && member != null) { manager.emit( - event: Events.memberLeave, - params: [member] + event: Events.memberLeave, + params: [member] ); guild.members.cache.remove(member.user.id); diff --git a/lib/src/internal/websockets/websocket_dispatcher.dart b/lib/src/internal/websockets/websocket_dispatcher.dart index c3c627e35..089159e17 100644 --- a/lib/src/internal/websockets/websocket_dispatcher.dart +++ b/lib/src/internal/websockets/websocket_dispatcher.dart @@ -8,7 +8,7 @@ import 'package:mineral/src/internal/websockets/packets/channel_update.dart'; import 'package:mineral/src/internal/websockets/packets/guild_create.dart'; import 'package:mineral/src/internal/websockets/packets/guild_integrations_update.dart'; import 'package:mineral/src/internal/websockets/packets/guild_member_add.dart'; -import 'package:mineral/src/internal/websockets/packets/guild_member_delete.dart'; +import 'package:mineral/src/internal/websockets/packets/guild_member_remove.dart'; import 'package:mineral/src/internal/websockets/packets/guild_member_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'; @@ -46,7 +46,7 @@ class WebsocketDispatcher { register(PacketType.channelDelete, ChannelDelete()); register(PacketType.channelUpdate, ChannelUpdate()); register(PacketType.memberUpdate, GuildMemberUpdate()); - register(PacketType.memberDelete, GuildMemberDelete()); + register(PacketType.memberRemove, GuildMemberRemove()); register(PacketType.memberAdd, GuildMemberAdd()); register(PacketType.memberJoinRequest, MemberJoinRequest()); register(PacketType.interactionCreate, InteractionCreate()); From 8fef4cdaba69544dd6514a3dd8873bf7200ac773 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 8 Jul 2022 22:40:42 +0200 Subject: [PATCH 05/68] feat: add message post generation --- lib/src/commands/make_command.dart | 1 + lib/src/commands/make_event.dart | 1 + lib/src/commands/make_module.dart | 1 + lib/src/commands/make_store.dart | 1 + lib/src/internal/kernel.dart | 2 ++ 5 files changed, 6 insertions(+) diff --git a/lib/src/commands/make_command.dart b/lib/src/commands/make_command.dart index bc5f416ef..212cab927 100644 --- a/lib/src/commands/make_command.dart +++ b/lib/src/commands/make_command.dart @@ -52,6 +52,7 @@ class MakeCommand extends MineralCliCommand { await writeFileContent(file, getTemplate(filename)); Console.success(message: 'The file was created in the location ${file.uri}'); + Console.success(message: 'Don\'t forget to add your file to the main.dart file'); } String getTemplate (String filename) => ''' diff --git a/lib/src/commands/make_event.dart b/lib/src/commands/make_event.dart index a2bf42989..b6190253e 100644 --- a/lib/src/commands/make_event.dart +++ b/lib/src/commands/make_event.dart @@ -59,6 +59,7 @@ class MakeEvent extends MineralCliCommand { await writeFileContent(file, getTemplate(filename, Events.values.elementAt(eventKey))); Console.success(message: 'The file was created in the location ${file.uri}'); + Console.success(message: 'Don\'t forget to add your file to the main.dart file'); } String getTemplate (String filename, Events event) { diff --git a/lib/src/commands/make_module.dart b/lib/src/commands/make_module.dart index 1b092ab89..6325fba2e 100644 --- a/lib/src/commands/make_module.dart +++ b/lib/src/commands/make_module.dart @@ -59,6 +59,7 @@ class MakeModule extends MineralCliCommand { await writeFileContent(file, getTemplate(filename)); Console.success(message: 'The file was created in the location ${file.uri}'); + Console.success(message: 'Don\'t forget to add your file to the main.dart file'); } String getTemplate (String filename) => ''' diff --git a/lib/src/commands/make_store.dart b/lib/src/commands/make_store.dart index 5c99f5f5b..593301f06 100644 --- a/lib/src/commands/make_store.dart +++ b/lib/src/commands/make_store.dart @@ -52,6 +52,7 @@ class MakeStore extends MineralCliCommand { await writeFileContent(file, getTemplate(filename)); Console.success(message: 'The file was created in the location ${file.uri}'); + Console.success(message: 'Don\'t forget to add your file to the main.dart file'); } String getTemplate (String filename) => ''' diff --git a/lib/src/internal/kernel.dart b/lib/src/internal/kernel.dart index 33b2f7535..7158be4a9 100644 --- a/lib/src/internal/kernel.dart +++ b/lib/src/internal/kernel.dart @@ -28,7 +28,9 @@ class Kernel { ioc.bind(namespace: ioc.services.store, service: stores); ioc.bind(namespace: ioc.services.modules, service: modules); ioc.bind(namespace: ioc.services.cli, service: cli); + } + void loadConsole () { cli.add(MakeCommand()); cli.add(MakeEvent()); cli.add(MakeModule()); From f072b89b1d29f570266bed3fe872ee30785e1ed0 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 8 Jul 2022 22:46:28 +0200 Subject: [PATCH 06/68] feat: Remove empty lines from environment file --- lib/src/internal/environment.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/internal/environment.dart b/lib/src/internal/environment.dart index 536b9670a..dd6a2340f 100644 --- a/lib/src/internal/environment.dart +++ b/lib/src/internal/environment.dart @@ -10,12 +10,13 @@ class Environment { List content = await file.readAsLines(encoding: utf8); for (String line in content) { - List content = line.split(':'); + if (line.isNotEmpty) { + List content = line.split(':'); + String key = content[0].trim(); + String value = content[1].trim(); - String key = content[0].trim(); - String value = content[1].trim(); - - _cache.putIfAbsent(key, () => value); + _cache.putIfAbsent(key, () => value); + } } return this; From 98e293bdc0d94a7754b6e6f83164ca67bcfb8623 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 8 Jul 2022 23:11:51 +0200 Subject: [PATCH 07/68] feat: Implement thumbnail into embeds --- lib/api.dart | 2 +- lib/src/api/message_embed.dart | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index 88e1ef225..62f785008 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -28,7 +28,7 @@ export 'src/api/channels/text_channel.dart' show TextChannel; export 'src/api/channels/category_channel.dart' show CategoryChannel; export 'src/api/message.dart' show Message; -export 'src/api/message_embed.dart' show MessageEmbed, Footer, Image, Author, Field; +export 'src/api/message_embed.dart' show MessageEmbed, Footer, Image, Thumbnail, Author, Field; export 'src/api/color.dart' show Color; export 'src/api/emoji.dart' show Emoji; diff --git a/lib/src/api/message_embed.dart b/lib/src/api/message_embed.dart index 7199110f4..9a882f4b6 100644 --- a/lib/src/api/message_embed.dart +++ b/lib/src/api/message_embed.dart @@ -30,6 +30,22 @@ class Image { }; } +class Thumbnail { + String url; + String? proxyUrl; + int? height; + int? width; + + Thumbnail({ required this.url, this.proxyUrl, this.height, this.width }); + + Object toJson () => { + 'url': url, + 'proxy_url': proxyUrl, + 'width': width, + 'height': height, + }; +} + class Author { String name; String? url; @@ -67,7 +83,7 @@ class MessageEmbed { DateTime? timestamp; Footer? footer; Image? image; - // Thumbnail thumbnail; + Thumbnail? thumbnail; Author? author; List? fields; Color? color; @@ -79,6 +95,7 @@ class MessageEmbed { this.timestamp, this.footer, this.image, + this.thumbnail, this.author, this.fields, this.color, @@ -104,6 +121,11 @@ class MessageEmbed { return this; } + MessageEmbed setThumbnail ({ required String url, String? proxyUrl, int? width, int? height }) { + thumbnail = Thumbnail(url: url, proxyUrl: proxyUrl, width: width, height: height); + return this; + } + MessageEmbed setAuthor ({ required String name, String? url, String? iconUrl, String? proxyIconUrl }) { author = Author(name: name, url: url, iconUrl: iconUrl, proxyIconUrl: proxyIconUrl); return this; @@ -146,6 +168,7 @@ class MessageEmbed { 'fields': fields, 'color': color != null ? int.parse(color.toString().replaceAll('#', ''), radix: 16) : null, 'image': image?.toJson(), + 'thumbnail': thumbnail?.toJson(), }; } } From 9a4ba48027f1c45f87e4653bd47c200d7928e107 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 9 Jul 2022 00:37:39 +0200 Subject: [PATCH 08/68] feat: Implement logs reporter --- lib/console.dart | 14 +++++++++++ lib/src/exceptions/already_exist.dart | 7 ++++++ .../exceptions/empty_parameter_exception.dart | 7 ++++++ .../exceptions/missing_feature_exception.dart | 7 ++++++ .../missing_premium_subscription.dart | 7 ++++++ lib/src/exceptions/not_exist.dart | 7 ++++++ lib/src/exceptions/shard_exception.dart | 7 ++++++ lib/src/exceptions/token_exception.dart | 7 ++++++ lib/src/exceptions/too_many.dart | 7 ++++++ .../internal/entities/reporter_manager.dart | 25 +++++++++++++++++++ lib/src/internal/environment.dart | 2 +- lib/src/internal/event_emitter.dart | 6 ++--- lib/src/internal/ioc.dart | 1 + lib/src/internal/kernel.dart | 13 ++++++++++ 14 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 lib/src/internal/entities/reporter_manager.dart diff --git a/lib/console.dart b/lib/console.dart index 5f98a2c4c..56bdd193d 100644 --- a/lib/console.dart +++ b/lib/console.dart @@ -1,6 +1,7 @@ library console; import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class Console { static void log ({ required String message, String level = "info"}) { @@ -15,6 +16,8 @@ class Console { } static debug ({ String prefix = 'debug', required String message }) { + _report('[ $prefix ] $message'); + String p = ColorList.white(prefix); log(message: "[ $p ] $message", level: "debug"); } @@ -22,19 +25,23 @@ class Console { static info ({ String prefix = 'info', required String message }) { String p = ColorList.blue(prefix); log(message: "[ $p ] $message", level: "info"); + _report('[ $prefix ] $message'); } static success ({ String prefix = 'success', required String message }) { String p = ColorList.green(prefix); log(message: "[ $p ] $message", level: "info"); + _report('[ $prefix ] $message'); } static error ({ String prefix = 'error', required String message }) { log(message: getErrorMessage(prefix: ColorList.red(prefix), message: message), level: "error"); + _report('[ $prefix ] $message'); } static warn ({ String prefix = 'warn', required String message }) { log(message: getWarnMessage(prefix: ColorList.yellow(prefix), message: message), level: "warn"); + _report('[ $prefix ] $message'); } static String getWarnMessage ({ String? prefix = 'warn', required String message }) { @@ -46,6 +53,13 @@ class Console { String p = ColorList.red(prefix!); return "[ $p ] $message"; } + + static _report (String message) { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write(message); + } + } } class ColorList { diff --git a/lib/src/exceptions/already_exist.dart b/lib/src/exceptions/already_exist.dart index a74657756..e94199198 100644 --- a/lib/src/exceptions/already_exist.dart +++ b/lib/src/exceptions/already_exist.dart @@ -1,4 +1,6 @@ import 'package:mineral/console.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class AlreadyExist implements Exception { String? prefix; @@ -7,6 +9,11 @@ class AlreadyExist implements Exception { @override String toString () { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write('[ $prefix ] $cause'); + } + return Console.getErrorMessage(prefix: prefix, message: cause); } } diff --git a/lib/src/exceptions/empty_parameter_exception.dart b/lib/src/exceptions/empty_parameter_exception.dart index 1a590a11a..036b5df85 100644 --- a/lib/src/exceptions/empty_parameter_exception.dart +++ b/lib/src/exceptions/empty_parameter_exception.dart @@ -1,4 +1,6 @@ import 'package:mineral/console.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class EmptyParameterException implements Exception { String prefix = 'INVALID PARAMETER'; @@ -7,6 +9,11 @@ class EmptyParameterException implements Exception { @override String toString () { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write('[ $prefix ] $cause'); + } + return Console.getErrorMessage(prefix: prefix, message: cause); } } diff --git a/lib/src/exceptions/missing_feature_exception.dart b/lib/src/exceptions/missing_feature_exception.dart index 1a3bbffc1..4e7044f83 100644 --- a/lib/src/exceptions/missing_feature_exception.dart +++ b/lib/src/exceptions/missing_feature_exception.dart @@ -1,4 +1,6 @@ import 'package:mineral/console.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class MissingFeatureException implements Exception { String prefix = 'MISSING FEATURE'; @@ -8,6 +10,11 @@ class MissingFeatureException implements Exception { @override String toString () { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write('[ $prefix ] $cause'); + } + return Console.getErrorMessage(prefix: prefix, message: cause); } } diff --git a/lib/src/exceptions/missing_premium_subscription.dart b/lib/src/exceptions/missing_premium_subscription.dart index 759550938..bfc0c06a1 100644 --- a/lib/src/exceptions/missing_premium_subscription.dart +++ b/lib/src/exceptions/missing_premium_subscription.dart @@ -1,4 +1,6 @@ import 'package:mineral/console.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class MissingPremiumSubscription implements Exception { String? prefix; @@ -7,6 +9,11 @@ class MissingPremiumSubscription implements Exception { @override String toString () { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write('[ $prefix ] $cause'); + } + return Console.getErrorMessage(prefix: prefix, message: cause); } } diff --git a/lib/src/exceptions/not_exist.dart b/lib/src/exceptions/not_exist.dart index 342aee1fc..94529815c 100644 --- a/lib/src/exceptions/not_exist.dart +++ b/lib/src/exceptions/not_exist.dart @@ -1,4 +1,6 @@ import 'package:mineral/console.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class NotExist implements Exception { String? prefix; @@ -7,6 +9,11 @@ class NotExist implements Exception { @override String toString () { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write('[ $prefix ] $cause'); + } + return Console.getErrorMessage(prefix: prefix, message: cause); } } diff --git a/lib/src/exceptions/shard_exception.dart b/lib/src/exceptions/shard_exception.dart index 37a2e6123..cf6ba9aae 100644 --- a/lib/src/exceptions/shard_exception.dart +++ b/lib/src/exceptions/shard_exception.dart @@ -1,4 +1,6 @@ import 'package:mineral/console.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class ShardException implements Exception { String? prefix; @@ -7,6 +9,11 @@ class ShardException implements Exception { @override String toString () { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write('[ $prefix ] $cause'); + } + return Console.getErrorMessage(prefix: prefix, message: cause); } } diff --git a/lib/src/exceptions/token_exception.dart b/lib/src/exceptions/token_exception.dart index 9906eef3b..c85e8d196 100644 --- a/lib/src/exceptions/token_exception.dart +++ b/lib/src/exceptions/token_exception.dart @@ -1,4 +1,6 @@ import 'package:mineral/console.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class TokenException implements Exception { String? prefix; @@ -7,6 +9,11 @@ class TokenException implements Exception { @override String toString () { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write('[ $prefix ] $cause'); + } + return Console.getErrorMessage(prefix: prefix, message: cause); } } diff --git a/lib/src/exceptions/too_many.dart b/lib/src/exceptions/too_many.dart index c37f040fc..c768d4f05 100644 --- a/lib/src/exceptions/too_many.dart +++ b/lib/src/exceptions/too_many.dart @@ -1,4 +1,6 @@ import 'package:mineral/console.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; class TooMany implements Exception { String? prefix; @@ -7,6 +9,11 @@ class TooMany implements Exception { @override String toString () { + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + if (reporter != null) { + reporter.write('[ $prefix ] $cause'); + } + return Console.getErrorMessage(prefix: prefix, message: cause); } } diff --git a/lib/src/internal/entities/reporter_manager.dart b/lib/src/internal/entities/reporter_manager.dart new file mode 100644 index 000000000..62afc346d --- /dev/null +++ b/lib/src/internal/entities/reporter_manager.dart @@ -0,0 +1,25 @@ +import 'dart:io'; + +import 'package:path/path.dart'; + +class ReporterManager { + final Directory _reportDirectory; + late File currentFile; + + ReporterManager(this._reportDirectory); + + void write (String message) { + final DateTime now = DateTime.now(); + final String filename = 'log-${now.day}-${now.month}-${now.year}.txt'; + + final file = File(join(_reportDirectory.path, filename)); + final bool fileExist = file.existsSync(); + + if (!fileExist) { + file.createSync(recursive: true); + } + + int timestamp = DateTime.now().millisecondsSinceEpoch; + file.writeAsStringSync('[$timestamp] $message\n', mode: FileMode.writeOnlyAppend); + } +} diff --git a/lib/src/internal/environment.dart b/lib/src/internal/environment.dart index dd6a2340f..9e7715884 100644 --- a/lib/src/internal/environment.dart +++ b/lib/src/internal/environment.dart @@ -22,7 +22,7 @@ class Environment { return this; } - String? get (String key){ + String? get (String key) { return _cache[key]; } diff --git a/lib/src/internal/event_emitter.dart b/lib/src/internal/event_emitter.dart index 62d71403d..1c66b2a78 100644 --- a/lib/src/internal/event_emitter.dart +++ b/lib/src/internal/event_emitter.dart @@ -4,7 +4,7 @@ typedef CallbackMap = Set>; class EventEmitter { final Map> _listeners = >{}; - Future on (String event, EventCallback callback) async { + void on (String event, EventCallback callback) { if (_listeners.containsKey(event)) { _listeners[event]?.add((args) => callback); } else { @@ -17,9 +17,9 @@ class EventEmitter { void emit (String event, Object? args) { if (_listeners.containsKey(event)) { - CallbackMap? Map = _listeners[event]; + CallbackMap? callbacks = _listeners[event]; - Map?.forEach((callback) { + callbacks?.forEach((callback) { callback.call(args as T); }); } diff --git a/lib/src/internal/ioc.dart b/lib/src/internal/ioc.dart index a3470507e..4c223a7b9 100644 --- a/lib/src/internal/ioc.dart +++ b/lib/src/internal/ioc.dart @@ -8,6 +8,7 @@ class Service { final modules = 'Mineral/Core/Modules'; final cli = 'Mineral/Core/Cli'; final shards = 'Mineral/Core/Shards'; + final reporter = 'Mineral/Core/Reporter'; } class Ioc { diff --git a/lib/src/internal/kernel.dart b/lib/src/internal/kernel.dart index 7158be4a9..5170f5267 100644 --- a/lib/src/internal/kernel.dart +++ b/lib/src/internal/kernel.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:mineral/api.dart'; import 'package:mineral/exception.dart'; import 'package:mineral/src/commands/create_project.dart'; @@ -10,7 +12,9 @@ import 'package:mineral/src/internal/entities/command_manager.dart'; import 'package:mineral/src/internal/entities/event_manager.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/internal/entities/module_manager.dart'; +import 'package:mineral/src/internal/entities/reporter_manager.dart'; import 'package:mineral/src/internal/websockets/sharding/shard_manager.dart'; +import 'package:path/path.dart'; import 'entities/store_manager.dart'; @@ -45,6 +49,15 @@ class Kernel { http.defineHeader(header: 'Content-Type', value: 'application/json'); ioc.bind(namespace: ioc.services.http, service: http); + String? report = environment.get('REPORTER'); + if (report?.toLowerCase() == 'true') { + ReporterManager reportManager = ReporterManager(Directory(join(Directory.current.path, 'logs'))); + ioc.bind( + namespace: ioc.services.reporter, + service: reportManager + ); + } + String? token = environment.get('APP_TOKEN'); if (token == null) { throw TokenException( From f5672daac1a6c4f64b28dcc8c64d96751d33c7ec Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 9 Jul 2022 00:55:13 +0200 Subject: [PATCH 09/68] fix: Reporter condition --- lib/console.dart | 26 +++++++++++-------- .../internal/entities/reporter_manager.dart | 1 + lib/src/internal/kernel.dart | 8 +++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/console.dart b/lib/console.dart index 56bdd193d..86cb39428 100644 --- a/lib/console.dart +++ b/lib/console.dart @@ -4,54 +4,58 @@ import 'package:mineral/core.dart'; import 'package:mineral/src/internal/entities/reporter_manager.dart'; class Console { - static void log ({ required String message, String level = "info"}) { - if(level == "debug") { + static void log ({ required String message, String level = 'info'}) { + if (level == 'debug') { final Environment environment = ioc.singleton(ioc.services.environment); final String? logLevel = environment.get('LOG_LEVEL'); - if (logLevel != "debug") return; + if (logLevel != 'debug') return; } print(message); } static debug ({ String prefix = 'debug', required String message }) { - _report('[ $prefix ] $message'); + ReporterManager? reporter = ioc.singleton(ioc.services.reporter); + + if (reporter != null && reporter.reportLevel == 'debug') { + _report('[ $prefix ] $message'); + } String p = ColorList.white(prefix); - log(message: "[ $p ] $message", level: "debug"); + log(message: '[ $p ] $message', level: 'debug'); } static info ({ String prefix = 'info', required String message }) { String p = ColorList.blue(prefix); - log(message: "[ $p ] $message", level: "info"); + log(message: '[ $p ] $message', level: 'info'); _report('[ $prefix ] $message'); } static success ({ String prefix = 'success', required String message }) { String p = ColorList.green(prefix); - log(message: "[ $p ] $message", level: "info"); + log(message: '[ $p ] $message', level: 'info'); _report('[ $prefix ] $message'); } static error ({ String prefix = 'error', required String message }) { - log(message: getErrorMessage(prefix: ColorList.red(prefix), message: message), level: "error"); + log(message: getErrorMessage(prefix: ColorList.red(prefix), message: message), level: 'error'); _report('[ $prefix ] $message'); } static warn ({ String prefix = 'warn', required String message }) { - log(message: getWarnMessage(prefix: ColorList.yellow(prefix), message: message), level: "warn"); + log(message: getWarnMessage(prefix: ColorList.yellow(prefix), message: message), level: 'warn'); _report('[ $prefix ] $message'); } static String getWarnMessage ({ String? prefix = 'warn', required String message }) { String p = ColorList.yellow(prefix!); - return "[ $p ] $message"; + return '[ $p ] $message'; } static String getErrorMessage ({ String? prefix = 'error', required String message }) { String p = ColorList.red(prefix!); - return "[ $p ] $message"; + return '[ $p ] $message'; } static _report (String message) { diff --git a/lib/src/internal/entities/reporter_manager.dart b/lib/src/internal/entities/reporter_manager.dart index 62afc346d..00ef2c9fa 100644 --- a/lib/src/internal/entities/reporter_manager.dart +++ b/lib/src/internal/entities/reporter_manager.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:path/path.dart'; class ReporterManager { + late String reportLevel = 'info'; final Directory _reportDirectory; late File currentFile; diff --git a/lib/src/internal/kernel.dart b/lib/src/internal/kernel.dart index 5170f5267..1e9127a3a 100644 --- a/lib/src/internal/kernel.dart +++ b/lib/src/internal/kernel.dart @@ -50,11 +50,13 @@ class Kernel { ioc.bind(namespace: ioc.services.http, service: http); String? report = environment.get('REPORTER'); - if (report?.toLowerCase() == 'true') { - ReporterManager reportManager = ReporterManager(Directory(join(Directory.current.path, 'logs'))); + if (report != null) { + ReporterManager reporter = ReporterManager(Directory(join(Directory.current.path, 'logs'))); + reporter.reportLevel = report; + ioc.bind( namespace: ioc.services.reporter, - service: reportManager + service: reporter ); } From 74301c5d2d1a160441b3e99ab8b557dbf8c6e434 Mon Sep 17 00:00:00 2001 From: Vic256 Date: Sat, 9 Jul 2022 00:40:24 +0200 Subject: [PATCH 10/68] feat: implements voice state management --- lib/src/api/guilds/guild_member.dart | 7 +- lib/src/api/managers/member_manager.dart | 26 ++-- lib/src/api/managers/voice_manager.dart | 77 ++++++++++ lib/src/constants.dart | 2 + lib/src/internal/entities/event_manager.dart | 13 +- .../websockets/packets/guild_create.dart | 20 ++- .../websockets/packets/guild_member_add.dart | 9 +- .../packets/guild_member_update.dart | 13 +- .../packets/voice_state_update.dart | 135 ++++++++++++++++++ .../websockets/websocket_dispatcher.dart | 2 + 10 files changed, 285 insertions(+), 19 deletions(-) create mode 100644 lib/src/api/managers/voice_manager.dart create mode 100644 lib/src/internal/websockets/packets/voice_state_update.dart diff --git a/lib/src/api/guilds/guild_member.dart b/lib/src/api/guilds/guild_member.dart index 46bfbb05f..e9c9c7cc8 100644 --- a/lib/src/api/guilds/guild_member.dart +++ b/lib/src/api/guilds/guild_member.dart @@ -2,6 +2,7 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/guilds/guild_role_manager.dart'; +import 'package:mineral/src/api/managers/voice_manager.dart'; class GuildMember { User user; @@ -13,7 +14,7 @@ class GuildMember { bool isPending; DateTime? timeoutDuration; MemberRoleManager roles; - Voice voice; + late VoiceManager voice; late Guild guild; GuildMember({ @@ -97,7 +98,7 @@ class GuildMember { ..roles = roles; } - factory GuildMember.from({ required user, required GuildRoleManager roles, dynamic member, required Snowflake guildId }) { + factory GuildMember.from({ required user, required GuildRoleManager roles, dynamic member, required Snowflake guildId, required VoiceManager voice }) { MemberRoleManager memberRoleManager = MemberRoleManager(manager: roles, memberId: user.id); for (var element in (member['roles'] as List)) { Role? role = roles.cache.get(element); @@ -116,7 +117,7 @@ class GuildMember { isPending: member['pending'] == true, timeoutDuration: member['communication_disabled_until'] != null ? DateTime.parse(member['communication_disabled_until']) : null, roles: memberRoleManager, - voice: Voice.from(payload: member), + voice: voice, ); } } diff --git a/lib/src/api/managers/member_manager.dart b/lib/src/api/managers/member_manager.dart index ca6e34643..e013a468f 100644 --- a/lib/src/api/managers/member_manager.dart +++ b/lib/src/api/managers/member_manager.dart @@ -4,6 +4,7 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/cache_manager.dart'; +import 'package:mineral/src/api/managers/voice_manager.dart'; class MemberManager implements CacheManager { @override @@ -17,19 +18,26 @@ class MemberManager implements CacheManager { @override Future> sync () async { Http http = ioc.singleton(ioc.services.http); - cache.clear(); Response response = await http.get(url: "/guilds/$guildId/members"); - dynamic payload = jsonDecode(response.body); + if(response.statusCode == 200) { + dynamic payload = jsonDecode(response.body); + final Map voiceStateCache = cache.map((key, value) => MapEntry(key, value.voice)); - for(dynamic element in payload) { - GuildMember guildMember = GuildMember.from( - user: User.from(element['user']), - roles: guild.roles, - guildId: guild.id - ); + cache.clear(); - cache.putIfAbsent(guildMember.user.id, () => guildMember); + for(dynamic element in payload) { + VoiceManager? voiceManager = voiceStateCache.get(element['user']['id']); + + GuildMember guildMember = GuildMember.from( + user: User.from(element['user']), + roles: guild.roles, + guildId: guild.id, + voice: voiceManager ?? VoiceManager(isMute: element['mute'], isDeaf: element['deaf'], isSelfMute: false, isSelfDeaf: false, hasVideo: false, hasStream: false, channel: null) + ); + + cache.putIfAbsent(guildMember.user.id, () => guildMember); + } } return cache; diff --git a/lib/src/api/managers/voice_manager.dart b/lib/src/api/managers/voice_manager.dart new file mode 100644 index 000000000..8f9c28857 --- /dev/null +++ b/lib/src/api/managers/voice_manager.dart @@ -0,0 +1,77 @@ +import 'package:http/http.dart'; +import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; + +class VoiceManager { + late final GuildMember member; + bool isDeaf; + bool isMute; + bool isSelfMute; + bool isSelfDeaf; + bool hasVideo; + bool? hasStream; + VoiceChannel? channel; + + VoiceManager({ + required this.isMute, + required this.isDeaf, + required this.isSelfMute, + required this.isSelfDeaf, + required this.hasVideo, + required this.hasStream, + required this.channel + }); + + Future setMute(bool value) async { + final Http http = ioc.singleton(ioc.services.http); + final Response response = await http.patch( + url: '/guilds/${member.guild.id}/${member.user.id}', + payload: {'mute': value} + ); + + if (response.statusCode == 200) { + isMute = value; + } + } + + Future setDeaf(bool value) async { + final Http http = ioc.singleton(ioc.services.http); + final Response response = await http.patch( + url: '/guilds/${member.guild.id}/${member.user.id}', + payload: {'deaf': value} + ); + + if (response.statusCode == 200) { + isDeaf = value; + } + } + + Future move(Snowflake channelId) async { + final Http http = ioc.singleton(ioc.services.http); + final Response response = await http.patch( + url: '/guilds/${member.guild.id}/${member.user.id}', + payload: {'channel_id': channelId} + ); + + if (response.statusCode == 200) { + final VoiceChannel? channel = member.guild.channels.cache.get(channelId); + if (channel != null) { + this.channel = channel; + } + } + } + + factory VoiceManager.from(dynamic payload, VoiceChannel? channel) { + return VoiceManager( + isMute: payload['mute'], + isDeaf: payload['deaf'], + isSelfMute: payload['self_mute'], + isSelfDeaf: payload['self_deaf'], + hasVideo: payload['self_video'], + hasStream: payload['self_stream'], + channel: channel + ); + } + + +} \ No newline at end of file diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 8c9514008..eafa93af3 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -53,6 +53,8 @@ enum PacketType { memberJoinRequest('GUILD_JOIN_REQUEST_UPDATE'), + voiceStateUpdate('VOICE_STATE_UPDATE'), + resumed('RESUMED'); final String _value; diff --git a/lib/src/internal/entities/event_manager.dart b/lib/src/internal/entities/event_manager.dart index b93e1e623..2156d3808 100644 --- a/lib/src/internal/entities/event_manager.dart +++ b/lib/src/internal/entities/event_manager.dart @@ -92,7 +92,18 @@ enum Events { commandCreate('create::commandInteraction', { 'interaction': CommandInteraction }), buttonCreate('create::buttonInteraction', { 'interaction': ButtonInteraction }), modalCreate('create::modalInteraction', { 'interaction': ModalInteraction }), - selectMenuCreate('create::selectMenuInteraction', { 'interaction': SelectMenuInteraction }); + selectMenuCreate('create::selectMenuInteraction', { 'interaction': SelectMenuInteraction }), + + voiceConnect('connect::voice', { 'member': GuildMember }), + voiceDisconnect('disconnect::voice', { 'member': GuildMember }), + memberMuted('mute::voice', { 'member': GuildMember }), + memberUnMuted('unmute::voice', { 'member': GuildMember }), + memberDeaf('deaf::voice', { 'member': GuildMember }), + memberUnDeaf('undeaf::voice', { 'member': GuildMember }), + memberSelfMuted('self::mute::voice', { 'member': GuildMember }), + memberSelfUnMuted('self::unmute::voice', { 'member': GuildMember }), + memberSelfDeaf('self::deaf::voice', { 'member': GuildMember }), + memberSelfUnDeaf('self::undeaf::voice', { 'member': GuildMember }); final String event; final Map params; diff --git a/lib/src/internal/websockets/packets/guild_create.dart b/lib/src/internal/websockets/packets/guild_create.dart index 3faedd742..236acf373 100644 --- a/lib/src/internal/websockets/packets/guild_create.dart +++ b/lib/src/internal/websockets/packets/guild_create.dart @@ -11,6 +11,7 @@ import 'package:mineral/src/api/managers/emoji_manager.dart'; import 'package:mineral/src/api/managers/guild_scheduled_event_manager.dart'; import 'package:mineral/src/api/managers/member_manager.dart'; import 'package:mineral/src/api/managers/moderation_rule_manager.dart'; +import 'package:mineral/src/api/managers/voice_manager.dart'; import 'package:mineral/src/api/managers/webhook_manager.dart'; import 'package:mineral/src/internal/entities/command_manager.dart'; import 'package:mineral/src/internal/entities/event_manager.dart'; @@ -32,6 +33,13 @@ class GuildCreate implements WebsocketPacket { Role role = Role.from(roleManager: roleManager, payload: item); roleManager.cache.putIfAbsent(role.id, () => role); } + + Map voices = {}; + for(dynamic voiceMember in websocketResponse.payload['voice_states']) { + final VoiceManager voiceManager = VoiceManager.from(voiceMember, null); + voices.putIfAbsent(voiceMember['user_id'], () => voiceManager); + voices.putIfAbsent(voiceMember['channel_id'], () => voiceManager); + } MemberManager memberManager = MemberManager(guildId: websocketResponse.payload['id']); for (dynamic member in websocketResponse.payload['members']) { @@ -41,7 +49,10 @@ class GuildCreate implements WebsocketPacket { roles: roleManager, user: user, member: member, - guildId: websocketResponse.payload['id'] + guildId: websocketResponse.payload['id'], + voice: voices.containsKey(user.id) + ? voices.get(user.id)! + : VoiceManager(isMute: member['mute'], isDeaf: member['deaf'], isSelfMute: false, isSelfDeaf: false, hasVideo: false, hasStream: false, channel: null) ); memberManager.cache.putIfAbsent(guildMember.user.id, () => guildMember); @@ -100,7 +111,6 @@ class GuildCreate implements WebsocketPacket { guild.members.cache.forEach((Snowflake id, GuildMember member) { member.guild = guild; member.voice.member = member; - member.voice.channel = guild.channels.cache.get(member.voice.channelId); }); // Assign guild channels @@ -110,6 +120,12 @@ class GuildCreate implements WebsocketPacket { channel.guild = guild; channel.parent = channel.parentId != null ? guild.channels.cache.get(channel.parentId) : null; channel.webhooks.guild = guild; + + print(id); + print(voices.containsKey(id)); + if(voices.containsKey(id)) { + voices.get(id)!.channel = channel as VoiceChannel; + } }); moderationManager.guild = guild; diff --git a/lib/src/internal/websockets/packets/guild_member_add.dart b/lib/src/internal/websockets/packets/guild_member_add.dart index 6a094dd58..4502ac1ab 100644 --- a/lib/src/internal/websockets/packets/guild_member_add.dart +++ b/lib/src/internal/websockets/packets/guild_member_add.dart @@ -1,5 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; +import 'package:mineral/src/api/managers/voice_manager.dart'; import 'package:mineral/src/internal/entities/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; @@ -19,7 +20,13 @@ class GuildMemberAdd implements WebsocketPacket { if(guild != null) { User user = User.from(payload['user']); - GuildMember member = GuildMember.from(user: user, roles: guild.roles, member: payload, guildId: guild.id); + GuildMember member = GuildMember.from( + user: user, + roles: guild.roles, + member: payload, + guildId: guild.id, + voice: VoiceManager(isMute: payload['mute'], isDeaf: payload['deaf'], isSelfMute: false, isSelfDeaf: false, hasVideo: false, hasStream: false, channel: null) + ); member.guild = guild; guild.members.cache.putIfAbsent(member.user.id, () => member); diff --git a/lib/src/internal/websockets/packets/guild_member_update.dart b/lib/src/internal/websockets/packets/guild_member_update.dart index 2c92b8e58..1c3b168d6 100644 --- a/lib/src/internal/websockets/packets/guild_member_update.dart +++ b/lib/src/internal/websockets/packets/guild_member_update.dart @@ -1,5 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; +import 'package:mineral/src/api/managers/voice_manager.dart'; import 'package:mineral/src/internal/entities/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; @@ -20,11 +21,17 @@ class GuildMemberUpdate implements WebsocketPacket { GuildMember? before = guild.members.cache.get(payload['user']['id']); User user = User.from(payload['user']); - GuildMember after = GuildMember.from(user: user, roles: guild.roles, guildId: guild.id, member: payload); + GuildMember after = GuildMember.from( + user: user, + roles: guild.roles, + member: payload, + guildId: guild.id, + voice: VoiceManager(isMute: payload['mute'], isDeaf: payload['deaf'], isSelfMute: false, isSelfDeaf: false, hasVideo: false, hasStream: false, channel: null) + ); after.guild = guild; - after.voice.member = after; - after.voice.channel = guild.channels.cache.get(after.voice.channelId); + //after.voice.member = after; + //after.voice.channel = guild.channels.cache.get(after.voice.channelId); manager.emit( event: Events.memberUpdate, diff --git a/lib/src/internal/websockets/packets/voice_state_update.dart b/lib/src/internal/websockets/packets/voice_state_update.dart new file mode 100644 index 000000000..de125c728 --- /dev/null +++ b/lib/src/internal/websockets/packets/voice_state_update.dart @@ -0,0 +1,135 @@ +import 'dart:convert'; + +import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/api/managers/voice_manager.dart'; +import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/event_emitter.dart'; +import 'package:mineral/src/internal/websockets/websocket_packet.dart'; +import 'package:mineral/src/internal/websockets/websocket_response.dart'; + +class VoiceStateUpdate implements WebsocketPacket { + @override + PacketType packetType = PacketType.voiceStateUpdate; + + @override + Future handle(WebsocketResponse websocketResponse) async { + EventManager manager = ioc.singleton(ioc.services.event); + MineralClient client = ioc.singleton(ioc.services.client); + + dynamic payload = websocketResponse.payload; + + Guild? guild = client.guilds.cache.get(payload['guild_id']); + GuildMember? member = guild?.members.cache.get(payload['user_id']); + VoiceChannel? voiceChannel = guild?.channels.cache.get(payload['channel_id']); + if (guild != null && member != null) { + VoiceManager before = member.voice; + VoiceManager after = VoiceManager.from(payload, voiceChannel); + + member.voice = after; + + //User move + if(before.channel != null && after.channel != null && before.channel != after.channel) { + print('USER MOVE'); + manager.emit( + event: Events.voiceDisconnect, + params: [member] + ); + manager.emit( + event: Events.voiceConnect, + params: [member] + ); + } + + //User connect + if(before.channel == null && after.channel != null) { + print('USER CONNECT'); + manager.emit( + event: Events.voiceConnect, + params: [member] + ); + } + + //User leave + if(before.channel != null && after.channel == null) { + print('USER LEAVE'); + manager.emit( + event: Events.voiceDisconnect, + params: [member] + ); + } + + //User muted + if(!before.isMute && after.isMute) { + print('USER MUTE'); + manager.emit( + event: Events.memberMuted, + params: [member] + ); + } + + //User unmute + if(before.isMute && !after.isMute) { + print('USER UNMUTE'); + manager.emit( + event: Events.memberUnMuted, + params: [member] + ); + } + + //User undeaf + if(before.isDeaf && !after.isDeaf) { + print('USER UNDEAF'); + manager.emit( + event: Events.memberUnDeaf, + params: [member] + ); + } + + //User deaf + if(!before.isDeaf && after.isDeaf) { + print('USER DEAF'); + manager.emit( + event: Events.memberDeaf, + params: [member] + ); + } + + //User selfUnMute + if(before.isSelfMute && !after.isSelfMute) { + print('USER UNSELFMUTE'); + manager.emit( + event: Events.memberSelfUnMuted, + params: [member] + ); + } + + //User selfMute + if(!before.isSelfMute && after.isSelfMute) { + print('USER SELFMUTE'); + manager.emit( + event: Events.memberSelfMuted, + params: [member] + ); + } + + //User selfUnDeaf + if(before.isSelfDeaf && !after.isSelfDeaf) { + print('USER UNSELFDEAF'); + manager.emit( + event: Events.memberSelfUnDeaf, + params: [member] + ); + } + + //User selfDeaf + if(!before.isSelfDeaf && after.isSelfDeaf) { + print('USER SELFDEAF'); + manager.emit( + event: Events.memberSelfDeaf, + params: [member] + ); + } + } + } +} diff --git a/lib/src/internal/websockets/websocket_dispatcher.dart b/lib/src/internal/websockets/websocket_dispatcher.dart index 089159e17..452e50209 100644 --- a/lib/src/internal/websockets/websocket_dispatcher.dart +++ b/lib/src/internal/websockets/websocket_dispatcher.dart @@ -24,6 +24,7 @@ import 'package:mineral/src/internal/websockets/packets/message_update.dart'; import 'package:mineral/src/internal/websockets/packets/presence_update.dart'; import 'package:mineral/src/internal/websockets/packets/ready.dart'; import 'package:mineral/src/internal/websockets/packets/resumed.dart'; +import 'package:mineral/src/internal/websockets/packets/voice_state_update.dart'; import 'package:mineral/src/internal/websockets/packets/webhook_update.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; @@ -59,6 +60,7 @@ class WebsocketDispatcher { register(PacketType.guildScheduledEventUserRemove, GuildScheduledEventUserRemove()); register(PacketType.webhookUpdate, WebhookUpdate()); register(PacketType.guildIntegrationsUpdate, GuildIntegrationsUpdate()); + register(PacketType.voiceStateUpdate, VoiceStateUpdate()); } void register (PacketType type, WebsocketPacket packet) { From 123e8642ef923a1cca2472295df861e0d48346de Mon Sep 17 00:00:00 2001 From: Vic256 Date: Sat, 9 Jul 2022 01:05:07 +0200 Subject: [PATCH 11/68] feat: implement global voice update event --- lib/src/internal/entities/event_manager.dart | 2 ++ .../packets/voice_state_update.dart | 31 ++++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/src/internal/entities/event_manager.dart b/lib/src/internal/entities/event_manager.dart index 2156d3808..16b9f9a7f 100644 --- a/lib/src/internal/entities/event_manager.dart +++ b/lib/src/internal/entities/event_manager.dart @@ -1,6 +1,7 @@ import 'dart:mirrors'; import 'package:mineral/api.dart'; +import 'package:mineral/src/api/managers/voice_manager.dart'; import 'package:mineral/src/internal/entities/store_manager.dart'; class EventManager { @@ -94,6 +95,7 @@ enum Events { modalCreate('create::modalInteraction', { 'interaction': ModalInteraction }), selectMenuCreate('create::selectMenuInteraction', { 'interaction': SelectMenuInteraction }), + voiceStateUpdate('update::voice', { 'before': VoiceManager, 'after': VoiceManager }), voiceConnect('connect::voice', { 'member': GuildMember }), voiceDisconnect('disconnect::voice', { 'member': GuildMember }), memberMuted('mute::voice', { 'member': GuildMember }), diff --git a/lib/src/internal/websockets/packets/voice_state_update.dart b/lib/src/internal/websockets/packets/voice_state_update.dart index de125c728..d19c1f605 100644 --- a/lib/src/internal/websockets/packets/voice_state_update.dart +++ b/lib/src/internal/websockets/packets/voice_state_update.dart @@ -28,40 +28,42 @@ class VoiceStateUpdate implements WebsocketPacket { member.voice = after; + manager.emit( + event: Events.voiceStateUpdate, + params: [before, after] + ); + //User move if(before.channel != null && after.channel != null && before.channel != after.channel) { - print('USER MOVE'); manager.emit( - event: Events.voiceDisconnect, - params: [member] + event: Events.voiceDisconnect, + params: [before] ); + manager.emit( - event: Events.voiceConnect, - params: [member] + event: Events.voiceConnect, + params: [member, before.channel, after.channel] ); } //User connect if(before.channel == null && after.channel != null) { - print('USER CONNECT'); manager.emit( - event: Events.voiceConnect, - params: [member] + event: Events.voiceConnect, + params: [member, before.channel, after.channel] ); } //User leave if(before.channel != null && after.channel == null) { - print('USER LEAVE'); manager.emit( event: Events.voiceDisconnect, - params: [member] + params: [before] ); } //User muted if(!before.isMute && after.isMute) { - print('USER MUTE'); manager.emit( event: Events.memberMuted, params: [member] @@ -70,7 +72,6 @@ class VoiceStateUpdate implements WebsocketPacket { //User unmute if(before.isMute && !after.isMute) { - print('USER UNMUTE'); manager.emit( event: Events.memberUnMuted, params: [member] @@ -79,7 +80,6 @@ class VoiceStateUpdate implements WebsocketPacket { //User undeaf if(before.isDeaf && !after.isDeaf) { - print('USER UNDEAF'); manager.emit( event: Events.memberUnDeaf, params: [member] @@ -88,7 +88,6 @@ class VoiceStateUpdate implements WebsocketPacket { //User deaf if(!before.isDeaf && after.isDeaf) { - print('USER DEAF'); manager.emit( event: Events.memberDeaf, params: [member] @@ -97,7 +96,6 @@ class VoiceStateUpdate implements WebsocketPacket { //User selfUnMute if(before.isSelfMute && !after.isSelfMute) { - print('USER UNSELFMUTE'); manager.emit( event: Events.memberSelfUnMuted, params: [member] @@ -106,7 +104,6 @@ class VoiceStateUpdate implements WebsocketPacket { //User selfMute if(!before.isSelfMute && after.isSelfMute) { - print('USER SELFMUTE'); manager.emit( event: Events.memberSelfMuted, params: [member] @@ -115,7 +112,6 @@ class VoiceStateUpdate implements WebsocketPacket { //User selfUnDeaf if(before.isSelfDeaf && !after.isSelfDeaf) { - print('USER UNSELFDEAF'); manager.emit( event: Events.memberSelfUnDeaf, params: [member] @@ -124,7 +120,6 @@ class VoiceStateUpdate implements WebsocketPacket { //User selfDeaf if(!before.isSelfDeaf && after.isSelfDeaf) { - print('USER SELFDEAF'); manager.emit( event: Events.memberSelfDeaf, params: [member] From de8cb88ce51cab9afc364d336e335625da5b10f8 Mon Sep 17 00:00:00 2001 From: Vic256 Date: Sat, 9 Jul 2022 01:40:52 +0200 Subject: [PATCH 12/68] feat: implement custom_id on voice connect --- lib/src/internal/entities/event_manager.dart | 4 +-- .../websockets/packets/guild_create.dart | 2 -- .../packets/voice_state_update.dart | 34 +++++++++---------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/src/internal/entities/event_manager.dart b/lib/src/internal/entities/event_manager.dart index 16b9f9a7f..05784fc58 100644 --- a/lib/src/internal/entities/event_manager.dart +++ b/lib/src/internal/entities/event_manager.dart @@ -96,8 +96,8 @@ enum Events { selectMenuCreate('create::selectMenuInteraction', { 'interaction': SelectMenuInteraction }), voiceStateUpdate('update::voice', { 'before': VoiceManager, 'after': VoiceManager }), - voiceConnect('connect::voice', { 'member': GuildMember }), - voiceDisconnect('disconnect::voice', { 'member': GuildMember }), + voiceConnect('connect::voice', { 'member': GuildMember, 'before': 'VoiceChannel?', 'after': VoiceChannel }), + voiceDisconnect('disconnect::voice', { 'member': GuildMember, 'channel': VoiceChannel }), memberMuted('mute::voice', { 'member': GuildMember }), memberUnMuted('unmute::voice', { 'member': GuildMember }), memberDeaf('deaf::voice', { 'member': GuildMember }), diff --git a/lib/src/internal/websockets/packets/guild_create.dart b/lib/src/internal/websockets/packets/guild_create.dart index 236acf373..1418a5208 100644 --- a/lib/src/internal/websockets/packets/guild_create.dart +++ b/lib/src/internal/websockets/packets/guild_create.dart @@ -121,8 +121,6 @@ class GuildCreate implements WebsocketPacket { channel.parent = channel.parentId != null ? guild.channels.cache.get(channel.parentId) : null; channel.webhooks.guild = guild; - print(id); - print(voices.containsKey(id)); if(voices.containsKey(id)) { voices.get(id)!.channel = channel as VoiceChannel; } diff --git a/lib/src/internal/websockets/packets/voice_state_update.dart b/lib/src/internal/websockets/packets/voice_state_update.dart index d19c1f605..090365fab 100644 --- a/lib/src/internal/websockets/packets/voice_state_update.dart +++ b/lib/src/internal/websockets/packets/voice_state_update.dart @@ -35,31 +35,18 @@ class VoiceStateUpdate implements WebsocketPacket { //User move if(before.channel != null && after.channel != null && before.channel != after.channel) { - manager.emit( - event: Events.voiceDisconnect, - params: [before] - ); - - manager.emit( - event: Events.voiceConnect, - params: [member, before.channel, after.channel] - ); + _emitEvent(manager, Events.voiceDisconnect, [member, before.channel], before.channel!.id); + _emitEvent(manager, Events.voiceConnect, [member, before.channel, after.channel], after.channel!.id); } //User connect if(before.channel == null && after.channel != null) { - manager.emit( - event: Events.voiceConnect, - params: [member, before.channel, after.channel] - ); + _emitEvent(manager, Events.voiceConnect, [member, before.channel, after.channel], after.channel!.id); } //User leave if(before.channel != null && after.channel == null) { - manager.emit( - event: Events.voiceDisconnect, - params: [before] - ); + _emitEvent(manager, Events.voiceDisconnect, [member, before.channel], before.channel!.id); } //User muted @@ -127,4 +114,17 @@ class VoiceStateUpdate implements WebsocketPacket { } } } + + _emitEvent(EventManager manager, Events event, dynamic params, Snowflake customId) { + manager.emit( + event: event, + params: params, + ); + + manager.emit( + event: event, + params: params, + customId: customId + ); + } } From ebe09cb40952d6a932cc416dd2989c6641a8d794 Mon Sep 17 00:00:00 2001 From: Vic256 Date: Sun, 10 Jul 2022 21:49:34 +0200 Subject: [PATCH 13/68] fix: change url and discord return status code --- lib/src/api/managers/voice_manager.dart | 8 ++++---- .../internal/websockets/packets/guild_member_update.dart | 7 ++++++- .../internal/websockets/packets/voice_state_update.dart | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/src/api/managers/voice_manager.dart b/lib/src/api/managers/voice_manager.dart index 8f9c28857..9a82ce034 100644 --- a/lib/src/api/managers/voice_manager.dart +++ b/lib/src/api/managers/voice_manager.dart @@ -25,11 +25,11 @@ class VoiceManager { Future setMute(bool value) async { final Http http = ioc.singleton(ioc.services.http); final Response response = await http.patch( - url: '/guilds/${member.guild.id}/${member.user.id}', + url: '/guilds/${member.guild.id}/members/${member.user.id}', payload: {'mute': value} ); - if (response.statusCode == 200) { + if (response.statusCode == 204 || response.statusCode == 200) { isMute = value; } } @@ -37,11 +37,11 @@ class VoiceManager { Future setDeaf(bool value) async { final Http http = ioc.singleton(ioc.services.http); final Response response = await http.patch( - url: '/guilds/${member.guild.id}/${member.user.id}', + url: '/guilds/${member.guild.id}/members/${member.user.id}', payload: {'deaf': value} ); - if (response.statusCode == 200) { + if (response.statusCode == 204 || response.statusCode == 200) { isDeaf = value; } } diff --git a/lib/src/internal/websockets/packets/guild_member_update.dart b/lib/src/internal/websockets/packets/guild_member_update.dart index 1c3b168d6..b47b76b90 100644 --- a/lib/src/internal/websockets/packets/guild_member_update.dart +++ b/lib/src/internal/websockets/packets/guild_member_update.dart @@ -20,16 +20,21 @@ class GuildMemberUpdate implements WebsocketPacket { if (guild != null) { GuildMember? before = guild.members.cache.get(payload['user']['id']); + VoiceManager voice = before != null + ? before.voice + : VoiceManager(isMute: payload['mute'], isDeaf: payload['deaf'], isSelfMute: false, isSelfDeaf: false, hasVideo: false, hasStream: false, channel: null); + User user = User.from(payload['user']); GuildMember after = GuildMember.from( user: user, roles: guild.roles, member: payload, guildId: guild.id, - voice: VoiceManager(isMute: payload['mute'], isDeaf: payload['deaf'], isSelfMute: false, isSelfDeaf: false, hasVideo: false, hasStream: false, channel: null) + voice: voice ); after.guild = guild; + after.voice.member = after; //after.voice.member = after; //after.voice.channel = guild.channels.cache.get(after.voice.channelId); diff --git a/lib/src/internal/websockets/packets/voice_state_update.dart b/lib/src/internal/websockets/packets/voice_state_update.dart index 090365fab..ec0d5ca08 100644 --- a/lib/src/internal/websockets/packets/voice_state_update.dart +++ b/lib/src/internal/websockets/packets/voice_state_update.dart @@ -27,6 +27,7 @@ class VoiceStateUpdate implements WebsocketPacket { VoiceManager after = VoiceManager.from(payload, voiceChannel); member.voice = after; + after.member = member; manager.emit( event: Events.voiceStateUpdate, From 3ef8ed442a1a89701ec7aada569b129306d6fd4e Mon Sep 17 00:00:00 2001 From: Vic256 Date: Sun, 10 Jul 2022 22:48:46 +0200 Subject: [PATCH 14/68] refactor: change indentation --- lib/src/internal/websockets/packets/guild_create.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/internal/websockets/packets/guild_create.dart b/lib/src/internal/websockets/packets/guild_create.dart index 1418a5208..c8c34c9a3 100644 --- a/lib/src/internal/websockets/packets/guild_create.dart +++ b/lib/src/internal/websockets/packets/guild_create.dart @@ -52,7 +52,15 @@ class GuildCreate implements WebsocketPacket { guildId: websocketResponse.payload['id'], voice: voices.containsKey(user.id) ? voices.get(user.id)! - : VoiceManager(isMute: member['mute'], isDeaf: member['deaf'], isSelfMute: false, isSelfDeaf: false, hasVideo: false, hasStream: false, channel: null) + : VoiceManager( + isMute: member['mute'], + isDeaf: member['deaf'], + isSelfMute: false, + isSelfDeaf: false, + hasVideo: false, + hasStream: false, + channel: null + ) ); memberManager.cache.putIfAbsent(guildMember.user.id, () => guildMember); From ccae289228c93ff55b34cf5085e32efcafede8a2 Mon Sep 17 00:00:00 2001 From: Vic256 Date: Sun, 10 Jul 2022 22:57:10 +0200 Subject: [PATCH 15/68] fix: change member update url on move --- lib/src/api/managers/voice_manager.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/api/managers/voice_manager.dart b/lib/src/api/managers/voice_manager.dart index 9a82ce034..243cded49 100644 --- a/lib/src/api/managers/voice_manager.dart +++ b/lib/src/api/managers/voice_manager.dart @@ -49,11 +49,11 @@ class VoiceManager { Future move(Snowflake channelId) async { final Http http = ioc.singleton(ioc.services.http); final Response response = await http.patch( - url: '/guilds/${member.guild.id}/${member.user.id}', + url: '/guilds/${member.guild.id}/members/${member.user.id}', payload: {'channel_id': channelId} ); - if (response.statusCode == 200) { + if (response.statusCode == 204 || response.statusCode == 200) { final VoiceChannel? channel = member.guild.channels.cache.get(channelId); if (channel != null) { this.channel = channel; From a59cb74124370aea8492bef4de0a5656c44ac90a Mon Sep 17 00:00:00 2001 From: Vic256 Date: Mon, 11 Jul 2022 00:47:20 +0200 Subject: [PATCH 16/68] feat: add disconnect --- lib/src/api/managers/voice_manager.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/api/managers/voice_manager.dart b/lib/src/api/managers/voice_manager.dart index 243cded49..e2ff6135b 100644 --- a/lib/src/api/managers/voice_manager.dart +++ b/lib/src/api/managers/voice_manager.dart @@ -24,6 +24,7 @@ class VoiceManager { Future setMute(bool value) async { final Http http = ioc.singleton(ioc.services.http); + final Response response = await http.patch( url: '/guilds/${member.guild.id}/members/${member.user.id}', payload: {'mute': value} @@ -47,6 +48,14 @@ class VoiceManager { } Future move(Snowflake channelId) async { + _updateChannel(channelId); + } + + Future disconnect() async { + _updateChannel(null); + } + + Future _updateChannel(Snowflake? channelId) async { final Http http = ioc.singleton(ioc.services.http); final Response response = await http.patch( url: '/guilds/${member.guild.id}/members/${member.user.id}', From 585195a853b66bdb05d5ba9fcdc5e55d3973b588 Mon Sep 17 00:00:00 2001 From: Vic256 Date: Mon, 11 Jul 2022 01:04:11 +0200 Subject: [PATCH 17/68] feat: add get user method --- .../api/interactions/command_interaction.dart | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/src/api/interactions/command_interaction.dart b/lib/src/api/interactions/command_interaction.dart index 28d2e1b21..16465e103 100644 --- a/lib/src/api/interactions/command_interaction.dart +++ b/lib/src/api/interactions/command_interaction.dart @@ -1,6 +1,7 @@ import 'dart:core'; import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; import 'package:mineral/src/api/interactions/interaction.dart'; class CommandInteraction extends Interaction { @@ -18,35 +19,40 @@ class CommandInteraction extends Interaction { }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); T? getChannel (String optionName) { - return guild?.channels.cache.get(data[optionName]['value']); + return guild?.channels.cache.get(data[optionName]?['value']); } int? getInteger (String optionName) { - return data[optionName]['value']; + return data[optionName]?['value']; } String? getString (String optionName) { - return data[optionName]['value']; + return data[optionName]?['value']; } GuildMember? getMember (String optionName) { - return guild?.members.cache.get(data[optionName]['value']); + return guild?.members.cache.get(data[optionName]?['value']); + } + + User? getUser (String optionName) { + final MineralClient client = ioc.singleton(ioc.services.client); + return client.users.cache.get(data[optionName]?['value']); } bool? getBoolean (String optionName) { - return data[optionName]['value']; + return data[optionName]?['value']; } Role? getRole (String optionName) { - return guild?.roles.cache.get(data[optionName]['value']); + return guild?.roles.cache.get(data[optionName]?['value']); } T? getChoice (String optionName) { - return data[optionName]['value']; + return data[optionName]?['value']; } dynamic getMentionable (String optionName) { - return data[optionName]['value']; + return data[optionName]?['value']; } factory CommandInteraction.from({ required User user, required dynamic payload }) { From fdf03c5320a1adb0614b2f30b160c7355c56c947 Mon Sep 17 00:00:00 2001 From: Vic256 Date: Mon, 11 Jul 2022 01:35:56 +0200 Subject: [PATCH 18/68] fix: Use ChannelType instead of int --- lib/src/api/managers/channel_manager.dart | 7 +++++-- lib/src/internal/websockets/packets/channel_create.dart | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/src/api/managers/channel_manager.dart b/lib/src/api/managers/channel_manager.dart index a096459f2..41df0ae0a 100644 --- a/lib/src/api/managers/channel_manager.dart +++ b/lib/src/api/managers/channel_manager.dart @@ -6,6 +6,8 @@ import 'package:mineral/core.dart'; import 'package:mineral/src/api/channels/channel.dart'; import 'package:mineral/src/api/managers/cache_manager.dart'; +import 'package:collection/collection.dart'; + class ChannelManager implements CacheManager { @override Map cache = {}; @@ -72,8 +74,9 @@ class ChannelManager implements CacheManager { Response response = await http.post(url: "/guilds/$guildId/channels", payload: data); dynamic payload = jsonDecode(response.body); - if (channels.containsKey(payload['type'])) { - Channel Function(dynamic payload) item = channels[payload['type']] as Channel Function(dynamic payload); + final ChannelType? type = ChannelType.values.firstWhereOrNull((element) => element.value == payload['type']); + if (type != null && channels.containsKey(type)) { + Channel Function(dynamic payload) item = channels[type] as Channel Function(dynamic payload); Channel channel = item(payload); // Define deep properties diff --git a/lib/src/internal/websockets/packets/channel_create.dart b/lib/src/internal/websockets/packets/channel_create.dart index 247eaee49..8671aa4cd 100644 --- a/lib/src/internal/websockets/packets/channel_create.dart +++ b/lib/src/internal/websockets/packets/channel_create.dart @@ -5,6 +5,8 @@ import 'package:mineral/src/internal/entities/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; +import 'package:collection/collection.dart'; + class ChannelCreate implements WebsocketPacket { @override PacketType packetType = PacketType.channelCreate; @@ -37,8 +39,9 @@ class ChannelCreate implements WebsocketPacket { } Channel? _dispatch (Guild? guild, dynamic payload) { - if (channels.containsKey(payload['type'])) { - Channel Function(dynamic payload) item = channels[payload['type']] as Channel Function(dynamic payload); + final ChannelType? type = ChannelType.values.firstWhereOrNull((element) => element.value == payload['type']); + if (type != null && channels.containsKey(type)) { + Channel Function(dynamic payload) item = channels[type] as Channel Function(dynamic payload); return item(payload); } return null; From 2ce27fe17f5a2592a5a462e482ed2adf5840e173 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Mon, 11 Jul 2022 14:52:51 +0200 Subject: [PATCH 19/68] feat: Infuse environment into events/commands/stores --- lib/src/internal/entities/command_manager.dart | 2 ++ lib/src/internal/entities/event_manager.dart | 2 ++ lib/src/internal/entities/store_manager.dart | 4 ++++ lib/src/internal/websockets/packets/ready.dart | 14 ++++++++------ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/src/internal/entities/command_manager.dart b/lib/src/internal/entities/command_manager.dart index 9d608a161..1225217d1 100644 --- a/lib/src/internal/entities/command_manager.dart +++ b/lib/src/internal/entities/command_manager.dart @@ -1,6 +1,7 @@ import 'dart:mirrors'; import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; import 'package:mineral/src/internal/entities/store_manager.dart'; class CommandManager { @@ -135,6 +136,7 @@ class CommandManager { class MineralCommand { late MineralClient client; late StoreManager stores; + late Environment environment; } class Command { diff --git a/lib/src/internal/entities/event_manager.dart b/lib/src/internal/entities/event_manager.dart index 05784fc58..051de2a6c 100644 --- a/lib/src/internal/entities/event_manager.dart +++ b/lib/src/internal/entities/event_manager.dart @@ -1,6 +1,7 @@ import 'dart:mirrors'; import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/voice_manager.dart'; import 'package:mineral/src/internal/entities/store_manager.dart'; @@ -58,6 +59,7 @@ class Event { abstract class MineralEvent { late StoreManager stores; late MineralClient client; + late Environment environment; } enum Events { diff --git a/lib/src/internal/entities/store_manager.dart b/lib/src/internal/entities/store_manager.dart index 5e7b310bc..4f2ba5f20 100644 --- a/lib/src/internal/entities/store_manager.dart +++ b/lib/src/internal/entities/store_manager.dart @@ -1,5 +1,6 @@ import 'dart:mirrors'; +import 'package:mineral/core.dart'; import 'package:mineral/src/exceptions/already_exist.dart'; import 'package:mineral/src/exceptions/not_exist.dart'; @@ -12,6 +13,8 @@ class StoreManager { throw AlreadyExist(cause: "A store named $name already exists."); } + store.environment = ioc.singleton(ioc.services.environment); + _stores[name] = store; return this; } @@ -33,5 +36,6 @@ class Store { } abstract class MineralStore { + late Environment environment; late T state; } diff --git a/lib/src/internal/websockets/packets/ready.dart b/lib/src/internal/websockets/packets/ready.dart index 9e25e2d92..28f051f99 100644 --- a/lib/src/internal/websockets/packets/ready.dart +++ b/lib/src/internal/websockets/packets/ready.dart @@ -48,8 +48,10 @@ class Ready implements WebsocketPacket { Map>> events = manager.getRegisteredEvents(); events.forEach((_, events) { for (Map event in events) { - event['mineralEvent'].client = client; - event['mineralEvent'].stores = ioc.singleton(ioc.services.store); + event['mineralEvent'] + ..client = client + ..stores = ioc.singleton(ioc.services.store) + ..environment = ioc.singleton(ioc.services.environment); } }); } @@ -57,10 +59,10 @@ class Ready implements WebsocketPacket { void infuseClientIntoCommands ({required CommandManager manager, required MineralClient client}) { Map commands = manager.getHandlers(); commands.forEach((_, handler) { - MineralCommand command = handler['commandClass']; - - command.client = client; - command.stores = ioc.singleton(ioc.services.store); + handler['commandClass'] + ..client = client + ..stores = ioc.singleton(ioc.services.store) + ..environment = ioc.singleton(ioc.services.environment); }); } } From d031990f52f54d43cdcb5628a0ebc5e8a93cfce2 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Mon, 11 Jul 2022 15:15:06 +0200 Subject: [PATCH 20/68] feat: Add getOrFail method --- lib/src/internal/extensions/collection.dart | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/src/internal/extensions/collection.dart b/lib/src/internal/extensions/collection.dart index 01a615d55..b3b557e21 100644 --- a/lib/src/internal/extensions/collection.dart +++ b/lib/src/internal/extensions/collection.dart @@ -1,5 +1,7 @@ +import 'package:mineral/src/exceptions/not_exist.dart'; + extension Collection on Map { - /// Returns the value associated from the [key] parameter + /// Returns the value associated from the [K] parameter /// ```dart /// Channel? channel = guild.channels.cache.get('991686152585232404'); /// print(channel); @@ -22,4 +24,18 @@ extension Collection on Map { if (this[key] != null) this[key] = ifPresent(); return this[key]; } + + /// Returns the value associated from the [K] parameter + /// ```dart + /// Channel channel = guild.channels.cache.getOrFail('991686152585232404'); + /// print(channel); + /// ``` + T getOrFail (K? key) { + final T? result = get(key); + if (result == null) { + throw NotExist(cause: 'No values are attached to $key key.'); + } + + return result; + } } From af4d19361b425af232516580b8ddb9574988ccf0 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Mon, 11 Jul 2022 15:17:49 +0200 Subject: [PATCH 21/68] feat: Add custom message --- lib/src/internal/extensions/collection.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/internal/extensions/collection.dart b/lib/src/internal/extensions/collection.dart index b3b557e21..8da1624d0 100644 --- a/lib/src/internal/extensions/collection.dart +++ b/lib/src/internal/extensions/collection.dart @@ -30,10 +30,10 @@ extension Collection on Map { /// Channel channel = guild.channels.cache.getOrFail('991686152585232404'); /// print(channel); /// ``` - T getOrFail (K? key) { + T getOrFail (K? key, { String? message }) { final T? result = get(key); if (result == null) { - throw NotExist(cause: 'No values are attached to $key key.'); + throw NotExist(cause: message ?? 'No values are attached to $key key.'); } return result; From 694a36c12c9803604f4b14db23d8be399f233bd2 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Mon, 11 Jul 2022 15:20:18 +0200 Subject: [PATCH 22/68] docs: Write doc --- lib/src/internal/extensions/collection.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/internal/extensions/collection.dart b/lib/src/internal/extensions/collection.dart index 8da1624d0..3c64934c8 100644 --- a/lib/src/internal/extensions/collection.dart +++ b/lib/src/internal/extensions/collection.dart @@ -30,6 +30,11 @@ extension Collection on Map { /// Channel channel = guild.channels.cache.getOrFail('991686152585232404'); /// print(channel); /// ``` + /// You can define an error customized message + /// ```dart + /// Channel channel = guild.channels.cache.getOrFail('991686152585232404', message: 'Channel is undefined'); + /// print(channel); + /// ``` T getOrFail (K? key, { String? message }) { final T? result = get(key); if (result == null) { From a0b11ca7a8ff23805748f14406978a2fa0f68112 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Mon, 11 Jul 2022 15:26:50 +0200 Subject: [PATCH 23/68] feat: Add find method --- lib/src/internal/extensions/collection.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/internal/extensions/collection.dart b/lib/src/internal/extensions/collection.dart index 3c64934c8..e0e23adee 100644 --- a/lib/src/internal/extensions/collection.dart +++ b/lib/src/internal/extensions/collection.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:mineral/src/exceptions/not_exist.dart'; extension Collection on Map { @@ -43,4 +44,14 @@ extension Collection on Map { return result; } + + /// Returns the first element satisfying test, or null if there are none. + /// ```dart + /// Channel? channel = guild.channels.cache.find((channel) => channel.id == '991686152585232404'); + /// print(channel); + /// ``` + T? find (bool Function(MapEntry) callback) { + final MapEntry? result = entries.firstWhereOrNull(callback); + return result?.value as T; + } } From f9a3b8b833066a3027110c8563b5279a56658618 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Mon, 11 Jul 2022 15:30:40 +0200 Subject: [PATCH 24/68] feat: Add findOrFail method --- lib/src/internal/extensions/collection.dart | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/src/internal/extensions/collection.dart b/lib/src/internal/extensions/collection.dart index e0e23adee..d20fc923d 100644 --- a/lib/src/internal/extensions/collection.dart +++ b/lib/src/internal/extensions/collection.dart @@ -54,4 +54,23 @@ extension Collection on Map { final MapEntry? result = entries.firstWhereOrNull(callback); return result?.value as T; } + + /// Returns the first element satisfying test, or throw if there are none. + /// ```dart + /// Channel? channel = guild.channels.cache.find((channel) => channel.id == '991686152585232404'); + /// print(channel); + /// ``` + /// You can define an error customized message + /// ```dart + /// Channel channel = guild.channels.cache.find((channel) => channel.id == '991686152585232404', message: 'Channel is undefined'); + /// print(channel); + /// ``` + T findOrFail (bool Function(MapEntry) callback, { String? message }) { + final V? result = find(callback); + if (result == null) { + throw NotExist(cause: message ?? 'No values were found.'); + } + + return result as T; + } } From bcd26e7b0fac0a33a5e0a7ee1b0bc60c0cffa57b Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Mon, 11 Jul 2022 15:59:46 +0200 Subject: [PATCH 25/68] feat: Work in progress --- lib/console.dart | 2 +- lib/src/internal/extensions/collection.dart | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/console.dart b/lib/console.dart index 86cb39428..077fdb521 100644 --- a/lib/console.dart +++ b/lib/console.dart @@ -68,7 +68,7 @@ class Console { class ColorList { static String black (String text) => '\x1B[30m$text\x1B[0m'; - static String red (String text) => '\x1B[31m$text\x1B[0m'; + static String red (String text) => '\x1B[186m$text\x1B[0m'; static String green (String text) => '\x1B[32m$text\x1B[0m'; static String yellow (String text) => '\x1B[33m$text\x1B[0m'; static String blue (String text) => '\x1B[34m$text\x1B[0m'; diff --git a/lib/src/internal/extensions/collection.dart b/lib/src/internal/extensions/collection.dart index d20fc923d..8c129bea4 100644 --- a/lib/src/internal/extensions/collection.dart +++ b/lib/src/internal/extensions/collection.dart @@ -39,7 +39,7 @@ extension Collection on Map { T getOrFail (K? key, { String? message }) { final T? result = get(key); if (result == null) { - throw NotExist(cause: message ?? 'No values are attached to $key key.'); + throw NotExist(prefix: 'Invalid value', cause: message ?? 'No values are attached to $key key.'); } return result; @@ -50,9 +50,9 @@ extension Collection on Map { /// Channel? channel = guild.channels.cache.find((channel) => channel.id == '991686152585232404'); /// print(channel); /// ``` - T? find (bool Function(MapEntry) callback) { - final MapEntry? result = entries.firstWhereOrNull(callback); - return result?.value as T; + T? find (bool Function(V element) callback) { + final MapEntry? result = entries.firstWhereOrNull((item) => callback(item.value)); + return result?.value as T?; } /// Returns the first element satisfying test, or throw if there are none. @@ -65,10 +65,10 @@ extension Collection on Map { /// Channel channel = guild.channels.cache.find((channel) => channel.id == '991686152585232404', message: 'Channel is undefined'); /// print(channel); /// ``` - T findOrFail (bool Function(MapEntry) callback, { String? message }) { + T findOrFail (bool Function(V element) callback, { String? message }) { final V? result = find(callback); if (result == null) { - throw NotExist(cause: message ?? 'No values were found.'); + throw NotExist(prefix: 'Invalid value', cause: message ?? 'No values were found.'); } return result as T; From 3409b532aec214f03f63a01ab277e42f3cf47b1d Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Mon, 11 Jul 2022 18:50:16 +0200 Subject: [PATCH 26/68] feat: Work in progress --- lib/src/internal/extensions/collection.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/src/internal/extensions/collection.dart b/lib/src/internal/extensions/collection.dart index 8c129bea4..ca15a3890 100644 --- a/lib/src/internal/extensions/collection.dart +++ b/lib/src/internal/extensions/collection.dart @@ -9,6 +9,20 @@ extension Collection on Map { /// ``` T? get (K? key) => this[key] as T?; + /// Returns the value associated from the [K] parameter or defined value + /// ```dart + /// Channel firstChannel = guild.channels.cache.getOrFail('991686152585232404', defaultValue: myChannel ); + /// Channel? secondChannel = guild.channels.cache.getOr('991686152585232404', defaultValue: firstChannel ); + /// print(secondChannel); + /// ``` + T? getOr (K? key, { T? defaultValue }) { + V? result = get(key); + if (result == null) { + return defaultValue; + } + return result as T; + } + /// Inserts or replaces data in the collection /// ```dart /// Channel channel = Channel.from({...}); From bfe878bcc7e59a7fc8a12dbe9b2fe2761d45909d Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Thu, 14 Jul 2022 20:01:36 +0200 Subject: [PATCH 27/68] feat: Add leave method --- lib/src/api/guilds/guild.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/src/api/guilds/guild.dart b/lib/src/api/guilds/guild.dart index 90bbf9313..4856d4fbd 100644 --- a/lib/src/api/guilds/guild.dart +++ b/lib/src/api/guilds/guild.dart @@ -344,6 +344,16 @@ class Guild { } } + Future leave () async { + Http http = ioc.singleton(ioc.services.http); + Response response = await http.destroy(url: '/users/@me/guilds/$id'); + + if (response.statusCode == 204) { + MineralClient client = ioc.singleton(ioc.services.client); + client.guilds.cache.remove(this); + } + } + factory Guild.from({ required EmojiManager emojiManager, required MemberManager memberManager, From eae8096101f894f8bac8f92b3dd6f68fcfacb2db Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Thu, 14 Jul 2022 22:57:47 +0200 Subject: [PATCH 28/68] feat: Implement send message to dm channel --- lib/src/api/channels/dm_channel.dart | 38 ++++++ lib/src/api/channels/text_based_channel.dart | 30 ++--- lib/src/api/client/mineral_client.dart | 8 +- lib/src/api/dm_message.dart | 122 ++++++++++++++++++ lib/src/api/managers/dm_channel_manager.dart | 15 +++ lib/src/api/managers/dm_message_manager.dart | 17 +++ lib/src/api/user.dart | 43 +++++- .../internal/extensions/mineral_client.dart | 30 +++++ 8 files changed, 278 insertions(+), 25 deletions(-) create mode 100644 lib/src/api/channels/dm_channel.dart create mode 100644 lib/src/api/dm_message.dart create mode 100644 lib/src/api/managers/dm_channel_manager.dart create mode 100644 lib/src/api/managers/dm_message_manager.dart create mode 100644 lib/src/internal/extensions/mineral_client.dart diff --git a/lib/src/api/channels/dm_channel.dart b/lib/src/api/channels/dm_channel.dart new file mode 100644 index 000000000..54fae80d1 --- /dev/null +++ b/lib/src/api/channels/dm_channel.dart @@ -0,0 +1,38 @@ +import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/api/managers/dm_message_manager.dart'; + +class DmChannel { + Snowflake id; + Snowflake? lastMessageId; + DmMessageManager messages; + Map recipients; + + DmChannel({ + required this.id, + required this.lastMessageId, + required this.messages, + required this.recipients, + }); + + factory DmChannel.from({ required dynamic payload }) { + MineralClient client = ioc.singleton(ioc.services.client); + + Map users = {}; + if (payload['recipients'] != null) { + for (dynamic element in payload['recipients']) { + User? user = client.users.cache.get(element['id']); + user ??= User.from(element); + + users.putIfAbsent(user.id, () => user!); + } + } + + return DmChannel( + id: payload['id'], + lastMessageId: payload['last_message_id'], + messages: DmMessageManager(payload['id']), + recipients: users + ); + } +} diff --git a/lib/src/api/channels/text_based_channel.dart b/lib/src/api/channels/text_based_channel.dart index 120ae81a1..f566918c3 100644 --- a/lib/src/api/channels/text_based_channel.dart +++ b/lib/src/api/channels/text_based_channel.dart @@ -5,8 +5,9 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/message_manager.dart'; import 'package:mineral/src/api/managers/webhook_manager.dart'; +import 'package:mineral/src/api/managers/thread_manager.dart'; +import 'package:mineral/src/internal/extensions/mineral_client.dart'; -import '../managers/thread_manager.dart'; class TextBasedChannel extends Channel { String? description; @@ -43,28 +44,13 @@ class TextBasedChannel extends Channel { ); Future send ({ String? content, List? embeds, List? components, bool? tts }) async { - Http http = ioc.singleton(ioc.services.http); - - List embedList = []; - if (embeds != null) { - for (MessageEmbed element in embeds) { - embedList.add(element.toJson()); - } - } + MineralClient client = ioc.singleton(ioc.services.client); - List componentList = []; - if (components != null) { - for (Row element in components) { - componentList.add(element.toJson()); - } - } - - Response response = await http.post(url: "/channels/$id/messages", payload: { - 'tts': tts ?? false, - 'content': content, - 'embeds': embeds != null ? embedList : [], - 'components': components != null ? componentList : [], - }); + Response response = await client.sendMessage(this, + content: content, + embeds: embeds, + components: components + ); if (response.statusCode == 200) { dynamic payload = jsonDecode(response.body); diff --git a/lib/src/api/client/mineral_client.dart b/lib/src/api/client/mineral_client.dart index 03314a7de..123a428fd 100644 --- a/lib/src/api/client/mineral_client.dart +++ b/lib/src/api/client/mineral_client.dart @@ -1,5 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; +import 'package:mineral/src/api/managers/dm_channel_manager.dart'; import 'package:mineral/src/api/managers/guild_manager.dart'; import 'package:mineral/src/api/managers/user_manager.dart'; import 'package:mineral/src/internal/websockets/sharding/shard_manager.dart'; @@ -66,12 +67,13 @@ class ClientActivity { ClientActivity({ required this.name, required this.type }); - dynamic toJson () => { 'name': name, 'type': type.value }; + Object toJson () => { 'name': name, 'type': type.value }; } class MineralClient { User user; GuildManager guilds; + DmChannelManager dmChannels; UserManager users; String sessionId; Application application; @@ -80,6 +82,7 @@ class MineralClient { MineralClient({ required this.user, required this.guilds, + required this.dmChannels, required this.users, required this.sessionId, required this.application, @@ -128,7 +131,8 @@ class MineralClient { users: UserManager(), sessionId: payload['session_id'], application: Application.from(payload['application']), - intents: manager.intents + intents: manager.intents, + dmChannels: DmChannelManager() ); } } diff --git a/lib/src/api/dm_message.dart b/lib/src/api/dm_message.dart new file mode 100644 index 000000000..7941b7704 --- /dev/null +++ b/lib/src/api/dm_message.dart @@ -0,0 +1,122 @@ +import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/api/channels/dm_channel.dart'; +import 'package:mineral/src/api/components/component.dart'; +import 'package:mineral/src/api/message_attachment.dart'; +import 'package:mineral/src/api/message_sticker_item.dart'; + +class DmMessage { + Snowflake id; + String content; + bool tts; + List embeds; + bool allowMentions; + Message? reference; + List components; + List stickers; + dynamic payload; + List attachments; + int? flags; + Snowflake channelId; + DmChannel channel; + User author; + + DmMessage({ + required this.id, + required this.content, + required this.tts, + required this.embeds, + required this.allowMentions, + required this.reference, + required this.components, + required this.stickers, + required this.payload, + required this.attachments, + required this.flags, + required this.channelId, + required this.channel, + required this.author, + }); + + factory DmMessage.from({ required DmChannel channel, required dynamic payload }) { + MineralClient client = ioc.singleton(ioc.services.client); + User? user = client.users.cache.get(payload['author']['id']); + List embeds = []; + + for (dynamic element in payload['embeds']) { + List fields = []; + if (element['fields'] != null) { + for (dynamic item in element['fields']) { + Field field = Field(name: item['name'], value: item['value'], inline: item['inline'] ?? false); + fields.add(field); + } + } + + MessageEmbed embed = MessageEmbed( + title: element['title'], + description: element['description'], + url: element['url'], + timestamp: element['timestamp'] != null ? DateTime.parse(element['timestamp']) : null, + footer: element['footer'] != null ? Footer( + text: element['footer']['text'], + iconUrl: element['footer']['icon_url'], + proxyIconUrl: element['footer']['proxy_icon_url'], + ) : null, + image: element['image'] != null ? Image( + url: element['image']['url'], + proxyUrl: element['image']['proxy_url'], + height: element['image']['height'], + width: element['image']['width'], + ) : null, + author: element['author'] != null ? Author( + name: element['author']['name'], + url: element['author']['url'], + proxyIconUrl: element['author']['proxy_icon_url'], + iconUrl: element['author']['icon_url'], + ) : null, + fields: fields, + ); + + embeds.add(embed); + } + + List stickers = []; + if (payload['sticker_items'] != null) { + for (dynamic element in payload['sticker_items']) { + MessageStickerItem sticker = MessageStickerItem.from(element); + stickers.add(sticker); + } + } + + List messageAttachments = []; + if (payload['attachments'] != null) { + for (dynamic element in payload['attachments']) { + MessageAttachment attachment = MessageAttachment.from(element); + messageAttachments.add(attachment); + } + } + + List components = []; + for (dynamic payload in payload['components']) { + Component component = Component.from(payload: payload); + components.add(component); + } + + return DmMessage( + id: payload['id'], + content: payload['content'], + tts: payload['tts'] ?? false, + allowMentions: payload['allow_mentions'] ?? false, + reference: payload['reference'], + flags: payload['flags'], + channelId: channel.id, + channel: channel, + author: user!, + embeds: embeds, + components: components, + payload: payload['payload'], + stickers: stickers, + attachments: messageAttachments, + ); + } +} diff --git a/lib/src/api/managers/dm_channel_manager.dart b/lib/src/api/managers/dm_channel_manager.dart new file mode 100644 index 000000000..12bbd94d5 --- /dev/null +++ b/lib/src/api/managers/dm_channel_manager.dart @@ -0,0 +1,15 @@ +import 'package:mineral/api.dart'; +import 'package:mineral/src/api/channels/dm_channel.dart'; +import 'package:mineral/src/api/managers/cache_manager.dart'; + +class DmChannelManager implements CacheManager { + @override + Map cache = {}; + + DmChannelManager(); + + @override + Future> sync () async { + return cache; + } +} diff --git a/lib/src/api/managers/dm_message_manager.dart b/lib/src/api/managers/dm_message_manager.dart new file mode 100644 index 000000000..5eaed22d5 --- /dev/null +++ b/lib/src/api/managers/dm_message_manager.dart @@ -0,0 +1,17 @@ +import 'package:mineral/api.dart'; +import 'package:mineral/src/api/dm_message.dart'; +import 'package:mineral/src/api/managers/cache_manager.dart'; + +class DmMessageManager implements CacheManager { + @override + Map cache = {}; + + final Snowflake _channelId; + + DmMessageManager(this._channelId); + + @override + Future> sync() { + throw UnimplementedError(); + } +} diff --git a/lib/src/api/user.dart b/lib/src/api/user.dart index d791798ac..5e192852e 100644 --- a/lib/src/api/user.dart +++ b/lib/src/api/user.dart @@ -1,5 +1,11 @@ +import 'dart:convert'; + +import 'package:http/http.dart'; import 'package:mineral/api.dart'; -import 'package:mineral/src/constants.dart'; +import 'package:mineral/core.dart'; +import 'package:mineral/src/api/channels/dm_channel.dart'; +import 'package:mineral/src/api/dm_message.dart'; +import 'package:mineral/src/internal/extensions/mineral_client.dart'; class User { Snowflake id; @@ -9,8 +15,41 @@ class User { bool bot = false; int publicFlags; String? avatar; + String? avatarDecoration; late Status status; + Future send ({ String? content, List? embeds, List? components, bool? tts }) async { + MineralClient client = ioc.singleton(ioc.services.client); + Http http = ioc.singleton(ioc.services.http); + + DmChannel? channel = client.dmChannels.cache.get(id); + + /// Get channel if exist or create + if (channel == null) { + Response response = await http.post(url: '/users/@me/channels', payload: { 'recipient_id': id }); + if (response.statusCode == 200) { + channel = DmChannel.from(payload: jsonDecode(response.body)); + client.dmChannels.cache.putIfAbsent(channel.id, () => channel!); + } + } + + Response response = await client.sendMessage(channel!, + content: content, + embeds: embeds, + components: components + ); + + if (response.statusCode == 200) { + dynamic payload = jsonDecode(response.body); + + DmMessage message = DmMessage.from(channel: channel, payload: payload); + channel.messages.cache.putIfAbsent(message.id, () => message); + + return message; + } + return null; + } + User({ required this.id, required this.username, @@ -19,6 +58,7 @@ class User { required this.bot, required this.publicFlags, required this.avatar, + required this.avatarDecoration, }); String getDisplayAvatarUrl () { @@ -37,6 +77,7 @@ class User { bot: payload['bot'] == true, publicFlags: payload['public_flags'] ?? 0, avatar: payload['avatar'], + avatarDecoration: payload['avatar_decoration'] ); } } diff --git a/lib/src/internal/extensions/mineral_client.dart b/lib/src/internal/extensions/mineral_client.dart new file mode 100644 index 000000000..71fc2a4fc --- /dev/null +++ b/lib/src/internal/extensions/mineral_client.dart @@ -0,0 +1,30 @@ +import 'package:http/http.dart'; +import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; + +extension MineralClientExtension on MineralClient { + Future sendMessage (dynamic channel, { String? content, List? embeds, List? components, bool? tts }) async { + Http http = ioc.singleton(ioc.services.http); + + List embedList = []; + if (embeds != null) { + for (MessageEmbed element in embeds) { + embedList.add(element.toJson()); + } + } + + List componentList = []; + if (components != null) { + for (Row element in components) { + componentList.add(element.toJson()); + } + } + + return await http.post(url: '/channels/${channel?.id}/messages', payload: { + 'tts': tts ?? false, + 'content': content, + 'embeds': embeds != null ? embedList : [], + 'components': components != null ? componentList : [], + }); + } +} From 7cf6a1eb8b587a203209044feebae3a0799d2ef8 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 00:35:40 +0200 Subject: [PATCH 29/68] feat: Improve DX --- lib/api.dart | 4 +- lib/src/api/channels/base_channel.dart | 7 +++ lib/src/api/channels/channel.dart | 8 +-- lib/src/api/channels/dm_channel.dart | 14 ++--- lib/src/api/managers/dm_message_manager.dart | 17 ----- lib/src/api/managers/message_manager.dart | 7 ++- lib/src/api/{ => messages}/dm_message.dart | 62 +++++++++--------- lib/src/api/{ => messages}/message.dart | 63 ++++++++++--------- .../{ => messages}/message_attachment.dart | 0 lib/src/api/{ => messages}/message_embed.dart | 0 .../{ => messages}/message_sticker_item.dart | 0 lib/src/api/messages/partial_message.dart | 38 +++++++++++ lib/src/api/user.dart | 2 +- 13 files changed, 127 insertions(+), 95 deletions(-) create mode 100644 lib/src/api/channels/base_channel.dart delete mode 100644 lib/src/api/managers/dm_message_manager.dart rename lib/src/api/{ => messages}/dm_message.dart (78%) rename lib/src/api/{ => messages}/message.dart (79%) rename lib/src/api/{ => messages}/message_attachment.dart (100%) rename lib/src/api/{ => messages}/message_embed.dart (100%) rename lib/src/api/{ => messages}/message_sticker_item.dart (100%) create mode 100644 lib/src/api/messages/partial_message.dart diff --git a/lib/api.dart b/lib/api.dart index 62f785008..a30c16e1b 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -27,8 +27,8 @@ export 'src/api/channels/text_based_channel.dart' show TextBasedChannel; export 'src/api/channels/text_channel.dart' show TextChannel; export 'src/api/channels/category_channel.dart' show CategoryChannel; -export 'src/api/message.dart' show Message; -export 'src/api/message_embed.dart' show MessageEmbed, Footer, Image, Thumbnail, Author, Field; +export 'src/api/messages/message.dart' show Message; +export 'src/api/messages/message_embed.dart' show MessageEmbed, Footer, Image, Thumbnail, Author, Field; export 'src/api/color.dart' show Color; export 'src/api/emoji.dart' show Emoji; diff --git a/lib/src/api/channels/base_channel.dart b/lib/src/api/channels/base_channel.dart new file mode 100644 index 000000000..e94c0cc21 --- /dev/null +++ b/lib/src/api/channels/base_channel.dart @@ -0,0 +1,7 @@ +import 'package:mineral/api.dart'; + +class BaseChannel { + Snowflake id; + + BaseChannel({ required this.id }); +} diff --git a/lib/src/api/channels/channel.dart b/lib/src/api/channels/channel.dart index 977b5660a..3f89339f6 100644 --- a/lib/src/api/channels/channel.dart +++ b/lib/src/api/channels/channel.dart @@ -1,6 +1,7 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; +import 'package:mineral/src/api/channels/base_channel.dart'; import 'package:mineral/src/api/managers/webhook_manager.dart'; enum ChannelType { @@ -36,8 +37,7 @@ Map channels = { // 'GUILD_FORUM': () => , }; -class Channel { - Snowflake id; +class Channel extends BaseChannel { ChannelType type; Snowflake? guildId; late Guild? guild; @@ -50,7 +50,7 @@ class Channel { WebhookManager webhooks; Channel({ - required this.id, + required id, required this.type, required this.guildId, required this.position, @@ -59,7 +59,7 @@ class Channel { required this.parentId, required this.flags, required this.webhooks, - }); + }): super(id: id); Future setLabel (String label) async { Http http = ioc.singleton(ioc.services.http); diff --git a/lib/src/api/channels/dm_channel.dart b/lib/src/api/channels/dm_channel.dart index 54fae80d1..3f65361d9 100644 --- a/lib/src/api/channels/dm_channel.dart +++ b/lib/src/api/channels/dm_channel.dart @@ -1,19 +1,19 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/api/managers/dm_message_manager.dart'; +import 'package:mineral/src/api/channels/base_channel.dart'; +import 'package:mineral/src/api/managers/message_manager.dart'; -class DmChannel { - Snowflake id; +class DmChannel extends BaseChannel { Snowflake? lastMessageId; - DmMessageManager messages; + MessageManager messages; Map recipients; DmChannel({ - required this.id, + required id, required this.lastMessageId, required this.messages, required this.recipients, - }); + }): super(id: id); factory DmChannel.from({ required dynamic payload }) { MineralClient client = ioc.singleton(ioc.services.client); @@ -31,7 +31,7 @@ class DmChannel { return DmChannel( id: payload['id'], lastMessageId: payload['last_message_id'], - messages: DmMessageManager(payload['id']), + messages: MessageManager(payload['id'], null), recipients: users ); } diff --git a/lib/src/api/managers/dm_message_manager.dart b/lib/src/api/managers/dm_message_manager.dart deleted file mode 100644 index 5eaed22d5..000000000 --- a/lib/src/api/managers/dm_message_manager.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:mineral/api.dart'; -import 'package:mineral/src/api/dm_message.dart'; -import 'package:mineral/src/api/managers/cache_manager.dart'; - -class DmMessageManager implements CacheManager { - @override - Map cache = {}; - - final Snowflake _channelId; - - DmMessageManager(this._channelId); - - @override - Future> sync() { - throw UnimplementedError(); - } -} diff --git a/lib/src/api/managers/message_manager.dart b/lib/src/api/managers/message_manager.dart index 10b105dc6..423e5cbad 100644 --- a/lib/src/api/managers/message_manager.dart +++ b/lib/src/api/managers/message_manager.dart @@ -4,10 +4,11 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/cache_manager.dart'; +import 'package:mineral/src/api/messages/partial_message.dart'; -class MessageManager implements CacheManager { +class MessageManager implements CacheManager { @override - Map cache = {}; + Map cache = {}; final Snowflake? _guildId; final Snowflake _channelId; @@ -15,7 +16,7 @@ class MessageManager implements CacheManager { MessageManager(this._channelId, this._guildId); @override - Future> sync () async { + Future> sync () async { Http http = ioc.singleton(ioc.services.http); cache.clear(); diff --git a/lib/src/api/dm_message.dart b/lib/src/api/messages/dm_message.dart similarity index 78% rename from lib/src/api/dm_message.dart rename to lib/src/api/messages/dm_message.dart index 7941b7704..2e727ba51 100644 --- a/lib/src/api/dm_message.dart +++ b/lib/src/api/messages/dm_message.dart @@ -2,41 +2,43 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/channels/dm_channel.dart'; import 'package:mineral/src/api/components/component.dart'; -import 'package:mineral/src/api/message_attachment.dart'; -import 'package:mineral/src/api/message_sticker_item.dart'; +import 'package:mineral/src/api/messages/message_attachment.dart'; +import 'package:mineral/src/api/messages/message_sticker_item.dart'; +import 'package:mineral/src/api/messages/partial_message.dart'; -class DmMessage { - Snowflake id; - String content; - bool tts; - List embeds; - bool allowMentions; - Message? reference; - List components; - List stickers; - dynamic payload; - List attachments; - int? flags; - Snowflake channelId; - DmChannel channel; +class DmMessage extends PartialMessage { User author; DmMessage({ - required this.id, - required this.content, - required this.tts, - required this.embeds, - required this.allowMentions, - required this.reference, - required this.components, - required this.stickers, - required this.payload, - required this.attachments, - required this.flags, - required this.channelId, - required this.channel, + required id, + required content, + required tts, + required embeds, + required allowMentions, + required reference, + required components, + required stickers, + required payload, + required attachments, + required flags, + required channelId, + required channel, required this.author, - }); + }): super( + id: id, + content: content, + tts: tts, + embeds: embeds, + allowMentions: allowMentions, + reference: reference, + components: components, + stickers: stickers, + payload: payload, + attachments: attachments, + flags: flags, + channelId: channelId, + channel: channel, + ); factory DmMessage.from({ required DmChannel channel, required dynamic payload }) { MineralClient client = ioc.singleton(ioc.services.client); diff --git a/lib/src/api/message.dart b/lib/src/api/messages/message.dart similarity index 79% rename from lib/src/api/message.dart rename to lib/src/api/messages/message.dart index f5ddbaad8..29c0c3d74 100644 --- a/lib/src/api/message.dart +++ b/lib/src/api/messages/message.dart @@ -4,42 +4,43 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/components/component.dart'; -import 'package:mineral/src/api/message_attachment.dart'; -import 'package:mineral/src/api/message_embed.dart'; -import 'package:mineral/src/api/message_sticker_item.dart'; +import 'package:mineral/src/api/messages/message_attachment.dart'; +import 'package:mineral/src/api/messages/message_sticker_item.dart'; +import 'package:mineral/src/api/messages/partial_message.dart'; -class Message { - Snowflake id; - String content; - bool tts; - List embeds; - bool allowMentions; - Message? reference; - List components; - List stickers; - dynamic payload; - List attachments; - int? flags; - Snowflake channelId; - TextBasedChannel channel; +class Message extends PartialMessage { GuildMember author; Message({ - required this.id, - required this.content, - required this.tts, - required this.embeds, - required this.allowMentions, - required this.reference, - required this.components, - required this.stickers, - required this.payload, - required this.attachments, - required this.flags, - required this.channelId, - required this.channel, + required id, + required content, + required tts, + required embeds, + required allowMentions, + required reference, + required components, + required stickers, + required payload, + required attachments, + required flags, + required channelId, + required channel, required this.author, - }); + }): super( + id: id, + content: content, + tts: tts, + embeds: embeds, + allowMentions: allowMentions, + reference: reference, + components: components, + stickers: stickers, + payload: payload, + attachments: attachments, + flags: flags, + channelId: channelId, + channel: channel, + ); Future sync () async { Http http = ioc.singleton(ioc.services.http); diff --git a/lib/src/api/message_attachment.dart b/lib/src/api/messages/message_attachment.dart similarity index 100% rename from lib/src/api/message_attachment.dart rename to lib/src/api/messages/message_attachment.dart diff --git a/lib/src/api/message_embed.dart b/lib/src/api/messages/message_embed.dart similarity index 100% rename from lib/src/api/message_embed.dart rename to lib/src/api/messages/message_embed.dart diff --git a/lib/src/api/message_sticker_item.dart b/lib/src/api/messages/message_sticker_item.dart similarity index 100% rename from lib/src/api/message_sticker_item.dart rename to lib/src/api/messages/message_sticker_item.dart diff --git a/lib/src/api/messages/partial_message.dart b/lib/src/api/messages/partial_message.dart new file mode 100644 index 000000000..3427c1747 --- /dev/null +++ b/lib/src/api/messages/partial_message.dart @@ -0,0 +1,38 @@ +import 'package:mineral/api.dart'; +import 'package:mineral/src/api/channels/base_channel.dart'; +import 'package:mineral/src/api/components/component.dart'; +import 'package:mineral/src/api/messages/message_attachment.dart'; +import 'package:mineral/src/api/messages/message_embed.dart'; +import 'package:mineral/src/api/messages/message_sticker_item.dart'; + +class PartialMessage { + Snowflake id; + String content; + bool tts; + List embeds; + bool allowMentions; + PartialMessage? reference; + List components; + List stickers; + dynamic payload; + List attachments; + int? flags; + Snowflake channelId; + T channel; + + PartialMessage({ + required this.id, + required this.content, + required this.tts, + required this.embeds, + required this.allowMentions, + required this.reference, + required this.components, + required this.stickers, + required this.payload, + required this.attachments, + required this.flags, + required this.channelId, + required this.channel, + }); +} diff --git a/lib/src/api/user.dart b/lib/src/api/user.dart index 5e192852e..ae9274329 100644 --- a/lib/src/api/user.dart +++ b/lib/src/api/user.dart @@ -4,7 +4,7 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/channels/dm_channel.dart'; -import 'package:mineral/src/api/dm_message.dart'; +import 'package:mineral/src/api/messages/dm_message.dart'; import 'package:mineral/src/internal/extensions/mineral_client.dart'; class User { From 3109ca7a6a35601fa009f2a189d9843aaeb0b787 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 00:53:14 +0200 Subject: [PATCH 30/68] feat: Improve DX --- lib/api.dart | 1 + lib/src/api/guilds/guild_member.dart | 12 ++-- lib/src/internal/extensions/string.dart | 79 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 lib/src/internal/extensions/string.dart diff --git a/lib/api.dart b/lib/api.dart index a30c16e1b..ac95b5980 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -48,5 +48,6 @@ export 'src/api/interactions/select_menu_interaction.dart' show SelectMenuIntera export 'src/api/utils.dart'; export 'src/internal/extensions/collection.dart'; +export 'src/internal/extensions/string.dart'; typedef Snowflake = String; diff --git a/lib/src/api/guilds/guild_member.dart b/lib/src/api/guilds/guild_member.dart index e9c9c7cc8..11738b184 100644 --- a/lib/src/api/guilds/guild_member.dart +++ b/lib/src/api/guilds/guild_member.dart @@ -11,7 +11,7 @@ class GuildMember { DateTime joinedAt; DateTime? premiumSince; String? permissions; - bool isPending; + bool pending; DateTime? timeoutDuration; MemberRoleManager roles; late VoiceManager voice; @@ -24,7 +24,7 @@ class GuildMember { required this.joinedAt, required this.premiumSince, required this.permissions, - required this.isPending, + required this.pending, required this.timeoutDuration, required this.roles, required this.voice, @@ -76,6 +76,10 @@ class GuildMember { await http.destroy(url: "/guilds/${guild.id}/members/${user.id}"); } + bool isBot () => user.bot; + + bool isPending () => pending; + @override String toString () { return "<@${nickname != null ? '!' : ''}${user.id}>"; @@ -89,7 +93,7 @@ class GuildMember { joinedAt: joinedAt, premiumSince: premiumSince, permissions: permissions, - isPending: isPending, + pending: pending, timeoutDuration: timeoutDuration, roles: roles, voice: voice @@ -114,7 +118,7 @@ class GuildMember { joinedAt: DateTime.parse(member['joined_at']), premiumSince: member['premium_since'] != null ? DateTime.parse(member['premium_since']) : null, permissions: member['permissions'], - isPending: member['pending'] == true, + pending: member['pending'] == true, timeoutDuration: member['communication_disabled_until'] != null ? DateTime.parse(member['communication_disabled_until']) : null, roles: memberRoleManager, voice: voice, diff --git a/lib/src/internal/extensions/string.dart b/lib/src/internal/extensions/string.dart new file mode 100644 index 000000000..6e39f1c82 --- /dev/null +++ b/lib/src/internal/extensions/string.dart @@ -0,0 +1,79 @@ +extension StringFormat on String { + + List _groupIntoWords(String text) { + RegExp _upperAlphaRegex = RegExp(r'[A-Z]'); + Set symbolSet = {' ', '.', '/', '_', '\\', '-'}; + + StringBuffer sb = StringBuffer(); + List words = []; + bool isAllCaps = text.toUpperCase() == text; + + for (int i = 0; i < text.length; i++) { + String char = text[i]; + String? nextChar = i + 1 == text.length ? null : text[i + 1]; + + if (symbolSet.contains(char)) { + continue; + } + + sb.write(char); + + bool isEndOfWord = nextChar == null + || (_upperAlphaRegex.hasMatch(nextChar) && !isAllCaps) + || symbolSet.contains(nextChar); + + if (isEndOfWord) { + words.add(sb.toString()); + sb.clear(); + } + } + + return words; + } + + String _getCamelCase({String separator = ''}) { + List words = _groupIntoWords(this).map(_upperCaseFirstLetter).toList(); + if (_groupIntoWords(this).isNotEmpty) { + words[0] = words[0].toLowerCase(); + } + + return words.join(separator); + } + + String _getConstantCase({String separator = '_'}) { + List words = _groupIntoWords(this).map((word) => word.toUpperCase()).toList(); + + return words.join(separator); + } + + String _getPascalCase({String separator = ''}) { + List words = _groupIntoWords(this).map(_upperCaseFirstLetter).toList(); + + return words.join(separator); + } + + String _getSentenceCase({String separator = ' '}) { + List words = _groupIntoWords(this).map((word) => word.toLowerCase()).toList(); + if (_groupIntoWords(this).isNotEmpty) { + words[0] = _upperCaseFirstLetter(words[0]); + } + + return words.join(separator); + } + + String _getSnakeCase({String separator = '_'}) { + List words = _groupIntoWords(this).map((word) => word.toLowerCase()).toList(); + + return words.join(separator); + } + + String _upperCaseFirstLetter(String word) { + return '${word.substring(0, 1).toUpperCase()}${word.substring(1).toLowerCase()}'; + } + + String get camelCase => _getCamelCase(); + String get constantCase => _getConstantCase(); + String get sentenceCase => _getSentenceCase(); + String get snakeCase => _getSnakeCase(); + String get pascalCase => _getPascalCase(); +} From 6456e6e9ab00c5be65eb4e6690cbfc795020cd0c Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 00:57:28 +0200 Subject: [PATCH 31/68] feat: Improve DX --- lib/src/internal/extensions/string.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/internal/extensions/string.dart b/lib/src/internal/extensions/string.dart index 6e39f1c82..b36de268a 100644 --- a/lib/src/internal/extensions/string.dart +++ b/lib/src/internal/extensions/string.dart @@ -4,7 +4,7 @@ extension StringFormat on String { RegExp _upperAlphaRegex = RegExp(r'[A-Z]'); Set symbolSet = {' ', '.', '/', '_', '\\', '-'}; - StringBuffer sb = StringBuffer(); + StringBuffer buffer = StringBuffer(); List words = []; bool isAllCaps = text.toUpperCase() == text; @@ -16,15 +16,15 @@ extension StringFormat on String { continue; } - sb.write(char); + buffer.write(char); bool isEndOfWord = nextChar == null || (_upperAlphaRegex.hasMatch(nextChar) && !isAllCaps) || symbolSet.contains(nextChar); if (isEndOfWord) { - words.add(sb.toString()); - sb.clear(); + words.add(buffer.toString()); + buffer.clear(); } } From 8aacf24a594fc01f7086439e57af8fad1468a445 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 01:03:23 +0200 Subject: [PATCH 32/68] feat: Improve DX --- lib/helper.dart | 13 ------------- lib/src/commands/create_project.dart | 6 +++--- lib/src/commands/make_command.dart | 12 ++++++------ lib/src/commands/make_event.dart | 10 +++++----- lib/src/commands/make_module.dart | 16 ++++++++-------- lib/src/commands/make_store.dart | 12 ++++++------ lib/src/internal/extensions/string.dart | 1 + 7 files changed, 29 insertions(+), 41 deletions(-) diff --git a/lib/helper.dart b/lib/helper.dart index de117d96f..44f9822aa 100644 --- a/lib/helper.dart +++ b/lib/helper.dart @@ -37,17 +37,4 @@ class Helper { return _permissions; } - - static toPascalCase (String value) { - List words = value.split('_'); - return words.map((word) => "${word[0].toUpperCase()}${word.substring(1)}").join(''); - } - - static toCapitalCase (String value) { - return '${value[0].toUpperCase()}${value.substring(1)}'; - } - - static String toSnakeCase (String value) { - return value.split(RegExp(r"(?=[A-Z])")).join('_').toLowerCase(); - } } diff --git a/lib/src/commands/create_project.dart b/lib/src/commands/create_project.dart index c53427c00..f8d817df0 100644 --- a/lib/src/commands/create_project.dart +++ b/lib/src/commands/create_project.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:args/args.dart'; +import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; -import 'package:mineral/helper.dart'; import 'package:mineral/src/internal/entities/cli_manager.dart'; import 'package:path/path.dart'; @@ -17,11 +17,11 @@ class CreateProject extends MineralCliCommand { return; } - String filename = Helper.toSnakeCase(args.arguments.elementAt(1)); + String filename = args.arguments.elementAt(1).snakeCase; final projectDirectory = Directory(join(Directory.current.path, filename)); - ProcessResult process = await Process.run('git', ['clone', 'https://github.com/mineral-dart/base-structure.git', Helper.toSnakeCase(filename)]); + ProcessResult process = await Process.run('git', ['clone', 'https://github.com/mineral-dart/base-structure.git', filename.snakeCase]); switch (process.exitCode) { case 0: diff --git a/lib/src/commands/make_command.dart b/lib/src/commands/make_command.dart index 212cab927..1dd76f379 100644 --- a/lib/src/commands/make_command.dart +++ b/lib/src/commands/make_command.dart @@ -2,8 +2,8 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:interact/interact.dart'; +import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; -import 'package:mineral/helper.dart'; import 'package:mineral/src/internal/entities/cli_manager.dart'; import 'package:path/path.dart'; @@ -18,7 +18,7 @@ class MakeCommand extends MineralCliCommand { return; } - String filename = Helper.toCapitalCase(args.arguments.elementAt(1)); + String filename = args.arguments.elementAt(1).capitalCase; final useExistLocation = Confirm( prompt: 'Do you want to use an existing location on your disk ?', @@ -38,14 +38,14 @@ class MakeCommand extends MineralCliCommand { .toList(), ).interact(); - file = File(join(directories[selection].path, '${Helper.toSnakeCase(filename)}.dart')); + file = File(join(directories[selection].path, '${filename.snakeCase}.dart')); } else { final location = Input( prompt: 'Target folder location', defaultValue: 'App/folder', // optional, will provide the user as a hint ).interact(); - file = File(join(Directory.current.path, 'src', location.replaceAll('App/', ''), '${Helper.toSnakeCase(filename)}.dart')); + file = File(join(Directory.current.path, 'src', location.replaceAll('App/', ''), '${filename.snakeCase}.dart')); } await file.create(recursive: true); @@ -59,8 +59,8 @@ class MakeCommand extends MineralCliCommand { import 'package:mineral/core.dart'; import 'package:mineral/api.dart'; -@Command(name: '${filename.toLowerCase()}', description: '${Helper.toCapitalCase(filename)} command description', scope: 'GUILD') -class ${Helper.toPascalCase(filename)} extends MineralCommand { +@Command(name: '${filename.toLowerCase()}', description: '${filename.capitalCase} command description', scope: 'GUILD') +class ${filename.pascalCase} extends MineralCommand { Future handle (CommandInteraction interaction) async { // Your code here } diff --git a/lib/src/commands/make_event.dart b/lib/src/commands/make_event.dart index b6190253e..26fc61540 100644 --- a/lib/src/commands/make_event.dart +++ b/lib/src/commands/make_event.dart @@ -1,12 +1,12 @@ import 'dart:io'; +import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; import 'package:path/path.dart'; import 'package:args/args.dart'; import 'package:interact/interact.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/helper.dart'; import 'package:mineral/src/internal/entities/cli_manager.dart'; class MakeEvent extends MineralCliCommand { @@ -20,7 +20,7 @@ class MakeEvent extends MineralCliCommand { return; } - String filename = Helper.toCapitalCase(args.arguments.elementAt(1)); + String filename = args.arguments.elementAt(1).capitalCase; final eventKey = Select( prompt: 'Which event would you like to use ?', @@ -45,14 +45,14 @@ class MakeEvent extends MineralCliCommand { .toList(), ).interact(); - file = File(join(directories[selection].path, '${Helper.toSnakeCase(filename)}.dart')); + file = File(join(directories[selection].path, '${filename.snakeCase}.dart')); } else { final location = Input( prompt: 'Target folder location', defaultValue: 'App/folder', // optional, will provide the user as a hint ).interact(); - file = File(join(Directory.current.path, 'src', location.replaceAll('App/', ''), '${Helper.toSnakeCase(filename)}.dart')); + file = File(join(Directory.current.path, 'src', location.replaceAll('App/', ''), '${filename.snakeCase}.dart')); } await file.create(recursive: true); @@ -73,7 +73,7 @@ import 'package:mineral/core.dart'; import 'package:mineral/api.dart'; @Event(${event.toString()}) -class ${Helper.toCapitalCase(filename)} extends MineralEvent { +class ${filename.capitalCase} extends MineralEvent { Future handle (${params.join(', ')}) async { // Your code here } diff --git a/lib/src/commands/make_module.dart b/lib/src/commands/make_module.dart index 6325fba2e..98a0bfc73 100644 --- a/lib/src/commands/make_module.dart +++ b/lib/src/commands/make_module.dart @@ -2,8 +2,8 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:interact/interact.dart'; +import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; -import 'package:mineral/helper.dart'; import 'package:mineral/src/internal/entities/cli_manager.dart'; import 'package:path/path.dart'; @@ -18,7 +18,7 @@ class MakeModule extends MineralCliCommand { return; } - String filename = Helper.toCapitalCase(args.arguments.elementAt(1)); + String filename = args.arguments.elementAt(1).capitalCase; final useExistLocation = Confirm( prompt: 'Do you want to use an existing location on your disk ?', @@ -39,16 +39,16 @@ class MakeModule extends MineralCliCommand { .toList(), ).interact(); - directory = Directory(join(directories[selection].path, Helper.toSnakeCase(filename))); - file = File(join(directory.path, '${Helper.toSnakeCase(filename)}.dart')); + directory = Directory(join(directories[selection].path, filename.snakeCase)); + file = File(join(directory.path, '${filename.snakeCase}.dart')); } else { final location = Input( prompt: 'Target folder location', defaultValue: 'App/folder', ).interact(); - directory = Directory(join(Directory.current.path, 'src', location.replaceAll('App/', ''), Helper.toSnakeCase(filename))); - file = File(join(directory.path, '${Helper.toSnakeCase(filename)}.dart')); + directory = Directory(join(Directory.current.path, 'src', location.replaceAll('App/', ''), filename.snakeCase)); + file = File(join(directory.path, '${filename.snakeCase}.dart')); } await Directory(join(directory.path, 'events')).create(recursive: true); @@ -65,8 +65,8 @@ class MakeModule extends MineralCliCommand { String getTemplate (String filename) => ''' import 'package:mineral/core.dart'; -@Module(identifier: '${Helper.toSnakeCase(filename)}', label: '${Helper.toCapitalCase(filename)} module') -class ${Helper.toPascalCase(filename)} extends MineralModule { +@Module(identifier: '${filename.snakeCase}', label: '${filename.capitalCase} module') +class ${filename.pascalCase} extends MineralModule { @override List commands = []; diff --git a/lib/src/commands/make_store.dart b/lib/src/commands/make_store.dart index 593301f06..ac4174501 100644 --- a/lib/src/commands/make_store.dart +++ b/lib/src/commands/make_store.dart @@ -2,8 +2,8 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:interact/interact.dart'; +import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; -import 'package:mineral/helper.dart'; import 'package:mineral/src/internal/entities/cli_manager.dart'; import 'package:path/path.dart'; @@ -18,7 +18,7 @@ class MakeStore extends MineralCliCommand { return; } - String filename = Helper.toCapitalCase(args.arguments.elementAt(1)); + String filename = args.arguments.elementAt(1).capitalCase; final useExistLocation = Confirm( prompt: 'Do you want to use an existing location on your disk ?', @@ -38,14 +38,14 @@ class MakeStore extends MineralCliCommand { .toList(), ).interact(); - file = File(join(directories[selection].path, '${Helper.toSnakeCase(filename)}.dart')); + file = File(join(directories[selection].path, '${filename.snakeCase}.dart')); } else { final location = Input( prompt: 'Target folder location', defaultValue: 'App/folder', ).interact(); - file = File(join(Directory.current.path, 'src', location.replaceAll('App/', ''), '${Helper.toSnakeCase(filename)}.dart')); + file = File(join(Directory.current.path, 'src', location.replaceAll('App/', ''), '${filename.snakeCase}.dart')); } await file.create(recursive: true); @@ -58,8 +58,8 @@ class MakeStore extends MineralCliCommand { String getTemplate (String filename) => ''' import 'package:mineral/core.dart'; -@Store('${Helper.toSnakeCase(filename)}') -class ${Helper.toPascalCase(filename)} implements MineralStore { +@Store('${filename.snakeCase}') +class ${filename.pascalCase} implements MineralStore { @override dynamic state = []; } diff --git a/lib/src/internal/extensions/string.dart b/lib/src/internal/extensions/string.dart index b36de268a..6f19213ff 100644 --- a/lib/src/internal/extensions/string.dart +++ b/lib/src/internal/extensions/string.dart @@ -71,6 +71,7 @@ extension StringFormat on String { return '${word.substring(0, 1).toUpperCase()}${word.substring(1).toLowerCase()}'; } + String get capitalCase => _upperCaseFirstLetter(this); String get camelCase => _getCamelCase(); String get constantCase => _getConstantCase(); String get sentenceCase => _getSentenceCase(); From 0ba8811c80f34ec499a2bff8e32fdbd5352464f5 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 01:12:24 +0200 Subject: [PATCH 33/68] refactor: Refactor folder name --- lib/console.dart | 2 +- lib/core.dart | 8 ++++---- lib/src/commands/create_project.dart | 2 +- lib/src/commands/make_command.dart | 2 +- lib/src/commands/make_event.dart | 2 +- lib/src/commands/make_module.dart | 2 +- lib/src/commands/make_store.dart | 2 +- lib/src/exceptions/already_exist.dart | 2 +- lib/src/exceptions/empty_parameter_exception.dart | 2 +- lib/src/exceptions/missing_feature_exception.dart | 2 +- .../exceptions/missing_premium_subscription.dart | 2 +- lib/src/exceptions/not_exist.dart | 2 +- lib/src/exceptions/shard_exception.dart | 2 +- lib/src/exceptions/token_exception.dart | 2 +- lib/src/exceptions/too_many.dart | 2 +- lib/src/internal/kernel.dart | 13 ++++++------- .../{entities => managers}/cli_manager.dart | 0 .../{entities => managers}/command_manager.dart | 2 +- .../{entities => managers}/event_manager.dart | 2 +- .../{entities => managers}/module_manager.dart | 4 ++-- .../{entities => managers}/reporter_manager.dart | 0 .../{entities => managers}/store_manager.dart | 0 .../packets/auto_moderation_rule_create.dart | 2 +- .../packets/auto_moderation_rule_delete.dart | 2 +- .../packets/auto_moderation_rule_update.dart | 2 +- .../internal/websockets/packets/channel_create.dart | 2 +- .../internal/websockets/packets/channel_delete.dart | 2 +- .../internal/websockets/packets/channel_update.dart | 2 +- .../internal/websockets/packets/guild_create.dart | 4 ++-- .../packets/guild_integrations_update.dart | 2 +- .../websockets/packets/guild_member_add.dart | 2 +- .../websockets/packets/guild_member_remove.dart | 2 +- .../websockets/packets/guild_member_update.dart | 2 +- .../packets/guild_scheduled_event_create.dart | 2 +- .../packets/guild_scheduled_event_delete.dart | 4 +--- .../packets/guild_scheduled_event_update.dart | 2 +- .../packets/guild_scheduled_event_user_add.dart | 2 +- .../packets/guild_scheduled_event_user_remove.dart | 2 +- .../internal/websockets/packets/guild_update.dart | 2 +- .../websockets/packets/interaction_create.dart | 4 ++-- .../websockets/packets/member_join_request.dart | 2 +- .../internal/websockets/packets/message_create.dart | 2 +- .../internal/websockets/packets/message_delete.dart | 2 +- .../internal/websockets/packets/message_update.dart | 2 +- .../websockets/packets/presence_update.dart | 2 +- lib/src/internal/websockets/packets/ready.dart | 4 ++-- lib/src/internal/websockets/packets/resumed.dart | 1 - .../websockets/packets/voice_state_update.dart | 5 +---- .../internal/websockets/packets/webhook_update.dart | 2 +- 49 files changed, 57 insertions(+), 64 deletions(-) rename lib/src/internal/{entities => managers}/cli_manager.dart (100%) rename lib/src/internal/{entities => managers}/command_manager.dart (99%) rename lib/src/internal/{entities => managers}/event_manager.dart (98%) rename lib/src/internal/{entities => managers}/module_manager.dart (94%) rename lib/src/internal/{entities => managers}/reporter_manager.dart (100%) rename lib/src/internal/{entities => managers}/store_manager.dart (100%) diff --git a/lib/console.dart b/lib/console.dart index 077fdb521..d4e8d86b6 100644 --- a/lib/console.dart +++ b/lib/console.dart @@ -1,7 +1,7 @@ library console; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class Console { static void log ({ required String message, String level = 'info'}) { diff --git a/lib/core.dart b/lib/core.dart index d25630525..f336999c0 100644 --- a/lib/core.dart +++ b/lib/core.dart @@ -7,7 +7,7 @@ export 'src/internal/ioc.dart' show ioc, Service; export 'src/constants.dart'; export 'src/internal/http.dart'; -export 'src/internal/entities/event_manager.dart' show Event, Events, MineralEvent; -export 'src/internal/entities/command_manager.dart' show Command, MineralCommand, Option, OptionType, OptionChoice, Subcommand, CommandGroup; -export 'src/internal/entities/store_manager.dart' show Store, MineralStore; -export 'src/internal/entities/module_manager.dart' show Module, MineralModule; +export 'src/internal/managers/event_manager.dart' show Event, Events, MineralEvent; +export 'src/internal/managers/command_manager.dart' show Command, MineralCommand, Option, OptionType, OptionChoice, Subcommand, CommandGroup; +export 'src/internal/managers/store_manager.dart' show Store, MineralStore; +export 'src/internal/managers/module_manager.dart' show Module, MineralModule; diff --git a/lib/src/commands/create_project.dart b/lib/src/commands/create_project.dart index f8d817df0..1bc8b6b0a 100644 --- a/lib/src/commands/create_project.dart +++ b/lib/src/commands/create_project.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; -import 'package:mineral/src/internal/entities/cli_manager.dart'; +import 'package:mineral/src/internal/managers/cli_manager.dart'; import 'package:path/path.dart'; class CreateProject extends MineralCliCommand { diff --git a/lib/src/commands/make_command.dart b/lib/src/commands/make_command.dart index 1dd76f379..83ac68f14 100644 --- a/lib/src/commands/make_command.dart +++ b/lib/src/commands/make_command.dart @@ -4,7 +4,7 @@ import 'package:args/args.dart'; import 'package:interact/interact.dart'; import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; -import 'package:mineral/src/internal/entities/cli_manager.dart'; +import 'package:mineral/src/internal/managers/cli_manager.dart'; import 'package:path/path.dart'; class MakeCommand extends MineralCliCommand { diff --git a/lib/src/commands/make_event.dart b/lib/src/commands/make_event.dart index 26fc61540..a8de414e4 100644 --- a/lib/src/commands/make_event.dart +++ b/lib/src/commands/make_event.dart @@ -7,7 +7,7 @@ import 'package:path/path.dart'; import 'package:args/args.dart'; import 'package:interact/interact.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/cli_manager.dart'; +import 'package:mineral/src/internal/managers/cli_manager.dart'; class MakeEvent extends MineralCliCommand { @override diff --git a/lib/src/commands/make_module.dart b/lib/src/commands/make_module.dart index 98a0bfc73..a895fb910 100644 --- a/lib/src/commands/make_module.dart +++ b/lib/src/commands/make_module.dart @@ -4,7 +4,7 @@ import 'package:args/args.dart'; import 'package:interact/interact.dart'; import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; -import 'package:mineral/src/internal/entities/cli_manager.dart'; +import 'package:mineral/src/internal/managers/cli_manager.dart'; import 'package:path/path.dart'; class MakeModule extends MineralCliCommand { diff --git a/lib/src/commands/make_store.dart b/lib/src/commands/make_store.dart index ac4174501..30a1755a8 100644 --- a/lib/src/commands/make_store.dart +++ b/lib/src/commands/make_store.dart @@ -4,7 +4,7 @@ import 'package:args/args.dart'; import 'package:interact/interact.dart'; import 'package:mineral/api.dart'; import 'package:mineral/console.dart'; -import 'package:mineral/src/internal/entities/cli_manager.dart'; +import 'package:mineral/src/internal/managers/cli_manager.dart'; import 'package:path/path.dart'; class MakeStore extends MineralCliCommand { diff --git a/lib/src/exceptions/already_exist.dart b/lib/src/exceptions/already_exist.dart index e94199198..6cd871ce4 100644 --- a/lib/src/exceptions/already_exist.dart +++ b/lib/src/exceptions/already_exist.dart @@ -1,6 +1,6 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class AlreadyExist implements Exception { String? prefix; diff --git a/lib/src/exceptions/empty_parameter_exception.dart b/lib/src/exceptions/empty_parameter_exception.dart index 036b5df85..6a96cd090 100644 --- a/lib/src/exceptions/empty_parameter_exception.dart +++ b/lib/src/exceptions/empty_parameter_exception.dart @@ -1,6 +1,6 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class EmptyParameterException implements Exception { String prefix = 'INVALID PARAMETER'; diff --git a/lib/src/exceptions/missing_feature_exception.dart b/lib/src/exceptions/missing_feature_exception.dart index 4e7044f83..846f225a0 100644 --- a/lib/src/exceptions/missing_feature_exception.dart +++ b/lib/src/exceptions/missing_feature_exception.dart @@ -1,6 +1,6 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class MissingFeatureException implements Exception { String prefix = 'MISSING FEATURE'; diff --git a/lib/src/exceptions/missing_premium_subscription.dart b/lib/src/exceptions/missing_premium_subscription.dart index bfc0c06a1..b63811b8b 100644 --- a/lib/src/exceptions/missing_premium_subscription.dart +++ b/lib/src/exceptions/missing_premium_subscription.dart @@ -1,6 +1,6 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class MissingPremiumSubscription implements Exception { String? prefix; diff --git a/lib/src/exceptions/not_exist.dart b/lib/src/exceptions/not_exist.dart index 94529815c..7cd703def 100644 --- a/lib/src/exceptions/not_exist.dart +++ b/lib/src/exceptions/not_exist.dart @@ -1,6 +1,6 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class NotExist implements Exception { String? prefix; diff --git a/lib/src/exceptions/shard_exception.dart b/lib/src/exceptions/shard_exception.dart index cf6ba9aae..6b1bbc91a 100644 --- a/lib/src/exceptions/shard_exception.dart +++ b/lib/src/exceptions/shard_exception.dart @@ -1,6 +1,6 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class ShardException implements Exception { String? prefix; diff --git a/lib/src/exceptions/token_exception.dart b/lib/src/exceptions/token_exception.dart index c85e8d196..95cd4961a 100644 --- a/lib/src/exceptions/token_exception.dart +++ b/lib/src/exceptions/token_exception.dart @@ -1,6 +1,6 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class TokenException implements Exception { String? prefix; diff --git a/lib/src/exceptions/too_many.dart b/lib/src/exceptions/too_many.dart index c768d4f05..474a507a7 100644 --- a/lib/src/exceptions/too_many.dart +++ b/lib/src/exceptions/too_many.dart @@ -1,6 +1,6 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; class TooMany implements Exception { String? prefix; diff --git a/lib/src/internal/kernel.dart b/lib/src/internal/kernel.dart index 1e9127a3a..95ca48ae9 100644 --- a/lib/src/internal/kernel.dart +++ b/lib/src/internal/kernel.dart @@ -7,17 +7,16 @@ import 'package:mineral/src/commands/make_command.dart'; import 'package:mineral/src/commands/make_event.dart'; import 'package:mineral/src/commands/make_module.dart'; import 'package:mineral/src/commands/make_store.dart'; -import 'package:mineral/src/internal/entities/cli_manager.dart'; -import 'package:mineral/src/internal/entities/command_manager.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/cli_manager.dart'; +import 'package:mineral/src/internal/managers/command_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/module_manager.dart'; -import 'package:mineral/src/internal/entities/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/module_manager.dart'; +import 'package:mineral/src/internal/managers/reporter_manager.dart'; +import 'package:mineral/src/internal/managers/store_manager.dart'; import 'package:mineral/src/internal/websockets/sharding/shard_manager.dart'; import 'package:path/path.dart'; -import 'entities/store_manager.dart'; - class Kernel { EventManager events = EventManager(); CommandManager commands = CommandManager(); diff --git a/lib/src/internal/entities/cli_manager.dart b/lib/src/internal/managers/cli_manager.dart similarity index 100% rename from lib/src/internal/entities/cli_manager.dart rename to lib/src/internal/managers/cli_manager.dart diff --git a/lib/src/internal/entities/command_manager.dart b/lib/src/internal/managers/command_manager.dart similarity index 99% rename from lib/src/internal/entities/command_manager.dart rename to lib/src/internal/managers/command_manager.dart index 1225217d1..081ccb9b0 100644 --- a/lib/src/internal/entities/command_manager.dart +++ b/lib/src/internal/managers/command_manager.dart @@ -2,7 +2,7 @@ import 'dart:mirrors'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/store_manager.dart'; +import 'package:mineral/src/internal/managers/store_manager.dart'; class CommandManager { final Map _commands = {}; diff --git a/lib/src/internal/entities/event_manager.dart b/lib/src/internal/managers/event_manager.dart similarity index 98% rename from lib/src/internal/entities/event_manager.dart rename to lib/src/internal/managers/event_manager.dart index 051de2a6c..3cae1e934 100644 --- a/lib/src/internal/entities/event_manager.dart +++ b/lib/src/internal/managers/event_manager.dart @@ -3,7 +3,7 @@ import 'dart:mirrors'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/voice_manager.dart'; -import 'package:mineral/src/internal/entities/store_manager.dart'; +import 'package:mineral/src/internal/managers/store_manager.dart'; class EventManager { final Map>> _events = {}; diff --git a/lib/src/internal/entities/module_manager.dart b/lib/src/internal/managers/module_manager.dart similarity index 94% rename from lib/src/internal/entities/module_manager.dart rename to lib/src/internal/managers/module_manager.dart index b0152f523..01f86b723 100644 --- a/lib/src/internal/entities/module_manager.dart +++ b/lib/src/internal/managers/module_manager.dart @@ -3,8 +3,8 @@ import 'dart:mirrors'; import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/exceptions/already_exist.dart'; -import 'package:mineral/src/internal/entities/command_manager.dart'; -import 'package:mineral/src/internal/entities/store_manager.dart'; +import 'package:mineral/src/internal/managers/command_manager.dart'; +import 'package:mineral/src/internal/managers/store_manager.dart'; import 'event_manager.dart'; diff --git a/lib/src/internal/entities/reporter_manager.dart b/lib/src/internal/managers/reporter_manager.dart similarity index 100% rename from lib/src/internal/entities/reporter_manager.dart rename to lib/src/internal/managers/reporter_manager.dart diff --git a/lib/src/internal/entities/store_manager.dart b/lib/src/internal/managers/store_manager.dart similarity index 100% rename from lib/src/internal/entities/store_manager.dart rename to lib/src/internal/managers/store_manager.dart diff --git a/lib/src/internal/websockets/packets/auto_moderation_rule_create.dart b/lib/src/internal/websockets/packets/auto_moderation_rule_create.dart index a308b3774..a5a477ffc 100644 --- a/lib/src/internal/websockets/packets/auto_moderation_rule_create.dart +++ b/lib/src/internal/websockets/packets/auto_moderation_rule_create.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/auto_moderation_rule_delete.dart b/lib/src/internal/websockets/packets/auto_moderation_rule_delete.dart index 99464184a..710796ac7 100644 --- a/lib/src/internal/websockets/packets/auto_moderation_rule_delete.dart +++ b/lib/src/internal/websockets/packets/auto_moderation_rule_delete.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/auto_moderation_rule_update.dart b/lib/src/internal/websockets/packets/auto_moderation_rule_update.dart index 99d40d204..bb408ae9e 100644 --- a/lib/src/internal/websockets/packets/auto_moderation_rule_update.dart +++ b/lib/src/internal/websockets/packets/auto_moderation_rule_update.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/channel_create.dart b/lib/src/internal/websockets/packets/channel_create.dart index 8671aa4cd..da9b361a0 100644 --- a/lib/src/internal/websockets/packets/channel_create.dart +++ b/lib/src/internal/websockets/packets/channel_create.dart @@ -1,7 +1,7 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/channels/channel.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/channel_delete.dart b/lib/src/internal/websockets/packets/channel_delete.dart index 13cf6386e..7a407e2ff 100644 --- a/lib/src/internal/websockets/packets/channel_delete.dart +++ b/lib/src/internal/websockets/packets/channel_delete.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/channel_update.dart b/lib/src/internal/websockets/packets/channel_update.dart index 456d87571..8fa39bac3 100644 --- a/lib/src/internal/websockets/packets/channel_update.dart +++ b/lib/src/internal/websockets/packets/channel_update.dart @@ -1,7 +1,7 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/channels/channel.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_create.dart b/lib/src/internal/websockets/packets/guild_create.dart index c8c34c9a3..571f0c2ec 100644 --- a/lib/src/internal/websockets/packets/guild_create.dart +++ b/lib/src/internal/websockets/packets/guild_create.dart @@ -13,8 +13,8 @@ import 'package:mineral/src/api/managers/member_manager.dart'; import 'package:mineral/src/api/managers/moderation_rule_manager.dart'; import 'package:mineral/src/api/managers/voice_manager.dart'; import 'package:mineral/src/api/managers/webhook_manager.dart'; -import 'package:mineral/src/internal/entities/command_manager.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/command_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_integrations_update.dart b/lib/src/internal/websockets/packets/guild_integrations_update.dart index 2586d3849..a04825b77 100644 --- a/lib/src/internal/websockets/packets/guild_integrations_update.dart +++ b/lib/src/internal/websockets/packets/guild_integrations_update.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_member_add.dart b/lib/src/internal/websockets/packets/guild_member_add.dart index 4502ac1ab..88c1a77d1 100644 --- a/lib/src/internal/websockets/packets/guild_member_add.dart +++ b/lib/src/internal/websockets/packets/guild_member_add.dart @@ -1,7 +1,7 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/voice_manager.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_member_remove.dart b/lib/src/internal/websockets/packets/guild_member_remove.dart index 613cee743..da0bc3409 100644 --- a/lib/src/internal/websockets/packets/guild_member_remove.dart +++ b/lib/src/internal/websockets/packets/guild_member_remove.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_member_update.dart b/lib/src/internal/websockets/packets/guild_member_update.dart index b47b76b90..4a6aee67a 100644 --- a/lib/src/internal/websockets/packets/guild_member_update.dart +++ b/lib/src/internal/websockets/packets/guild_member_update.dart @@ -1,7 +1,7 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/voice_manager.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_scheduled_event_create.dart b/lib/src/internal/websockets/packets/guild_scheduled_event_create.dart index 7bf8d0c6a..91a972e6f 100644 --- a/lib/src/internal/websockets/packets/guild_scheduled_event_create.dart +++ b/lib/src/internal/websockets/packets/guild_scheduled_event_create.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_scheduled_event_delete.dart b/lib/src/internal/websockets/packets/guild_scheduled_event_delete.dart index d4890c1fc..f4a9a906c 100644 --- a/lib/src/internal/websockets/packets/guild_scheduled_event_delete.dart +++ b/lib/src/internal/websockets/packets/guild_scheduled_event_delete.dart @@ -1,8 +1,6 @@ -import 'dart:convert'; - import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_scheduled_event_update.dart b/lib/src/internal/websockets/packets/guild_scheduled_event_update.dart index 7f88a8168..2cd250b42 100644 --- a/lib/src/internal/websockets/packets/guild_scheduled_event_update.dart +++ b/lib/src/internal/websockets/packets/guild_scheduled_event_update.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_scheduled_event_user_add.dart b/lib/src/internal/websockets/packets/guild_scheduled_event_user_add.dart index 3347223de..f5a0e11d9 100644 --- a/lib/src/internal/websockets/packets/guild_scheduled_event_user_add.dart +++ b/lib/src/internal/websockets/packets/guild_scheduled_event_user_add.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_scheduled_event_user_remove.dart b/lib/src/internal/websockets/packets/guild_scheduled_event_user_remove.dart index 92b22fb3c..8af9423f2 100644 --- a/lib/src/internal/websockets/packets/guild_scheduled_event_user_remove.dart +++ b/lib/src/internal/websockets/packets/guild_scheduled_event_user_remove.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/guild_update.dart b/lib/src/internal/websockets/packets/guild_update.dart index 8b9e39e0c..3617a79c3 100644 --- a/lib/src/internal/websockets/packets/guild_update.dart +++ b/lib/src/internal/websockets/packets/guild_update.dart @@ -7,7 +7,7 @@ import 'package:mineral/src/api/managers/guild_scheduled_event_manager.dart'; import 'package:mineral/src/api/managers/member_manager.dart'; import 'package:mineral/src/api/managers/moderation_rule_manager.dart'; import 'package:mineral/src/api/managers/webhook_manager.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/interaction_create.dart b/lib/src/internal/websockets/packets/interaction_create.dart index 96725c982..7b930d7b8 100644 --- a/lib/src/internal/websockets/packets/interaction_create.dart +++ b/lib/src/internal/websockets/packets/interaction_create.dart @@ -6,8 +6,8 @@ import 'package:mineral/core.dart'; import 'package:mineral/src/api/components/component.dart'; import 'package:mineral/src/api/interactions/button_interaction.dart'; import 'package:mineral/src/api/interactions/select_menu_interaction.dart'; -import 'package:mineral/src/internal/entities/command_manager.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/command_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/member_join_request.dart b/lib/src/internal/websockets/packets/member_join_request.dart index e3126ad3f..0276a2b7c 100644 --- a/lib/src/internal/websockets/packets/member_join_request.dart +++ b/lib/src/internal/websockets/packets/member_join_request.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/message_create.dart b/lib/src/internal/websockets/packets/message_create.dart index aa1be6deb..b6890e257 100644 --- a/lib/src/internal/websockets/packets/message_create.dart +++ b/lib/src/internal/websockets/packets/message_create.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/message_delete.dart b/lib/src/internal/websockets/packets/message_delete.dart index e86cc4f12..32c6eecc7 100644 --- a/lib/src/internal/websockets/packets/message_delete.dart +++ b/lib/src/internal/websockets/packets/message_delete.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/message_update.dart b/lib/src/internal/websockets/packets/message_update.dart index 3b1f30b2a..2c531db12 100644 --- a/lib/src/internal/websockets/packets/message_update.dart +++ b/lib/src/internal/websockets/packets/message_update.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/presence_update.dart b/lib/src/internal/websockets/packets/presence_update.dart index 364cc377f..dddc167a9 100644 --- a/lib/src/internal/websockets/packets/presence_update.dart +++ b/lib/src/internal/websockets/packets/presence_update.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/ready.dart b/lib/src/internal/websockets/packets/ready.dart index 28f051f99..d5db1dd05 100644 --- a/lib/src/internal/websockets/packets/ready.dart +++ b/lib/src/internal/websockets/packets/ready.dart @@ -1,7 +1,7 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/command_manager.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/command_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/sharding/shard.dart'; import 'package:mineral/src/internal/websockets/sharding/shard_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; diff --git a/lib/src/internal/websockets/packets/resumed.dart b/lib/src/internal/websockets/packets/resumed.dart index 1b6d63a1a..28a07bac2 100644 --- a/lib/src/internal/websockets/packets/resumed.dart +++ b/lib/src/internal/websockets/packets/resumed.dart @@ -1,5 +1,4 @@ import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/voice_state_update.dart b/lib/src/internal/websockets/packets/voice_state_update.dart index ec0d5ca08..c32edbba0 100644 --- a/lib/src/internal/websockets/packets/voice_state_update.dart +++ b/lib/src/internal/websockets/packets/voice_state_update.dart @@ -1,10 +1,7 @@ -import 'dart:convert'; - import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/voice_manager.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; -import 'package:mineral/src/internal/event_emitter.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; diff --git a/lib/src/internal/websockets/packets/webhook_update.dart b/lib/src/internal/websockets/packets/webhook_update.dart index 16920c384..0ad130904 100644 --- a/lib/src/internal/websockets/packets/webhook_update.dart +++ b/lib/src/internal/websockets/packets/webhook_update.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/event_manager.dart'; +import 'package:mineral/src/internal/managers/event_manager.dart'; import 'package:mineral/src/internal/websockets/websocket_packet.dart'; import 'package:mineral/src/internal/websockets/websocket_response.dart'; From 962499c808199a3c0081cc06106395fe0f857683 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 01:13:36 +0200 Subject: [PATCH 34/68] refactor: Refactor folder name --- bin/mineral.dart | 2 +- lib/src/api/client/mineral_client.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/mineral.dart b/bin/mineral.dart index 02707a007..490333b90 100644 --- a/bin/mineral.dart +++ b/bin/mineral.dart @@ -1,7 +1,7 @@ import 'package:args/args.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/internal/entities/cli_manager.dart'; +import 'package:mineral/src/internal/managers/cli_manager.dart'; Future main (List arguments) async { Kernel kernel = Kernel(); diff --git a/lib/src/api/client/mineral_client.dart b/lib/src/api/client/mineral_client.dart index 123a428fd..f744b7b66 100644 --- a/lib/src/api/client/mineral_client.dart +++ b/lib/src/api/client/mineral_client.dart @@ -5,7 +5,7 @@ import 'package:mineral/src/api/managers/guild_manager.dart'; import 'package:mineral/src/api/managers/user_manager.dart'; import 'package:mineral/src/internal/websockets/sharding/shard_manager.dart'; -import '../../internal/entities/command_manager.dart'; +import 'package:mineral/src/internal/managers/command_manager.dart'; enum Intent { guilds(1 << 0), From 43cf9a193c08191c2ea5f682de91c627bdd67f23 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 01:23:08 +0200 Subject: [PATCH 35/68] fix: Missing load commands --- bin/mineral.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/mineral.dart b/bin/mineral.dart index 490333b90..561078882 100644 --- a/bin/mineral.dart +++ b/bin/mineral.dart @@ -5,6 +5,8 @@ import 'package:mineral/src/internal/managers/cli_manager.dart'; Future main (List arguments) async { Kernel kernel = Kernel(); + kernel.loadConsole(); + final ArgParser parser = ArgParser(); final makeCommandParser = ArgParser(); From 907c882fcc8c948e053c0f7c1f3e09abf788e841 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 01:31:57 +0200 Subject: [PATCH 36/68] fix: Force lowercase --- lib/src/commands/make_command.dart | 1 + lib/src/internal/managers/command_manager.dart | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/commands/make_command.dart b/lib/src/commands/make_command.dart index 83ac68f14..c4c990a8e 100644 --- a/lib/src/commands/make_command.dart +++ b/lib/src/commands/make_command.dart @@ -63,6 +63,7 @@ import 'package:mineral/api.dart'; class ${filename.pascalCase} extends MineralCommand { Future handle (CommandInteraction interaction) async { // Your code here + await interaction.reply(content: 'Hello World ! 💪'); } } '''; diff --git a/lib/src/internal/managers/command_manager.dart b/lib/src/internal/managers/command_manager.dart index 081ccb9b0..2a75ca119 100644 --- a/lib/src/internal/managers/command_manager.dart +++ b/lib/src/internal/managers/command_manager.dart @@ -63,7 +63,7 @@ class CommandManager { if (reflectee is CommandGroup) { SlashCommand group = SlashCommand(name: '', description: '', scope: '', options: []) ..type = 2 - ..name = reflectee.name + ..name = reflectee.name.toLowerCase() ..description = reflectee.description; command.groups.add(group); @@ -71,7 +71,7 @@ class CommandManager { if (reflectee is Command) { command - ..name = reflectee.name + ..name = reflectee.name.toLowerCase() ..description = reflectee.description ..scope = reflectee.scope; From ae397bc20e60b5449effcb4bcd4f148727673ab2 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Fri, 15 Jul 2022 01:37:43 +0200 Subject: [PATCH 37/68] =?UTF-8?q?refactor:=20Rename=20BaseChannel=20?= =?UTF-8?q?=E2=86=92=20PartialChannel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/api/channels/base_channel.dart | 7 ------- lib/src/api/channels/category_channel.dart | 1 - lib/src/api/channels/channel.dart | 4 ++-- lib/src/api/channels/dm_channel.dart | 4 ++-- lib/src/api/channels/partial_channel.dart | 7 +++++++ lib/src/api/channels/public_thread.dart | 4 ++-- lib/src/api/channels/text_channel.dart | 1 - lib/src/api/channels/voice_channel.dart | 1 - lib/src/api/messages/partial_message.dart | 4 ++-- 9 files changed, 15 insertions(+), 18 deletions(-) delete mode 100644 lib/src/api/channels/base_channel.dart create mode 100644 lib/src/api/channels/partial_channel.dart diff --git a/lib/src/api/channels/base_channel.dart b/lib/src/api/channels/base_channel.dart deleted file mode 100644 index e94c0cc21..000000000 --- a/lib/src/api/channels/base_channel.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:mineral/api.dart'; - -class BaseChannel { - Snowflake id; - - BaseChannel({ required this.id }); -} diff --git a/lib/src/api/channels/category_channel.dart b/lib/src/api/channels/category_channel.dart index 475e5525d..70cee6aa8 100644 --- a/lib/src/api/channels/category_channel.dart +++ b/lib/src/api/channels/category_channel.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/api/channels/channel.dart'; import 'package:mineral/src/api/managers/webhook_manager.dart'; class CategoryChannel extends Channel { diff --git a/lib/src/api/channels/channel.dart b/lib/src/api/channels/channel.dart index 3f89339f6..429b6464a 100644 --- a/lib/src/api/channels/channel.dart +++ b/lib/src/api/channels/channel.dart @@ -1,7 +1,7 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/api/channels/base_channel.dart'; +import 'package:mineral/src/api/channels/partial_channel.dart'; import 'package:mineral/src/api/managers/webhook_manager.dart'; enum ChannelType { @@ -37,7 +37,7 @@ Map channels = { // 'GUILD_FORUM': () => , }; -class Channel extends BaseChannel { +class Channel extends PartialChannel { ChannelType type; Snowflake? guildId; late Guild? guild; diff --git a/lib/src/api/channels/dm_channel.dart b/lib/src/api/channels/dm_channel.dart index 3f65361d9..bc186131e 100644 --- a/lib/src/api/channels/dm_channel.dart +++ b/lib/src/api/channels/dm_channel.dart @@ -1,9 +1,9 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/api/channels/base_channel.dart'; +import 'package:mineral/src/api/channels/partial_channel.dart'; import 'package:mineral/src/api/managers/message_manager.dart'; -class DmChannel extends BaseChannel { +class DmChannel extends PartialChannel { Snowflake? lastMessageId; MessageManager messages; Map recipients; diff --git a/lib/src/api/channels/partial_channel.dart b/lib/src/api/channels/partial_channel.dart new file mode 100644 index 000000000..a76088b16 --- /dev/null +++ b/lib/src/api/channels/partial_channel.dart @@ -0,0 +1,7 @@ +import 'package:mineral/api.dart'; + +class PartialChannel { + Snowflake id; + + PartialChannel({ required this.id }); +} diff --git a/lib/src/api/channels/public_thread.dart b/lib/src/api/channels/public_thread.dart index 0483d253a..59a2d2cf7 100644 --- a/lib/src/api/channels/public_thread.dart +++ b/lib/src/api/channels/public_thread.dart @@ -6,7 +6,7 @@ class PublicThread extends Channel { String? name; Snowflake? lastMessageId; - DateTime? lastPinTimstamp; + DateTime? lastPinTimestamp; PublicThread({ required Snowflake id, @@ -48,4 +48,4 @@ class PublicThread extends Channel { webhooks: payload['webhooks'], ); } -} \ No newline at end of file +} diff --git a/lib/src/api/channels/text_channel.dart b/lib/src/api/channels/text_channel.dart index 7d558e539..bf78478ea 100644 --- a/lib/src/api/channels/text_channel.dart +++ b/lib/src/api/channels/text_channel.dart @@ -1,6 +1,5 @@ import 'package:mineral/api.dart'; import 'package:mineral/src/api/managers/message_manager.dart'; - import 'package:mineral/src/api/managers/thread_manager.dart'; class TextChannel extends TextBasedChannel { diff --git a/lib/src/api/channels/voice_channel.dart b/lib/src/api/channels/voice_channel.dart index 20ed86377..0869d7f80 100644 --- a/lib/src/api/channels/voice_channel.dart +++ b/lib/src/api/channels/voice_channel.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/api/channels/channel.dart'; import 'package:mineral/src/api/managers/webhook_manager.dart'; class VoiceChannel extends Channel { diff --git a/lib/src/api/messages/partial_message.dart b/lib/src/api/messages/partial_message.dart index 3427c1747..1ab46b531 100644 --- a/lib/src/api/messages/partial_message.dart +++ b/lib/src/api/messages/partial_message.dart @@ -1,11 +1,11 @@ import 'package:mineral/api.dart'; -import 'package:mineral/src/api/channels/base_channel.dart'; +import 'package:mineral/src/api/channels/partial_channel.dart'; import 'package:mineral/src/api/components/component.dart'; import 'package:mineral/src/api/messages/message_attachment.dart'; import 'package:mineral/src/api/messages/message_embed.dart'; import 'package:mineral/src/api/messages/message_sticker_item.dart'; -class PartialMessage { +class PartialMessage { Snowflake id; String content; bool tts; From db289d1c098da6b6a458720efc6c22df8d01cfde Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 09:31:45 +0200 Subject: [PATCH 38/68] docs: Write User send message --- lib/src/api/user.dart | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/src/api/user.dart b/lib/src/api/user.dart index ae9274329..ba3191946 100644 --- a/lib/src/api/user.dart +++ b/lib/src/api/user.dart @@ -18,6 +18,22 @@ class User { String? avatarDecoration; late Status status; + User({ + required this.id, + required this.username, + required this.tag, + required this.discriminator, + required this.bot, + required this.publicFlags, + required this.avatar, + required this.avatarDecoration, + }); + + /// Envoie un message en DM à l'utilisateur + /// ```dart + /// GuildMember? member = guild.members.cache.get('240561194958716924'); + /// await member.user.send(content: 'Hello World !'); + /// ``` Future send ({ String? content, List? embeds, List? components, bool? tts }) async { MineralClient client = ioc.singleton(ioc.services.client); Http http = ioc.singleton(ioc.services.http); @@ -50,19 +66,8 @@ class User { return null; } - User({ - required this.id, - required this.username, - required this.tag, - required this.discriminator, - required this.bot, - required this.publicFlags, - required this.avatar, - required this.avatarDecoration, - }); - String getDisplayAvatarUrl () { - return "${Constants.cdnUrl}/avatars/$id/$avatar"; + return '${Constants.cdnUrl}/avatars/$id/$avatar'; } @override From ee992b6b4880acf82e2f2c45c7a4424b111a2c55 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 09:32:04 +0200 Subject: [PATCH 39/68] docs: Write User getDisplayAvatarUrl --- lib/src/api/user.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/api/user.dart b/lib/src/api/user.dart index ba3191946..3f1047762 100644 --- a/lib/src/api/user.dart +++ b/lib/src/api/user.dart @@ -66,6 +66,7 @@ class User { return null; } + /// Returns the absolute url to the user's avatar String getDisplayAvatarUrl () { return '${Constants.cdnUrl}/avatars/$id/$avatar'; } From 61daccc85cdf4291193d766416415ab6bd59c085 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 09:35:32 +0200 Subject: [PATCH 40/68] docs: Write Color --- lib/src/api/color.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/api/color.dart b/lib/src/api/color.dart index f0aa0d5d7..300280407 100644 --- a/lib/src/api/color.dart +++ b/lib/src/api/color.dart @@ -1,3 +1,14 @@ +/// Instance of colour. +/// You can use a pre-designed colour panel +/// ```dart +/// import 'package:mineral/api.dart'; +/// print(Color.cyan_600); +/// ``` +/// Or create your own colour instances +/// ```dart +/// import 'package:mineral/api.dart'; +/// print(Color('#FFFFFF')); +// ``` class Color { static Color amber_50 = Color('#fff7ed'); static Color amber_100 = Color('#ffedd5'); From 96c1777d55e1df3fb64c36af0ff66589a17b5bd7 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 09:53:10 +0200 Subject: [PATCH 41/68] docs: Write moderation rules --- lib/src/api/moderation_rule.dart | 53 +++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/lib/src/api/moderation_rule.dart b/lib/src/api/moderation_rule.dart index 57063ec63..3f0543b70 100644 --- a/lib/src/api/moderation_rule.dart +++ b/lib/src/api/moderation_rule.dart @@ -119,6 +119,10 @@ class ModerationRule { required this.exemptChannels, }); + /// Update the label of this + /// ```dart + /// await rule.setLabel('My label'); + /// ``` Future setLabel(String label) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$guildId/auto-moderation/rules/$id", payload: { 'label': label }); @@ -128,6 +132,10 @@ class ModerationRule { } } + /// Update the event of this + /// ```dart + /// await rule.setEventType(ModerationEventType.messageSend); + /// ``` Future setEventType(ModerationEventType event) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$guildId/auto-moderation/rules/$id", payload: { 'event_type': event.value }); @@ -137,6 +145,15 @@ class ModerationRule { } } + /// Update the trigger metadata of this + /// ```dart + /// final metadata = ModerationTriggerMetadata( + /// keywordFilter: ['foo'], + /// presets: [ModerationPresetType.profanity] + /// ); + /// + /// await rule.setTriggerMetadata(metadata); + /// ``` Future setTriggerMetadata(ModerationTriggerMetadata triggerMetadata) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$guildId/auto-moderation/rules/$id", payload: { 'trigger_metadata': triggerMetadata.toJson() }); @@ -146,6 +163,17 @@ class ModerationRule { } } + /// Update actions of this + /// ```dart + /// final channel = guild.channels.cache.get('240561194958716924'); + /// + /// final action = ModerationAction( + /// metadata: ModerationActionMetadata(duration: 3000, channel: channel), + /// type: ModerationActionType.sendAlertMessage + /// ); + /// + /// await rule.setActions([action]); + /// ``` Future setActions(List actions) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$guildId/auto-moderation/rules/$id", payload: { @@ -157,6 +185,10 @@ class ModerationRule { } } + /// Update enabled of this + /// ```dart + /// await rule.setEnabled(true); + /// ``` Future setEnabled(bool value) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$guildId/auto-moderation/rules/$id", payload: { 'value': value }); @@ -166,6 +198,14 @@ class ModerationRule { } } + /// Defines which roles will not be affected by this + /// ```dart + /// final role = guild.roles.cache.get('240561194958716924'); + /// + /// if (role != null) { + /// await rule.setExemptRoles([role]); + /// } + /// ``` Future setExemptRoles(List roles) async { int maxItems = 50; if (roles.length > maxItems) { @@ -182,6 +222,14 @@ class ModerationRule { } } + /// Defines which roles will not be affected by this + /// ```dart + /// final channel = guild.channels.cache.get('240561194958716924'); + /// + /// if (channel != null) { + /// await rule.setExemptChannels([channel]); + /// } + /// ``` Future setExemptChannels(List channels) async { int maxItems = 50; if (channels.length > maxItems) { @@ -197,7 +245,10 @@ class ModerationRule { exemptChannels = channels; } } - + /// Delete this + /// ```dart + /// await rule.delete(); + /// ``` Future delete() async { Http http = ioc.singleton(ioc.services.http); Response response = await http.destroy(url: "/guilds/$guildId/auto-moderation/rules/$id"); From d84e78f550d3707d62395bf7858d4d43768acb38 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 10:00:49 +0200 Subject: [PATCH 42/68] docs: Write webhooks --- lib/src/api/webhook.dart | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/src/api/webhook.dart b/lib/src/api/webhook.dart index 9e2f3c90d..67634efa6 100644 --- a/lib/src/api/webhook.dart +++ b/lib/src/api/webhook.dart @@ -42,7 +42,11 @@ class Webhook { required this.url, }); - Future setName (String label) async { + /// Update the label of this + /// ```dart + /// await webhook.setLabel('My webhook name'); + /// ``` + Future setLabel (String label) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/webhooks/$id", payload: { 'name': label }); @@ -51,6 +55,10 @@ class Webhook { } } + /// Update the avatar of this + /// ```dart + /// await webhook.setAvatar('assets/images/my_picture.png'); + /// ``` Future setAvatar (String avatar) async { Http http = ioc.singleton(ioc.services.http); String path = await Helper.getPicture(avatar); @@ -61,6 +69,11 @@ class Webhook { } } + /// Updates multiple properties of this in a single request. + /// When you need to update more than 2 fields, we advise you to use this method to reduce the number of outgoing requests. + /// ```dart + /// await webhook.update(label: 'My webhook name', avatar: 'assets/images/my_picture.png'); + /// ``` Future update ({ String? label, String? avatar }) async { Http http = ioc.singleton(ioc.services.http); String? path = avatar != null @@ -77,7 +90,10 @@ class Webhook { if (avatar != null) this.avatar = path; } } - + /// Send a message from the webhook + /// ```dart + /// await webhook.execute(content: 'Hello World !'); + /// ``` Future execute ({ String? content, String? username, String? avatarUrl, bool? tts, List? embeds, List? components, bool? suppressEmbed }) async { Http http = ioc.singleton(ioc.services.http); @@ -106,6 +122,10 @@ class Webhook { }); } + /// Delete this + /// ```dart + /// await webhook.delete(); + /// ``` Future delete () async { Http http = ioc.singleton(ioc.services.http); Response response = await http.destroy(url: "/webhooks/$id/$token"); From 35d7f85357441c3fd8ecb1c9ff5531ef5dc0dd72 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 10:05:36 +0200 Subject: [PATCH 43/68] docs: Write guildMember voices --- lib/src/api/voice.dart | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/lib/src/api/voice.dart b/lib/src/api/voice.dart index 0e6b1c0e8..e0f72c843 100644 --- a/lib/src/api/voice.dart +++ b/lib/src/api/voice.dart @@ -15,6 +15,13 @@ class Voice { required this.channelId, }); + /// Mutes a server member + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await member.mute(); + /// } Future mute () async { Http http = ioc.singleton(ioc.services.http); @@ -24,6 +31,13 @@ class Voice { } } + /// Remove mutes a server member + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await member.unmute(); + /// } Future unmute () async { Http http = ioc.singleton(ioc.services.http); @@ -33,6 +47,13 @@ class Voice { } } + /// Deafens a server member + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await member.deaf(); + /// } Future deaf () async { Http http = ioc.singleton(ioc.services.http); @@ -42,6 +63,13 @@ class Voice { } } + /// Remove deafens a server member + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await member.undeaf(); + /// } Future undeaf () async { Http http = ioc.singleton(ioc.services.http); @@ -51,6 +79,14 @@ class Voice { } } + /// Moves a member from one voice channel to another + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// final voiceChannel = guild.channels.cache.get('240561194958716924'); + /// + /// if (member != null && voiceChannel != null) { + /// await member.move(voiceChannel); + /// } Future move (VoiceChannel channel) async { Http http = ioc.singleton(ioc.services.http); @@ -60,7 +96,13 @@ class Voice { this.channel = channel; } } - + /// Disconnects the user from a voice channel + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await member.disconnect(); + /// } Future disconnect () async { Http http = ioc.singleton(ioc.services.http); From bc3c8a432b11a563de1f3876fba7e53896aa6a90 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 10:09:22 +0200 Subject: [PATCH 44/68] docs: Write mineral_client.dart --- lib/src/api/client/mineral_client.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/src/api/client/mineral_client.dart b/lib/src/api/client/mineral_client.dart index f744b7b66..f2ba48585 100644 --- a/lib/src/api/client/mineral_client.dart +++ b/lib/src/api/client/mineral_client.dart @@ -89,7 +89,14 @@ class MineralClient { required this.intents, }); - setPresence ({ ClientActivity? activity, ClientStatus? status, bool? afk }) { + /// Defines the presence that this should adopt + /// ```dart + /// client.setPresence( + /// activity: ClientActivity(name: 'My activity', type: GamePresence.listening), + /// status: ClientStatus.doNotDisturb + /// ); + /// ``` + void setPresence ({ ClientActivity? activity, ClientStatus? status, bool? afk }) { ShardManager manager = ioc.singleton(ioc.services.shards); manager.send(OpCode.statusUpdate, { 'since': DateTime.now().millisecond, @@ -99,6 +106,10 @@ class MineralClient { }); } + /// Sends a ping/pong to the APi websocket of discord and returns the latency + /// ```dart + /// final int latency = client.getLatency(); + /// ``` int getLatency () { ShardManager manager = ioc.singleton(ioc.services.shards); return manager.getLatency(); From 0d958bf0c95b7385aef1bd921b000610cb23eeee Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 10:13:39 +0200 Subject: [PATCH 45/68] docs: Write modal --- lib/src/api/components/modal.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/src/api/components/modal.dart b/lib/src/api/components/modal.dart index f41490dbc..ad4541545 100644 --- a/lib/src/api/components/modal.dart +++ b/lib/src/api/components/modal.dart @@ -11,11 +11,21 @@ class Modal extends Component { Modal({ required this.customId, required this.label }) : super(type: ComponentType.selectMenu); + /// Created a input text field + /// ```dart + /// final Modal modal = Modal(customId: 'my_modal', label: 'My modal') + /// .addInput(customId: 'my_text', label: 'Premier texte'); + /// ``` Modal addInput ({ required String customId, required String label, bool? required, int? minLength, int? maxLength, String? placeholder, String? value }) { _addInput(customId: customId, label: label, style: TextInputStyle.short, required: required, minLength: minLength, maxLength: maxLength, placeholder: placeholder, value: value); return this; } + /// Created a input text field with multiple lines + /// ```dart + /// final Modal modal = Modal(customId: 'my_modal', label: 'My modal') + /// .addParagraph(customId: 'my_paragraph', label: 'Second texte'); + /// ``` Modal addParagraph ({ required String customId, required String label, bool? required, int? minLength, int? maxLength, String? placeholder, String? value }) { _addInput(customId: customId, label: label, style: TextInputStyle.paragraph, required: required, minLength: minLength, maxLength: maxLength, placeholder: placeholder, value: value); return this; From c26dd006b5a4bdee773c6ee97dea59dd21988987 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 10:33:45 +0200 Subject: [PATCH 46/68] docs: Write Guild --- lib/src/api/guilds/guild.dart | 117 ++++++++++++++++++++++++++++++++-- 1 file changed, 113 insertions(+), 4 deletions(-) diff --git a/lib/src/api/guilds/guild.dart b/lib/src/api/guilds/guild.dart index 4856d4fbd..18e755693 100644 --- a/lib/src/api/guilds/guild.dart +++ b/lib/src/api/guilds/guild.dart @@ -154,17 +154,29 @@ class Guild { } } - Future setMessageNotification (int level) async { + /// Defines the notification level of this + /// - 0 → All messages + /// - 1 → Only mentions + /// ```dart + /// await guild.setMessageNotification(1); + /// ``` + Future setMessageNotification (int level) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$id", payload: { 'default_message_notifications': level }); if (response.statusCode == 200) { defaultMessageNotifications = level; } - - return this; } + /// Defines the explicit content level of this + /// - 0 → Disabled + /// - 1 → Members without roles + /// - 2 → All members + /// + /// ```dart + /// await guild.setExplicitContentFilter(2); + /// ``` Future setExplicitContentFilter (int level) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$id", payload: { 'explicit_content_filter': level }); @@ -174,6 +186,14 @@ class Guild { } } + /// Update the afk channel + /// ```dart + /// final voiceChannel = guild.channels.cache.get('240561194958716924'); + /// + /// if (voiceChannel != null) { + /// await guild.setAfkChannel(2); + /// } + /// ``` Future setAfkChannel (VoiceChannel channel) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$id", payload: { 'afk_channel_id': channel.id }); @@ -183,7 +203,18 @@ class Guild { afkChannelId = channel.id; } } - + /// Update the owner of this + /// + /// Warning : This method only works if the server was created via a discord bot and the bot is the current owner + /// + /// See [documentation](Warning: This method only works if the server was created via a discord bot) + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await guild.setOwner(member); + /// } + /// ``` Future setOwner (GuildMember guildMember) async { MineralClient client = ioc.singleton(ioc.services.client); Http http = ioc.singleton(ioc.services.http); @@ -201,6 +232,12 @@ class Guild { } } + /// Update the splash banner of this + /// + /// This method requires the feature [GuildFeature.banner] of this + /// ```dart + /// await guild.setSplash('assets/images/my_splash_banner.png'); + /// ``` Future setSplash (String filename) async { if (!features.contains(GuildFeature.banner)) { throw MissingFeatureException(cause: "The $name guild does not have the ${GuildFeature.inviteSplash} feature."); @@ -216,6 +253,12 @@ class Guild { } } + /// Remove the splash banner of this + /// + /// This method requires the feature [GuildFeature.banner] of this + /// ```dart + /// await guild.removeSplash(); + /// ``` Future removeSplash () async { if (!features.contains(GuildFeature.banner)) { throw MissingFeatureException(cause: "The $name guild does not have the ${GuildFeature.inviteSplash} feature."); @@ -229,6 +272,12 @@ class Guild { } } + /// Update the discovery splash banner of this + /// + /// This method requires the feature [GuildFeature.banner] of this + /// ```dart + /// await guild.setDiscoverySplash('assets/images/my_splash_discovery_banner.png'); + /// ``` Future setDiscoverySplash (String filename) async { if (!features.contains(GuildFeature.banner)) { throw MissingFeatureException(cause: "The $name guild does not have the ${GuildFeature.discoverable} feature."); @@ -244,6 +293,12 @@ class Guild { } } + /// Remove the discovery splash banner of this + /// + /// This method requires the feature [GuildFeature.banner] of this + /// ```dart + /// await guild.removeDiscoverySplash(); + /// ``` Future removeDiscoverySplash () async { if (!features.contains(GuildFeature.banner)) { throw MissingFeatureException(cause: "The $name guild does not have the ${GuildFeature.discoverable} feature."); @@ -257,6 +312,12 @@ class Guild { } } + /// Update the banner of this + /// + /// This method requires the feature [GuildFeature.banner] of this + /// ```dart + /// await guild.setBanner('assets/images/my_banner.png'); + /// ``` Future setBanner (String filename) async { if (!features.contains(GuildFeature.banner)) { throw MissingFeatureException(cause: "The $name guild does not have the ${GuildFeature.banner} feature."); @@ -272,6 +333,12 @@ class Guild { } } + /// Remove the banner of this + /// + /// This method requires the feature [GuildFeature.banner] of this + /// ```dart + /// await guild.removeBanner(); + /// ``` Future removeBanner () async { if (!features.contains(GuildFeature.banner)) { throw MissingFeatureException(cause: "The $name guild does not have the ${GuildFeature.banner} feature."); @@ -285,6 +352,10 @@ class Guild { } } + /// Update the icon of this + /// ```dart + /// await guild.setIcon('assets/images/my_guild_icon.png'); + /// ``` Future setIcon (String filename) async { String file = await Helper.getPicture(filename); @@ -296,6 +367,10 @@ class Guild { } } + /// Remove the icon of this + /// ```dart + /// await guild.removeIcon(); + /// ``` Future removeIcon () async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$id", payload: { 'icon': null }); @@ -305,6 +380,14 @@ class Guild { } } + /// Update system channel of this + /// ```dart + /// final channel = guild.channels.cache.get('240561194958716924'); + /// + /// if (channel != null) { + /// await guild.setSystemChannel(channel); + /// } + /// ``` Future setSystemChannel (TextChannel channel) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$id", payload: { 'system_channel_id': channel.id }); @@ -315,6 +398,14 @@ class Guild { } } + /// Update rules channel of this + /// ```dart + /// final channel = guild.channels.cache.get('240561194958716924'); + /// + /// if (channel != null) { + /// await guild.setRulesChannel(channel); + /// } + /// ``` Future setRulesChannel (TextChannel channel) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$id", payload: { 'rules_channel_id': channel.id }); @@ -325,6 +416,14 @@ class Guild { } } + /// Update public updates channel of this + /// ```dart + /// final channel = guild.channels.cache.get('240561194958716924'); + /// + /// if (channel != null) { + /// await guild.setPublicUpdateChannel(channel); + /// } + /// ``` Future setPublicUpdateChannel (TextChannel channel) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$id", payload: { 'public_updates_channel_id': channel.id }); @@ -335,6 +434,12 @@ class Guild { } } + /// Update preferred language of this + /// ```dart + /// import 'package:mineral/api.dart'; + /// + /// await guild.setPreferredLocale(Locale.fr); // 👈 Now you can use Lang enum + /// ``` Future setPreferredLocale (Locale locale) async { Http http = ioc.singleton(ioc.services.http); Response response = await http.patch(url: "/guilds/$id", payload: { 'public_updates_channel_id': locale }); @@ -344,6 +449,10 @@ class Guild { } } + /// Remove the discord client of this + /// ```dart + /// await guild.leave(); + /// ``` Future leave () async { Http http = ioc.singleton(ioc.services.http); Response response = await http.destroy(url: '/users/@me/guilds/$id'); From 6366a442ca42a1470084c3b81cb1dc5f5e21bd58 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 10:45:27 +0200 Subject: [PATCH 47/68] docs: Write GuildMember --- lib/src/api/guilds/guild_member.dart | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/src/api/guilds/guild_member.dart b/lib/src/api/guilds/guild_member.dart index 11738b184..4facc1af7 100644 --- a/lib/src/api/guilds/guild_member.dart +++ b/lib/src/api/guilds/guild_member.dart @@ -30,6 +30,10 @@ class GuildMember { required this.voice, }); + /// Update the username of this + /// ```dart + /// await member.setUsername('John Doe'); + /// ``` Future setUsername (String name) async { Http http = ioc.singleton(ioc.services.http); @@ -39,6 +43,15 @@ class GuildMember { } } + /// Excludes this for a pre-defined period + /// + /// Note: An exclusion cannot exceed 28 days + /// + /// See [documentation](https://discord.com/developers/docs/resources/guild#modify-guild-member) + /// ```dart + /// final DateTime = DateTime.now().add(Duration(days: 28)); + /// await member.timeout(DateTime); + /// ``` Future timeout (DateTime expiration) async { // @Todo add ADMINISTRATOR permission or is the owner of the guild constraint Http http = ioc.singleton(ioc.services.http); @@ -49,6 +62,10 @@ class GuildMember { } } + /// Cancels the exclusion of this + /// ```dart + /// await member.removeTimeout(); + /// ``` Future removeTimeout () async { Http http = ioc.singleton(ioc.services.http); @@ -58,6 +75,14 @@ class GuildMember { } } + /// banned this from the [Guild] and deleted its messages for a given period + /// ```dart + /// await member.ban(); + /// ``` + /// With the deletion of his messages for 7 days + /// ```dart + /// await member.ban(count: 7); + /// ``` Future ban ({ int? count, String? reason }) async { Http http = ioc.singleton(ioc.services.http); @@ -71,13 +96,25 @@ class GuildMember { } } + /// Kick this of [Guild] + /// ```dart + /// await member.removeTimeout(); + /// ``` Future kick ({ int? count, String? reason }) async { Http http = ioc.singleton(ioc.services.http); await http.destroy(url: "/guilds/${guild.id}/members/${user.id}"); } + /// Returns whether of this is a bot + /// ```dart + /// print(member.isBot()); + /// ``` bool isBot () => user.bot; + /// Returns whether of this is pending + /// ```dart + /// print(member.isPending()); + /// ``` bool isPending () => pending; @override From 9369c56b3061450249c84fe961e33691cdb3982c Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 10:53:44 +0200 Subject: [PATCH 48/68] docs: Write GuildRoleManager --- lib/src/api/guilds/guild_role_manager.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/src/api/guilds/guild_role_manager.dart b/lib/src/api/guilds/guild_role_manager.dart index 229acc7d7..b8785a222 100644 --- a/lib/src/api/guilds/guild_role_manager.dart +++ b/lib/src/api/guilds/guild_role_manager.dart @@ -16,6 +16,10 @@ class GuildRoleManager implements CacheManager { GuildRoleManager({ required this.guildId }); + /// Synchronise the cache from the Discord API + /// ```dart + /// await guild.roles.sync(); + /// ``` @override Future> sync () async { Http http = ioc.singleton(ioc.services.http); @@ -35,6 +39,17 @@ class GuildRoleManager implements CacheManager { return cache; } + /// Create a this + /// + /// Warning: if you want to define an icon, the [Guid] must have the feature [GuildFeature.roleIcons] + /// ```dart + /// await guild.roles.create( + /// label: 'My role', + /// color: Color.cyan_600, + /// permissions: [Permission.moderateMembers, Permission.banMembers], + /// hoist: true, + /// ); + /// ``` Future create ({ required String label, Color? color, bool? hoist, String? icon, String? unicode, bool? mentionable, List? permissions }) async { if ((icon != null || unicode != null) && !guild.features.contains('ROLE_ICONS')) { throw MissingFeatureException(cause: "Guild ${guild.name} has no 'ROLE_ICONS' feature."); From 0526f7c10c4dddeb1345d99f412813db6a49c540 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 10:54:13 +0200 Subject: [PATCH 49/68] docs: Write MemberRoleManager --- lib/src/api/guilds/member_role_manager.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/api/guilds/member_role_manager.dart b/lib/src/api/guilds/member_role_manager.dart index 15dfe3428..8e5256631 100644 --- a/lib/src/api/guilds/member_role_manager.dart +++ b/lib/src/api/guilds/member_role_manager.dart @@ -21,11 +21,11 @@ class MemberRoleManager implements CacheManager { /// ```dart /// final Role? role = guild.roles.cache.get('446556480850755604'); /// final GuildMember? member = guild.members.cache.get('240561194958716924'); + /// /// if (member != null && role != null) { /// await member.roles.add(role.id) /// } /// ``` - /// /// You can pass a reason for the audit logs. /// ```dart /// await member.roles.add('446556480850755604', reason: 'I love this user'); From 0e18d4ec14a893f019ac677eaef74828fb761815 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:00:03 +0200 Subject: [PATCH 50/68] docs: Write CommandInteraction --- .../api/interactions/command_interaction.dart | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/src/api/interactions/command_interaction.dart b/lib/src/api/interactions/command_interaction.dart index 16465e103..b97cce46f 100644 --- a/lib/src/api/interactions/command_interaction.dart +++ b/lib/src/api/interactions/command_interaction.dart @@ -18,39 +18,76 @@ class CommandInteraction extends Interaction { required User user }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); + /// Returns an instance of [Channel] if the command has the designed option + /// ```dart + /// Channel? channel = interaction.getChannel('option_name'); + /// ``` T? getChannel (String optionName) { return guild?.channels.cache.get(data[optionName]?['value']); } + /// Returns an [int] if the command has the designed option + /// ```dart + /// int? value = interaction.getInteger('option_name'); + /// ``` int? getInteger (String optionName) { return data[optionName]?['value']; } + /// Returns an [String] if the command has the designed option + /// ```dart + /// String? str = interaction.getString('option_name'); + /// ``` String? getString (String optionName) { return data[optionName]?['value']; } + /// Returns an instance of [GuildMember] if the command has the designed option + /// ```dart + /// GuildMember? member = interaction.getMember('option_name'); + /// ``` GuildMember? getMember (String optionName) { return guild?.members.cache.get(data[optionName]?['value']); } + /// Returns an instance of [User] if the command has the designed option + /// ```dart + /// User? user = interaction.getUser('option_name'); + /// ``` User? getUser (String optionName) { final MineralClient client = ioc.singleton(ioc.services.client); return client.users.cache.get(data[optionName]?['value']); } + /// Returns an [bool] if the command has the designed option + /// ```dart + /// book? boolean = interaction.getBoolean('option_name'); + /// ``` bool? getBoolean (String optionName) { return data[optionName]?['value']; } + /// Returns an instance of [Role] if the command has the designed option + /// ```dart + /// Role? role = interaction.getRole('option_name'); + /// ``` Role? getRole (String optionName) { return guild?.roles.cache.get(data[optionName]?['value']); } + /// Returns an [T] if the command has the designed option + /// ```dart + /// String? str = interaction.getChoice('option_name'); + /// int? value = interaction.getChoice('option_name'); + /// ``` T? getChoice (String optionName) { return data[optionName]?['value']; } + /// Returns an value if the command has the designed option + /// ```dart + /// dynamic mentionable = interaction.getMentionable('option_name'); + /// ``` dynamic getMentionable (String optionName) { return data[optionName]?['value']; } From 9acf8d3162a7f876324f8912eb6e2e42882247e1 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:03:09 +0200 Subject: [PATCH 51/68] docs: Write Interaction --- lib/src/api/interactions/interaction.dart | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/src/api/interactions/interaction.dart b/lib/src/api/interactions/interaction.dart index 922ed94fc..a54d3a979 100644 --- a/lib/src/api/interactions/interaction.dart +++ b/lib/src/api/interactions/interaction.dart @@ -1,4 +1,3 @@ -import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; @@ -27,6 +26,10 @@ class Interaction { Interaction({ required this.id, required this.applicationId, required this.version, required this.type, required this.token, required this.user }); + /// Responds to this by an [Message] + /// ```dart + /// await interaction.reply(content: 'Hello ${interaction.user.username}'); + /// ``` Future reply ({ String? content, List? embeds, List? components, bool? tts, bool? private }) async { Http http = ioc.singleton(ioc.services.http); @@ -56,14 +59,20 @@ class Interaction { }); } + /// Responds to this by an [Modal] + /// ```dart + /// Modal modal = Modal(customId: 'modal', label: 'My modal') + /// .addInput(customId: 'my_text', label: 'First text') + /// .addParagraph(customId: 'my_paragraph', label: 'Second text'); + /// + /// await interaction.modal(modal); + /// ``` Future modal (Modal modal) async { Http http = ioc.singleton(ioc.services.http); - Response response = await http.post(url: "/interactions/$id/$token/callback", payload: { + await http.post(url: "/interactions/$id/$token/callback", payload: { 'type': InteractionCallbackType.modal.value, 'data': modal.toJson(), }); - - print(response.body); } } From 534c1251276b3979550b2dd7bc720dfc883b62f3 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:04:42 +0200 Subject: [PATCH 52/68] docs: Write ModalInteraction --- lib/src/api/interactions/modal_interaction.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/api/interactions/modal_interaction.dart b/lib/src/api/interactions/modal_interaction.dart index badc8bd80..930b7fae5 100644 --- a/lib/src/api/interactions/modal_interaction.dart +++ b/lib/src/api/interactions/modal_interaction.dart @@ -19,6 +19,10 @@ class ModalInteraction extends Interaction { required User user }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); + /// Return an [String] if the modal has the designed field + /// ```dart + /// String? field = interaction.getText('custom_field_id'); + /// ``` String? getText(String customId) => data.get(customId); factory ModalInteraction.from({ required User user, required Message? message, required dynamic payload }) { From 189e8ca105d146f7b442aa61d8d860bfe0d37f24 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:06:52 +0200 Subject: [PATCH 53/68] docs: Write SelectMenuInteraction --- lib/src/api/interactions/select_menu_interaction.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/src/api/interactions/select_menu_interaction.dart b/lib/src/api/interactions/select_menu_interaction.dart index 29e4a98d0..bf633fbca 100644 --- a/lib/src/api/interactions/select_menu_interaction.dart +++ b/lib/src/api/interactions/select_menu_interaction.dart @@ -19,8 +19,18 @@ class SelectMenuInteraction extends Interaction { required User user }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); + /// Return an [List] of [T] if this has the designed field + /// ```dart + /// List? fields = interaction.getValues(); + /// List? fields = interaction.getValues(); + /// ``` List getValues () => data as List; + /// Return the first [T] if this has the designed field + /// ```dart + /// String? field = interaction.getValue(); + /// int? field = interaction.getValue(); + /// ``` T getValue () => data.first as T; factory SelectMenuInteraction.from({ required User user, required Message? message, required dynamic payload }) { From f5107b59473f3c39d1e0fd4b897204cd769e8b3d Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:08:54 +0200 Subject: [PATCH 54/68] refactor: Move managers --- lib/src/api/guilds/guild.dart | 2 +- lib/src/api/guilds/guild_member.dart | 3 ++- lib/src/api/{guilds => managers}/guild_role_manager.dart | 0 lib/src/api/{guilds => managers}/member_role_manager.dart | 2 +- lib/src/api/role.dart | 2 +- lib/src/internal/websockets/packets/guild_create.dart | 4 ++-- lib/src/internal/websockets/packets/guild_update.dart | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) rename lib/src/api/{guilds => managers}/guild_role_manager.dart (100%) rename lib/src/api/{guilds => managers}/member_role_manager.dart (98%) diff --git a/lib/src/api/guilds/guild.dart b/lib/src/api/guilds/guild.dart index 18e755693..18662d105 100644 --- a/lib/src/api/guilds/guild.dart +++ b/lib/src/api/guilds/guild.dart @@ -4,7 +4,7 @@ import 'package:mineral/console.dart'; import 'package:mineral/core.dart'; import 'package:mineral/exception.dart'; import 'package:mineral/helper.dart'; -import 'package:mineral/src/api/guilds/guild_role_manager.dart'; +import 'package:mineral/src/api/managers/guild_role_manager.dart'; import 'package:mineral/src/api/managers/channel_manager.dart'; import 'package:mineral/src/api/managers/emoji_manager.dart'; import 'package:mineral/src/api/managers/guild_webhook_manager.dart'; diff --git a/lib/src/api/guilds/guild_member.dart b/lib/src/api/guilds/guild_member.dart index 4facc1af7..703de3244 100644 --- a/lib/src/api/guilds/guild_member.dart +++ b/lib/src/api/guilds/guild_member.dart @@ -1,7 +1,8 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/api/guilds/guild_role_manager.dart'; +import 'package:mineral/src/api/managers/guild_role_manager.dart'; +import 'package:mineral/src/api/managers/member_role_manager.dart'; import 'package:mineral/src/api/managers/voice_manager.dart'; class GuildMember { diff --git a/lib/src/api/guilds/guild_role_manager.dart b/lib/src/api/managers/guild_role_manager.dart similarity index 100% rename from lib/src/api/guilds/guild_role_manager.dart rename to lib/src/api/managers/guild_role_manager.dart diff --git a/lib/src/api/guilds/member_role_manager.dart b/lib/src/api/managers/member_role_manager.dart similarity index 98% rename from lib/src/api/guilds/member_role_manager.dart rename to lib/src/api/managers/member_role_manager.dart index 8e5256631..77870824c 100644 --- a/lib/src/api/guilds/member_role_manager.dart +++ b/lib/src/api/managers/member_role_manager.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/api/guilds/guild_role_manager.dart'; +import 'package:mineral/src/api/managers/guild_role_manager.dart'; import 'package:mineral/src/api/managers/cache_manager.dart'; import 'package:mineral/src/exceptions/not_exist.dart'; diff --git a/lib/src/api/role.dart b/lib/src/api/role.dart index 6578f31b8..066d5ecd2 100644 --- a/lib/src/api/role.dart +++ b/lib/src/api/role.dart @@ -3,7 +3,7 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/exception.dart'; import 'package:mineral/helper.dart'; -import 'package:mineral/src/api/guilds/guild_role_manager.dart'; +import 'package:mineral/src/api/managers/guild_role_manager.dart'; class Tag { Snowflake? botId; diff --git a/lib/src/internal/websockets/packets/guild_create.dart b/lib/src/internal/websockets/packets/guild_create.dart index 571f0c2ec..5987018b4 100644 --- a/lib/src/internal/websockets/packets/guild_create.dart +++ b/lib/src/internal/websockets/packets/guild_create.dart @@ -4,7 +4,7 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/channels/channel.dart'; -import 'package:mineral/src/api/guilds/guild_role_manager.dart'; +import 'package:mineral/src/api/managers/guild_role_manager.dart'; import 'package:mineral/src/api/guilds/guild_scheduled_event.dart'; import 'package:mineral/src/api/managers/channel_manager.dart'; import 'package:mineral/src/api/managers/emoji_manager.dart'; @@ -33,7 +33,7 @@ class GuildCreate implements WebsocketPacket { Role role = Role.from(roleManager: roleManager, payload: item); roleManager.cache.putIfAbsent(role.id, () => role); } - + Map voices = {}; for(dynamic voiceMember in websocketResponse.payload['voice_states']) { final VoiceManager voiceManager = VoiceManager.from(voiceMember, null); diff --git a/lib/src/internal/websockets/packets/guild_update.dart b/lib/src/internal/websockets/packets/guild_update.dart index 3617a79c3..372b76af1 100644 --- a/lib/src/internal/websockets/packets/guild_update.dart +++ b/lib/src/internal/websockets/packets/guild_update.dart @@ -1,6 +1,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; -import 'package:mineral/src/api/guilds/guild_role_manager.dart'; +import 'package:mineral/src/api/managers/guild_role_manager.dart'; import 'package:mineral/src/api/managers/channel_manager.dart'; import 'package:mineral/src/api/managers/emoji_manager.dart'; import 'package:mineral/src/api/managers/guild_scheduled_event_manager.dart'; From fce51df0156ba610647468fc2e998eeba3779a9f Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:15:22 +0200 Subject: [PATCH 55/68] refactor: Remove unused method --- lib/src/api/messages/message.dart | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/src/api/messages/message.dart b/lib/src/api/messages/message.dart index 29c0c3d74..db86e6282 100644 --- a/lib/src/api/messages/message.dart +++ b/lib/src/api/messages/message.dart @@ -1,8 +1,4 @@ -import 'dart:convert'; - -import 'package:http/http.dart'; import 'package:mineral/api.dart'; -import 'package:mineral/core.dart'; import 'package:mineral/src/api/components/component.dart'; import 'package:mineral/src/api/messages/message_attachment.dart'; import 'package:mineral/src/api/messages/message_sticker_item.dart'; @@ -42,18 +38,6 @@ class Message extends PartialMessage { channel: channel, ); - Future sync () async { - Http http = ioc.singleton(ioc.services.http); - - Response response = await http.get(url: "/channels/${channel.id}"); - dynamic payload = jsonDecode(response.body); - - Message message = Message.from(channel: channel, payload: payload); - channel.messages.cache.set(message.id, message); - - return message; - } - factory Message.from({ required TextBasedChannel channel, required dynamic payload }) { GuildMember? guildMember = channel.guild?.members.cache.get(payload['author']['id']); List embeds = []; From 5e9dafad4796f93bbd7390c8ce66907d10835d2e Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:33:32 +0200 Subject: [PATCH 56/68] docs: Write MessageEmbed --- lib/src/api/messages/message_embed.dart | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/lib/src/api/messages/message_embed.dart b/lib/src/api/messages/message_embed.dart index 9a882f4b6..4924065ab 100644 --- a/lib/src/api/messages/message_embed.dart +++ b/lib/src/api/messages/message_embed.dart @@ -101,51 +101,111 @@ class MessageEmbed { this.color, }); + /// Set the [title] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setTitle('My title'); + /// ``` MessageEmbed setTitle (String value) { title = value; return this; } + /// Set the [description] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setDescription('My description'); + /// ``` MessageEmbed setDescription (String value) { description = value; return this; } + /// Set the [footer] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setFooter(text: 'My title'); + /// ``` MessageEmbed setFooter ({ required String text, String? iconUrl, String? proxyIconUrl }) { footer = Footer(text: text, iconUrl: iconUrl, proxyIconUrl: proxyIconUrl); return this; } + /// Set the [image] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setImage(url: 'https://..../images/my_picture.png'); + /// ``` MessageEmbed setImage ({ required String url, String? proxyUrl, int? width, int? height }) { image = Image(url: url, proxyUrl: proxyUrl, width: width, height: height); return this; } + /// Set the [thumbnail] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setThumbnail(url: 'https://..../images/my_picture.png'); + /// ``` MessageEmbed setThumbnail ({ required String url, String? proxyUrl, int? width, int? height }) { thumbnail = Thumbnail(url: url, proxyUrl: proxyUrl, width: width, height: height); return this; } + /// Set the [author] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setAuthor(name: 'John Doe'); + /// ``` MessageEmbed setAuthor ({ required String name, String? url, String? iconUrl, String? proxyIconUrl }) { author = Author(name: name, url: url, iconUrl: iconUrl, proxyIconUrl: proxyIconUrl); return this; } + /// Set the [color] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setColor(Color.cyan_600); + /// ``` + /// Or with your custom color + /// ```dart + /// final embed = MessageEmbed() + /// .setColor(Color('#FFFFFF')); + /// ``` MessageEmbed setColor (Color color) { this.color = color; return this; } + /// Set the [timestamp] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setTimestamp(); + /// ``` + /// You can define an older or future timestamp + /// DateTime date = DateTime.now().add(DateTime(days: 5)); + /// final embed = MessageEmbed() + /// .setTimestamp(dateTime: date); + /// ``` MessageEmbed setTimestamp ({ DateTime? dateTime }) { timestamp = dateTime ?? DateTime.now(); return this; } + /// Set the [url] field and return this + /// ```dart + /// final embed = MessageEmbed() + /// .setUrl('https://.....com'); + /// ``` MessageEmbed setUrl (String url) { this.url = url; return this; } + /// Add an field into [fields] and return this + /// ```dart + /// final embed = MessageEmbed() + /// .addField(name: 'My field', value: 'My custom value'); + /// ``` MessageEmbed addField ({ required String name, required String value, bool? inline }) { fields?.add(Field(name: name, value: value, inline: inline)); return this; From 2b02410999cf01e8431eaa929badd8a11d3949ce Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:34:42 +0200 Subject: [PATCH 57/68] refactor: Fix member_role_manager break link --- lib/api.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.dart b/lib/api.dart index ac95b5980..adfd7e537 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -11,7 +11,7 @@ export 'src/api/user.dart' show User; export 'src/api/status.dart' show Status, StatusType; export 'src/api/activity.dart' show Activity; export 'src/api/guilds/guild_member.dart' show GuildMember; -export 'src/api/guilds/member_role_manager.dart' show MemberRoleManager; +export 'src/api/managers/member_role_manager.dart' show MemberRoleManager; export 'src/api/voice.dart' show Voice; export 'src/api/guilds/guild.dart' show Guild; From fbc4426a8d78f5972f5c947f423d8f691a454f4d Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:49:23 +0200 Subject: [PATCH 58/68] docs: Add highlight title --- lib/internal.dart | 2 +- lib/src/api/client/mineral_client.dart | 3 +- lib/src/api/color.dart | 2 + lib/src/api/components/modal.dart | 4 +- lib/src/api/emoji.dart | 8 ++-- lib/src/api/guilds/guild.dart | 38 +++++++++---------- lib/src/api/guilds/guild_member.dart | 14 +++---- .../api/interactions/command_interaction.dart | 18 ++++----- lib/src/api/interactions/interaction.dart | 4 +- .../api/interactions/modal_interaction.dart | 2 +- .../interactions/select_menu_interaction.dart | 4 +- lib/src/api/messages/message_embed.dart | 20 +++++----- .../api/messages/message_sticker_item.dart | 2 - lib/src/api/messages/partial_message.dart | 1 - lib/src/api/moderation_rule.dart | 16 ++++---- lib/src/api/role.dart | 16 ++++---- lib/src/api/user.dart | 4 +- lib/src/api/voice.dart | 12 +++--- lib/src/api/webhook.dart | 10 ++--- 19 files changed, 90 insertions(+), 90 deletions(-) diff --git a/lib/internal.dart b/lib/internal.dart index b533cafff..8f4b0f171 100644 --- a/lib/internal.dart +++ b/lib/internal.dart @@ -3,4 +3,4 @@ /// {@category Internal} library internal; -export 'src/internal/websockets/websockets.dart'; \ No newline at end of file +export 'src/internal/websockets/websockets.dart'; diff --git a/lib/src/api/client/mineral_client.dart b/lib/src/api/client/mineral_client.dart index f2ba48585..002ba5711 100644 --- a/lib/src/api/client/mineral_client.dart +++ b/lib/src/api/client/mineral_client.dart @@ -89,7 +89,8 @@ class MineralClient { required this.intents, }); - /// Defines the presence that this should adopt + /// ### Defines the presence that this should adopt + /// /// ```dart /// client.setPresence( /// activity: ClientActivity(name: 'My activity', type: GamePresence.listening), diff --git a/lib/src/api/color.dart b/lib/src/api/color.dart index 300280407..fdec4aeaa 100644 --- a/lib/src/api/color.dart +++ b/lib/src/api/color.dart @@ -1,5 +1,7 @@ /// Instance of colour. /// You can use a pre-designed colour panel +/// +/// Example /// ```dart /// import 'package:mineral/api.dart'; /// print(Color.cyan_600); diff --git a/lib/src/api/components/modal.dart b/lib/src/api/components/modal.dart index ad4541545..5ad5f7bd7 100644 --- a/lib/src/api/components/modal.dart +++ b/lib/src/api/components/modal.dart @@ -11,7 +11,7 @@ class Modal extends Component { Modal({ required this.customId, required this.label }) : super(type: ComponentType.selectMenu); - /// Created a input text field + /// ### Created a input text field /// ```dart /// final Modal modal = Modal(customId: 'my_modal', label: 'My modal') /// .addInput(customId: 'my_text', label: 'Premier texte'); @@ -21,7 +21,7 @@ class Modal extends Component { return this; } - /// Created a input text field with multiple lines + /// ### Created a input text field with multiple lines /// ```dart /// final Modal modal = Modal(customId: 'my_modal', label: 'My modal') /// .addParagraph(customId: 'my_paragraph', label: 'Second texte'); diff --git a/lib/src/api/emoji.dart b/lib/src/api/emoji.dart index 405be5d7a..4920440dc 100644 --- a/lib/src/api/emoji.dart +++ b/lib/src/api/emoji.dart @@ -29,7 +29,7 @@ class Emoji { required this.manager, }); - /// Modifies the [label] of this. + /// ### Modifies the [label] of this. /// ```dart /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); /// if (emoji != null) { @@ -45,7 +45,7 @@ class Emoji { } } - /// Modifies the [roles] of this. + /// ### Modifies the [roles] of this. /// ```dart /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); /// final Role? role = guild.roles.cache.get('240561194958716924'); @@ -71,7 +71,7 @@ class Emoji { } }*/ - /// Removes the current this from the [EmojiManager]'s cache + /// ### Removes the current this from the [EmojiManager]'s cache /// ```dart /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); /// if (emoji != null) { @@ -91,7 +91,7 @@ class Emoji { } } - /// Returns this in discord notification format + /// ### Returns this in discord notification format /// ```dart /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); /// if (emoji != null) { diff --git a/lib/src/api/guilds/guild.dart b/lib/src/api/guilds/guild.dart index 18662d105..6a67611b8 100644 --- a/lib/src/api/guilds/guild.dart +++ b/lib/src/api/guilds/guild.dart @@ -126,7 +126,7 @@ class Guild { required this.scheduledEvents, }); - /// Modifies the [name] of this. + /// ### Modifies the [name] of this. /// ```dart /// await guild.setName('Guild name'); /// ``` @@ -139,7 +139,7 @@ class Guild { } } - /// Modifies the [verificationLevel] of the current [Guild]. + /// ### Modifies the [verificationLevel] of the current [Guild]. /// ```dart /// import 'package:mineral/api.dart'; 👈 // then you can use VerificationLevel enum /// @@ -154,7 +154,7 @@ class Guild { } } - /// Defines the notification level of this + /// ### Defines the notification level of this /// - 0 → All messages /// - 1 → Only mentions /// ```dart @@ -169,7 +169,7 @@ class Guild { } } - /// Defines the explicit content level of this + /// ### Defines the explicit content level of this /// - 0 → Disabled /// - 1 → Members without roles /// - 2 → All members @@ -186,7 +186,7 @@ class Guild { } } - /// Update the afk channel + /// ### Update the afk channel /// ```dart /// final voiceChannel = guild.channels.cache.get('240561194958716924'); /// @@ -203,7 +203,7 @@ class Guild { afkChannelId = channel.id; } } - /// Update the owner of this + /// ### Update the owner of this /// /// Warning : This method only works if the server was created via a discord bot and the bot is the current owner /// @@ -232,7 +232,7 @@ class Guild { } } - /// Update the splash banner of this + /// ### Update the splash banner of this /// /// This method requires the feature [GuildFeature.banner] of this /// ```dart @@ -253,7 +253,7 @@ class Guild { } } - /// Remove the splash banner of this + /// ### Remove the splash banner of this /// /// This method requires the feature [GuildFeature.banner] of this /// ```dart @@ -272,7 +272,7 @@ class Guild { } } - /// Update the discovery splash banner of this + /// ### Update the discovery splash banner of this /// /// This method requires the feature [GuildFeature.banner] of this /// ```dart @@ -293,7 +293,7 @@ class Guild { } } - /// Remove the discovery splash banner of this + /// ### Remove the discovery splash banner of this /// /// This method requires the feature [GuildFeature.banner] of this /// ```dart @@ -312,7 +312,7 @@ class Guild { } } - /// Update the banner of this + /// ### Update the banner of this /// /// This method requires the feature [GuildFeature.banner] of this /// ```dart @@ -333,7 +333,7 @@ class Guild { } } - /// Remove the banner of this + /// ### Remove the banner of this /// /// This method requires the feature [GuildFeature.banner] of this /// ```dart @@ -352,7 +352,7 @@ class Guild { } } - /// Update the icon of this + /// ### Update the icon of this /// ```dart /// await guild.setIcon('assets/images/my_guild_icon.png'); /// ``` @@ -367,7 +367,7 @@ class Guild { } } - /// Remove the icon of this + /// ### Remove the icon of this /// ```dart /// await guild.removeIcon(); /// ``` @@ -380,7 +380,7 @@ class Guild { } } - /// Update system channel of this + /// ### Update system channel of this /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -398,7 +398,7 @@ class Guild { } } - /// Update rules channel of this + /// ### Update rules channel of this /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -416,7 +416,7 @@ class Guild { } } - /// Update public updates channel of this + /// ### Update public updates channel of this /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -434,7 +434,7 @@ class Guild { } } - /// Update preferred language of this + /// ### Update preferred language of this /// ```dart /// import 'package:mineral/api.dart'; /// @@ -449,7 +449,7 @@ class Guild { } } - /// Remove the discord client of this + /// ### Remove the discord client of this /// ```dart /// await guild.leave(); /// ``` diff --git a/lib/src/api/guilds/guild_member.dart b/lib/src/api/guilds/guild_member.dart index 703de3244..ff3115ee6 100644 --- a/lib/src/api/guilds/guild_member.dart +++ b/lib/src/api/guilds/guild_member.dart @@ -31,7 +31,7 @@ class GuildMember { required this.voice, }); - /// Update the username of this + /// ### Update the username of this /// ```dart /// await member.setUsername('John Doe'); /// ``` @@ -44,7 +44,7 @@ class GuildMember { } } - /// Excludes this for a pre-defined period + /// ### Excludes this for a pre-defined period /// /// Note: An exclusion cannot exceed 28 days /// @@ -63,7 +63,7 @@ class GuildMember { } } - /// Cancels the exclusion of this + /// ### Cancels the exclusion of this /// ```dart /// await member.removeTimeout(); /// ``` @@ -76,7 +76,7 @@ class GuildMember { } } - /// banned this from the [Guild] and deleted its messages for a given period + /// ### banned this from the [Guild] and deleted its messages for a given period /// ```dart /// await member.ban(); /// ``` @@ -97,7 +97,7 @@ class GuildMember { } } - /// Kick this of [Guild] + /// ### Kick this of [Guild] /// ```dart /// await member.removeTimeout(); /// ``` @@ -106,13 +106,13 @@ class GuildMember { await http.destroy(url: "/guilds/${guild.id}/members/${user.id}"); } - /// Returns whether of this is a bot + /// ### Returns whether of this is a bot /// ```dart /// print(member.isBot()); /// ``` bool isBot () => user.bot; - /// Returns whether of this is pending + /// ### Returns whether of this is pending /// ```dart /// print(member.isPending()); /// ``` diff --git a/lib/src/api/interactions/command_interaction.dart b/lib/src/api/interactions/command_interaction.dart index b97cce46f..4998d664f 100644 --- a/lib/src/api/interactions/command_interaction.dart +++ b/lib/src/api/interactions/command_interaction.dart @@ -18,7 +18,7 @@ class CommandInteraction extends Interaction { required User user }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); - /// Returns an instance of [Channel] if the command has the designed option + /// ### Returns an instance of [Channel] if the command has the designed option /// ```dart /// Channel? channel = interaction.getChannel('option_name'); /// ``` @@ -26,7 +26,7 @@ class CommandInteraction extends Interaction { return guild?.channels.cache.get(data[optionName]?['value']); } - /// Returns an [int] if the command has the designed option + /// ### Returns an [int] if the command has the designed option /// ```dart /// int? value = interaction.getInteger('option_name'); /// ``` @@ -34,7 +34,7 @@ class CommandInteraction extends Interaction { return data[optionName]?['value']; } - /// Returns an [String] if the command has the designed option + /// ### Returns an [String] if the command has the designed option /// ```dart /// String? str = interaction.getString('option_name'); /// ``` @@ -42,7 +42,7 @@ class CommandInteraction extends Interaction { return data[optionName]?['value']; } - /// Returns an instance of [GuildMember] if the command has the designed option + /// ### Returns an instance of [GuildMember] if the command has the designed option /// ```dart /// GuildMember? member = interaction.getMember('option_name'); /// ``` @@ -50,7 +50,7 @@ class CommandInteraction extends Interaction { return guild?.members.cache.get(data[optionName]?['value']); } - /// Returns an instance of [User] if the command has the designed option + /// ### Returns an instance of [User] if the command has the designed option /// ```dart /// User? user = interaction.getUser('option_name'); /// ``` @@ -59,7 +59,7 @@ class CommandInteraction extends Interaction { return client.users.cache.get(data[optionName]?['value']); } - /// Returns an [bool] if the command has the designed option + /// ### Returns an [bool] if the command has the designed option /// ```dart /// book? boolean = interaction.getBoolean('option_name'); /// ``` @@ -67,7 +67,7 @@ class CommandInteraction extends Interaction { return data[optionName]?['value']; } - /// Returns an instance of [Role] if the command has the designed option + /// ### Returns an instance of [Role] if the command has the designed option /// ```dart /// Role? role = interaction.getRole('option_name'); /// ``` @@ -75,7 +75,7 @@ class CommandInteraction extends Interaction { return guild?.roles.cache.get(data[optionName]?['value']); } - /// Returns an [T] if the command has the designed option + /// ### Returns an [T] if the command has the designed option /// ```dart /// String? str = interaction.getChoice('option_name'); /// int? value = interaction.getChoice('option_name'); @@ -84,7 +84,7 @@ class CommandInteraction extends Interaction { return data[optionName]?['value']; } - /// Returns an value if the command has the designed option + /// ### Returns an value if the command has the designed option /// ```dart /// dynamic mentionable = interaction.getMentionable('option_name'); /// ``` diff --git a/lib/src/api/interactions/interaction.dart b/lib/src/api/interactions/interaction.dart index a54d3a979..5a25c9031 100644 --- a/lib/src/api/interactions/interaction.dart +++ b/lib/src/api/interactions/interaction.dart @@ -26,7 +26,7 @@ class Interaction { Interaction({ required this.id, required this.applicationId, required this.version, required this.type, required this.token, required this.user }); - /// Responds to this by an [Message] + /// ### Responds to this by an [Message] /// ```dart /// await interaction.reply(content: 'Hello ${interaction.user.username}'); /// ``` @@ -59,7 +59,7 @@ class Interaction { }); } - /// Responds to this by an [Modal] + /// ### Responds to this by an [Modal] /// ```dart /// Modal modal = Modal(customId: 'modal', label: 'My modal') /// .addInput(customId: 'my_text', label: 'First text') diff --git a/lib/src/api/interactions/modal_interaction.dart b/lib/src/api/interactions/modal_interaction.dart index 930b7fae5..8a1481898 100644 --- a/lib/src/api/interactions/modal_interaction.dart +++ b/lib/src/api/interactions/modal_interaction.dart @@ -19,7 +19,7 @@ class ModalInteraction extends Interaction { required User user }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); - /// Return an [String] if the modal has the designed field + /// ### Return an [String] if the modal has the designed field /// ```dart /// String? field = interaction.getText('custom_field_id'); /// ``` diff --git a/lib/src/api/interactions/select_menu_interaction.dart b/lib/src/api/interactions/select_menu_interaction.dart index bf633fbca..1fc2b5246 100644 --- a/lib/src/api/interactions/select_menu_interaction.dart +++ b/lib/src/api/interactions/select_menu_interaction.dart @@ -19,14 +19,14 @@ class SelectMenuInteraction extends Interaction { required User user }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); - /// Return an [List] of [T] if this has the designed field + /// ### Return an [List] of [T] if this has the designed field /// ```dart /// List? fields = interaction.getValues(); /// List? fields = interaction.getValues(); /// ``` List getValues () => data as List; - /// Return the first [T] if this has the designed field + /// ### Return the first [T] if this has the designed field /// ```dart /// String? field = interaction.getValue(); /// int? field = interaction.getValue(); diff --git a/lib/src/api/messages/message_embed.dart b/lib/src/api/messages/message_embed.dart index 4924065ab..1104307a5 100644 --- a/lib/src/api/messages/message_embed.dart +++ b/lib/src/api/messages/message_embed.dart @@ -101,7 +101,7 @@ class MessageEmbed { this.color, }); - /// Set the [title] field and return this + /// ### Set the [title] field and return this /// ```dart /// final embed = MessageEmbed() /// .setTitle('My title'); @@ -111,7 +111,7 @@ class MessageEmbed { return this; } - /// Set the [description] field and return this + /// ### Set the [description] field and return this /// ```dart /// final embed = MessageEmbed() /// .setDescription('My description'); @@ -121,7 +121,7 @@ class MessageEmbed { return this; } - /// Set the [footer] field and return this + /// ### Set the [footer] field and return this /// ```dart /// final embed = MessageEmbed() /// .setFooter(text: 'My title'); @@ -131,7 +131,7 @@ class MessageEmbed { return this; } - /// Set the [image] field and return this + /// ### Set the [image] field and return this /// ```dart /// final embed = MessageEmbed() /// .setImage(url: 'https://..../images/my_picture.png'); @@ -141,7 +141,7 @@ class MessageEmbed { return this; } - /// Set the [thumbnail] field and return this + /// ### Set the [thumbnail] field and return this /// ```dart /// final embed = MessageEmbed() /// .setThumbnail(url: 'https://..../images/my_picture.png'); @@ -151,7 +151,7 @@ class MessageEmbed { return this; } - /// Set the [author] field and return this + /// ### Set the [author] field and return this /// ```dart /// final embed = MessageEmbed() /// .setAuthor(name: 'John Doe'); @@ -161,7 +161,7 @@ class MessageEmbed { return this; } - /// Set the [color] field and return this + /// ### Set the [color] field and return this /// ```dart /// final embed = MessageEmbed() /// .setColor(Color.cyan_600); @@ -176,7 +176,7 @@ class MessageEmbed { return this; } - /// Set the [timestamp] field and return this + /// ### Set the [timestamp] field and return this /// ```dart /// final embed = MessageEmbed() /// .setTimestamp(); @@ -191,7 +191,7 @@ class MessageEmbed { return this; } - /// Set the [url] field and return this + /// ### Set the [url] field and return this /// ```dart /// final embed = MessageEmbed() /// .setUrl('https://.....com'); @@ -201,7 +201,7 @@ class MessageEmbed { return this; } - /// Add an field into [fields] and return this + /// ### Add an field into [fields] and return this /// ```dart /// final embed = MessageEmbed() /// .addField(name: 'My field', value: 'My custom value'); diff --git a/lib/src/api/messages/message_sticker_item.dart b/lib/src/api/messages/message_sticker_item.dart index 4b525bb37..cf8a7c4e9 100644 --- a/lib/src/api/messages/message_sticker_item.dart +++ b/lib/src/api/messages/message_sticker_item.dart @@ -13,8 +13,6 @@ class MessageStickerItem { }); factory MessageStickerItem.from(dynamic payload) { - print(payload); - return MessageStickerItem( id: payload['id'], name: payload['name'], diff --git a/lib/src/api/messages/partial_message.dart b/lib/src/api/messages/partial_message.dart index 1ab46b531..fa266711e 100644 --- a/lib/src/api/messages/partial_message.dart +++ b/lib/src/api/messages/partial_message.dart @@ -2,7 +2,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/src/api/channels/partial_channel.dart'; import 'package:mineral/src/api/components/component.dart'; import 'package:mineral/src/api/messages/message_attachment.dart'; -import 'package:mineral/src/api/messages/message_embed.dart'; import 'package:mineral/src/api/messages/message_sticker_item.dart'; class PartialMessage { diff --git a/lib/src/api/moderation_rule.dart b/lib/src/api/moderation_rule.dart index 3f0543b70..3c0b3f404 100644 --- a/lib/src/api/moderation_rule.dart +++ b/lib/src/api/moderation_rule.dart @@ -119,7 +119,7 @@ class ModerationRule { required this.exemptChannels, }); - /// Update the label of this + /// ### Update the label of this /// ```dart /// await rule.setLabel('My label'); /// ``` @@ -132,7 +132,7 @@ class ModerationRule { } } - /// Update the event of this + /// ### Update the event of this /// ```dart /// await rule.setEventType(ModerationEventType.messageSend); /// ``` @@ -145,7 +145,7 @@ class ModerationRule { } } - /// Update the trigger metadata of this + /// ### Update the trigger metadata of this /// ```dart /// final metadata = ModerationTriggerMetadata( /// keywordFilter: ['foo'], @@ -163,7 +163,7 @@ class ModerationRule { } } - /// Update actions of this + /// ### Update actions of this /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -185,7 +185,7 @@ class ModerationRule { } } - /// Update enabled of this + /// ### Update enabled of this /// ```dart /// await rule.setEnabled(true); /// ``` @@ -198,7 +198,7 @@ class ModerationRule { } } - /// Defines which roles will not be affected by this + /// ### Defines which roles will not be affected by this /// ```dart /// final role = guild.roles.cache.get('240561194958716924'); /// @@ -222,7 +222,7 @@ class ModerationRule { } } - /// Defines which roles will not be affected by this + /// ### Defines which roles will not be affected by this /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -245,7 +245,7 @@ class ModerationRule { exemptChannels = channels; } } - /// Delete this + /// ### Delete this /// ```dart /// await rule.delete(); /// ``` diff --git a/lib/src/api/role.dart b/lib/src/api/role.dart index 066d5ecd2..62aad0da1 100644 --- a/lib/src/api/role.dart +++ b/lib/src/api/role.dart @@ -50,7 +50,7 @@ class Role { required this.manager, }); - /// Modifies the [label] of the role. + /// ### Modifies the [label] of the role. /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { @@ -66,7 +66,7 @@ class Role { } } - /// Modifies the permissions associated with this + /// ### Modifies the permissions associated with this /// ```dart /// import 'package:mineral/api.dart'; 👈 // then you can use Permission class /// @@ -86,7 +86,7 @@ class Role { } } - /// Modifies the [color] of the role. + /// ### Modifies the [color] of the role. /// ```dart /// import 'package:mineral/api.dart'; 👈 // then you can use Color class /// @@ -109,7 +109,7 @@ class Role { } } - /// Modifies the [hoist] of the role from [bool]. + /// ### Modifies the [hoist] of the role from [bool]. /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { @@ -125,7 +125,7 @@ class Role { } } - /// Modifies the [icon] of the role from [String] path. + /// ### Modifies the [icon] of the role from [String] path. /// /// We consider having the file structure /// ``` @@ -158,7 +158,7 @@ class Role { } } - /// Remove the [icon] of the role. + /// ### Remove the [icon] of the role. /// /// Your guild requires the [GuildFeature.roleIcons] to perform this action, otherwise throw [MissingFeatureException]. /// ```dart @@ -183,7 +183,7 @@ class Role { } } - /// Define the [unicodeEmoji] of the role from [String]. + /// ### Define the [unicodeEmoji] of the role from [String]. /// /// Your guild requires the [GuildFeature.roleIcons] to perform this action, otherwise throw [MissingFeatureException]. /// ```dart @@ -208,7 +208,7 @@ class Role { } } - /// Modifies the [mentionable] of the role from [bool]. + /// ### Modifies the [mentionable] of the role from [bool]. /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { diff --git a/lib/src/api/user.dart b/lib/src/api/user.dart index 3f1047762..aeffc3c03 100644 --- a/lib/src/api/user.dart +++ b/lib/src/api/user.dart @@ -29,7 +29,7 @@ class User { required this.avatarDecoration, }); - /// Envoie un message en DM à l'utilisateur + /// ### Envoie un message en DM à l'utilisateur /// ```dart /// GuildMember? member = guild.members.cache.get('240561194958716924'); /// await member.user.send(content: 'Hello World !'); @@ -66,7 +66,7 @@ class User { return null; } - /// Returns the absolute url to the user's avatar + /// ### Returns the absolute url to the user's avatar String getDisplayAvatarUrl () { return '${Constants.cdnUrl}/avatars/$id/$avatar'; } diff --git a/lib/src/api/voice.dart b/lib/src/api/voice.dart index e0f72c843..af20efa3c 100644 --- a/lib/src/api/voice.dart +++ b/lib/src/api/voice.dart @@ -15,7 +15,7 @@ class Voice { required this.channelId, }); - /// Mutes a server member + /// ### Mutes a server member /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -31,7 +31,7 @@ class Voice { } } - /// Remove mutes a server member + /// ### Remove mutes a server member /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -47,7 +47,7 @@ class Voice { } } - /// Deafens a server member + /// ### Deafens a server member /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -63,7 +63,7 @@ class Voice { } } - /// Remove deafens a server member + /// ### Remove deafens a server member /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -79,7 +79,7 @@ class Voice { } } - /// Moves a member from one voice channel to another + /// ### Moves a member from one voice channel to another /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// final voiceChannel = guild.channels.cache.get('240561194958716924'); @@ -96,7 +96,7 @@ class Voice { this.channel = channel; } } - /// Disconnects the user from a voice channel + /// ### Disconnects the user from a voice channel /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// diff --git a/lib/src/api/webhook.dart b/lib/src/api/webhook.dart index 67634efa6..eeea42202 100644 --- a/lib/src/api/webhook.dart +++ b/lib/src/api/webhook.dart @@ -42,7 +42,7 @@ class Webhook { required this.url, }); - /// Update the label of this + /// ### Update the label of this /// ```dart /// await webhook.setLabel('My webhook name'); /// ``` @@ -55,7 +55,7 @@ class Webhook { } } - /// Update the avatar of this + /// ### Update the avatar of this /// ```dart /// await webhook.setAvatar('assets/images/my_picture.png'); /// ``` @@ -69,7 +69,7 @@ class Webhook { } } - /// Updates multiple properties of this in a single request. + /// ### Updates multiple properties of this in a single request. /// When you need to update more than 2 fields, we advise you to use this method to reduce the number of outgoing requests. /// ```dart /// await webhook.update(label: 'My webhook name', avatar: 'assets/images/my_picture.png'); @@ -90,7 +90,7 @@ class Webhook { if (avatar != null) this.avatar = path; } } - /// Send a message from the webhook + /// ### Send a message from the webhook /// ```dart /// await webhook.execute(content: 'Hello World !'); /// ``` @@ -122,7 +122,7 @@ class Webhook { }); } - /// Delete this + /// ### Delete this /// ```dart /// await webhook.delete(); /// ``` From 4f1c2105c1628487dfe661df4b6d869c55427511 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 11:55:17 +0200 Subject: [PATCH 59/68] docs: Add Example case --- lib/src/api/client/mineral_client.dart | 4 ++ lib/src/api/color.dart | 8 +++- lib/src/api/components/modal.dart | 4 ++ lib/src/api/emoji.dart | 10 +++++ lib/src/api/guilds/guild.dart | 38 +++++++++++++++++++ lib/src/api/guilds/guild_member.dart | 16 ++++++++ .../api/interactions/command_interaction.dart | 18 +++++++++ lib/src/api/interactions/interaction.dart | 4 ++ .../api/interactions/modal_interaction.dart | 2 + .../interactions/select_menu_interaction.dart | 4 ++ lib/src/api/managers/guild_role_manager.dart | 4 ++ lib/src/api/managers/member_role_manager.dart | 12 ++++++ lib/src/api/messages/message_embed.dart | 22 +++++++++++ lib/src/api/moderation_rule.dart | 16 ++++++++ lib/src/api/role.dart | 24 ++++++++++++ lib/src/api/user.dart | 2 + lib/src/api/voice.dart | 12 ++++++ lib/src/api/webhook.dart | 10 +++++ lib/src/internal/extensions/collection.dart | 18 +++++++++ 19 files changed, 226 insertions(+), 2 deletions(-) diff --git a/lib/src/api/client/mineral_client.dart b/lib/src/api/client/mineral_client.dart index 002ba5711..7dfc91cca 100644 --- a/lib/src/api/client/mineral_client.dart +++ b/lib/src/api/client/mineral_client.dart @@ -91,6 +91,8 @@ class MineralClient { /// ### Defines the presence that this should adopt /// + /// + /// Example : /// ```dart /// client.setPresence( /// activity: ClientActivity(name: 'My activity', type: GamePresence.listening), @@ -108,6 +110,8 @@ class MineralClient { } /// Sends a ping/pong to the APi websocket of discord and returns the latency + /// + /// Example : /// ```dart /// final int latency = client.getLatency(); /// ``` diff --git a/lib/src/api/color.dart b/lib/src/api/color.dart index fdec4aeaa..c57b56486 100644 --- a/lib/src/api/color.dart +++ b/lib/src/api/color.dart @@ -2,12 +2,16 @@ /// You can use a pre-designed colour panel /// /// Example -/// ```dart +/// + /// Example : + /// ```dart /// import 'package:mineral/api.dart'; /// print(Color.cyan_600); /// ``` /// Or create your own colour instances -/// ```dart +/// + /// Example : + /// ```dart /// import 'package:mineral/api.dart'; /// print(Color('#FFFFFF')); // ``` diff --git a/lib/src/api/components/modal.dart b/lib/src/api/components/modal.dart index 5ad5f7bd7..909f61dad 100644 --- a/lib/src/api/components/modal.dart +++ b/lib/src/api/components/modal.dart @@ -12,6 +12,8 @@ class Modal extends Component { Modal({ required this.customId, required this.label }) : super(type: ComponentType.selectMenu); /// ### Created a input text field + /// + /// Example : /// ```dart /// final Modal modal = Modal(customId: 'my_modal', label: 'My modal') /// .addInput(customId: 'my_text', label: 'Premier texte'); @@ -22,6 +24,8 @@ class Modal extends Component { } /// ### Created a input text field with multiple lines + /// + /// Example : /// ```dart /// final Modal modal = Modal(customId: 'my_modal', label: 'My modal') /// .addParagraph(customId: 'my_paragraph', label: 'Second texte'); diff --git a/lib/src/api/emoji.dart b/lib/src/api/emoji.dart index 4920440dc..10141d9e6 100644 --- a/lib/src/api/emoji.dart +++ b/lib/src/api/emoji.dart @@ -30,6 +30,8 @@ class Emoji { }); /// ### Modifies the [label] of this. + /// + /// Example : /// ```dart /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); /// if (emoji != null) { @@ -46,6 +48,8 @@ class Emoji { } /// ### Modifies the [roles] of this. + /// + /// Example : /// ```dart /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); /// final Role? role = guild.roles.cache.get('240561194958716924'); @@ -72,6 +76,8 @@ class Emoji { }*/ /// ### Removes the current this from the [EmojiManager]'s cache + /// + /// Example : /// ```dart /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); /// if (emoji != null) { @@ -79,6 +85,8 @@ class Emoji { /// } /// ``` /// You can specify a reason for this action + /// + /// Example : /// ```dart /// await emoji.delete(reason: 'I will destroy this..'); /// ``` @@ -92,6 +100,8 @@ class Emoji { } /// ### Returns this in discord notification format + /// + /// Example : /// ```dart /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); /// if (emoji != null) { diff --git a/lib/src/api/guilds/guild.dart b/lib/src/api/guilds/guild.dart index 6a67611b8..bdafbab06 100644 --- a/lib/src/api/guilds/guild.dart +++ b/lib/src/api/guilds/guild.dart @@ -127,6 +127,8 @@ class Guild { }); /// ### Modifies the [name] of this. + /// + /// Example : /// ```dart /// await guild.setName('Guild name'); /// ``` @@ -140,6 +142,8 @@ class Guild { } /// ### Modifies the [verificationLevel] of the current [Guild]. + /// + /// Example : /// ```dart /// import 'package:mineral/api.dart'; 👈 // then you can use VerificationLevel enum /// @@ -157,6 +161,8 @@ class Guild { /// ### Defines the notification level of this /// - 0 → All messages /// - 1 → Only mentions + /// + /// Example : /// ```dart /// await guild.setMessageNotification(1); /// ``` @@ -174,6 +180,8 @@ class Guild { /// - 1 → Members without roles /// - 2 → All members /// + /// + /// Example : /// ```dart /// await guild.setExplicitContentFilter(2); /// ``` @@ -187,6 +195,8 @@ class Guild { } /// ### Update the afk channel + /// + /// Example : /// ```dart /// final voiceChannel = guild.channels.cache.get('240561194958716924'); /// @@ -208,6 +218,8 @@ class Guild { /// Warning : This method only works if the server was created via a discord bot and the bot is the current owner /// /// See [documentation](Warning: This method only works if the server was created via a discord bot) + /// + /// Example : /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -235,6 +247,8 @@ class Guild { /// ### Update the splash banner of this /// /// This method requires the feature [GuildFeature.banner] of this + /// + /// Example : /// ```dart /// await guild.setSplash('assets/images/my_splash_banner.png'); /// ``` @@ -256,6 +270,8 @@ class Guild { /// ### Remove the splash banner of this /// /// This method requires the feature [GuildFeature.banner] of this + /// + /// Example : /// ```dart /// await guild.removeSplash(); /// ``` @@ -275,6 +291,8 @@ class Guild { /// ### Update the discovery splash banner of this /// /// This method requires the feature [GuildFeature.banner] of this + /// + /// Example : /// ```dart /// await guild.setDiscoverySplash('assets/images/my_splash_discovery_banner.png'); /// ``` @@ -296,6 +314,8 @@ class Guild { /// ### Remove the discovery splash banner of this /// /// This method requires the feature [GuildFeature.banner] of this + /// + /// Example : /// ```dart /// await guild.removeDiscoverySplash(); /// ``` @@ -315,6 +335,8 @@ class Guild { /// ### Update the banner of this /// /// This method requires the feature [GuildFeature.banner] of this + /// + /// Example : /// ```dart /// await guild.setBanner('assets/images/my_banner.png'); /// ``` @@ -336,6 +358,8 @@ class Guild { /// ### Remove the banner of this /// /// This method requires the feature [GuildFeature.banner] of this + /// + /// Example : /// ```dart /// await guild.removeBanner(); /// ``` @@ -353,6 +377,8 @@ class Guild { } /// ### Update the icon of this + /// + /// Example : /// ```dart /// await guild.setIcon('assets/images/my_guild_icon.png'); /// ``` @@ -368,6 +394,8 @@ class Guild { } /// ### Remove the icon of this + /// + /// Example : /// ```dart /// await guild.removeIcon(); /// ``` @@ -381,6 +409,8 @@ class Guild { } /// ### Update system channel of this + /// + /// Example : /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -399,6 +429,8 @@ class Guild { } /// ### Update rules channel of this + /// + /// Example : /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -417,6 +449,8 @@ class Guild { } /// ### Update public updates channel of this + /// + /// Example : /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -435,6 +469,8 @@ class Guild { } /// ### Update preferred language of this + /// + /// Example : /// ```dart /// import 'package:mineral/api.dart'; /// @@ -450,6 +486,8 @@ class Guild { } /// ### Remove the discord client of this + /// + /// Example : /// ```dart /// await guild.leave(); /// ``` diff --git a/lib/src/api/guilds/guild_member.dart b/lib/src/api/guilds/guild_member.dart index ff3115ee6..e00255534 100644 --- a/lib/src/api/guilds/guild_member.dart +++ b/lib/src/api/guilds/guild_member.dart @@ -32,6 +32,8 @@ class GuildMember { }); /// ### Update the username of this + /// + /// Example : /// ```dart /// await member.setUsername('John Doe'); /// ``` @@ -49,6 +51,8 @@ class GuildMember { /// Note: An exclusion cannot exceed 28 days /// /// See [documentation](https://discord.com/developers/docs/resources/guild#modify-guild-member) + /// + /// Example : /// ```dart /// final DateTime = DateTime.now().add(Duration(days: 28)); /// await member.timeout(DateTime); @@ -64,6 +68,8 @@ class GuildMember { } /// ### Cancels the exclusion of this + /// + /// Example : /// ```dart /// await member.removeTimeout(); /// ``` @@ -77,10 +83,14 @@ class GuildMember { } /// ### banned this from the [Guild] and deleted its messages for a given period + /// + /// Example : /// ```dart /// await member.ban(); /// ``` /// With the deletion of his messages for 7 days + /// + /// Example : /// ```dart /// await member.ban(count: 7); /// ``` @@ -98,6 +108,8 @@ class GuildMember { } /// ### Kick this of [Guild] + /// + /// Example : /// ```dart /// await member.removeTimeout(); /// ``` @@ -107,12 +119,16 @@ class GuildMember { } /// ### Returns whether of this is a bot + /// + /// Example : /// ```dart /// print(member.isBot()); /// ``` bool isBot () => user.bot; /// ### Returns whether of this is pending + /// + /// Example : /// ```dart /// print(member.isPending()); /// ``` diff --git a/lib/src/api/interactions/command_interaction.dart b/lib/src/api/interactions/command_interaction.dart index 4998d664f..5af1949dd 100644 --- a/lib/src/api/interactions/command_interaction.dart +++ b/lib/src/api/interactions/command_interaction.dart @@ -19,6 +19,8 @@ class CommandInteraction extends Interaction { }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); /// ### Returns an instance of [Channel] if the command has the designed option + /// + /// Example : /// ```dart /// Channel? channel = interaction.getChannel('option_name'); /// ``` @@ -27,6 +29,8 @@ class CommandInteraction extends Interaction { } /// ### Returns an [int] if the command has the designed option + /// + /// Example : /// ```dart /// int? value = interaction.getInteger('option_name'); /// ``` @@ -35,6 +39,8 @@ class CommandInteraction extends Interaction { } /// ### Returns an [String] if the command has the designed option + /// + /// Example : /// ```dart /// String? str = interaction.getString('option_name'); /// ``` @@ -43,6 +49,8 @@ class CommandInteraction extends Interaction { } /// ### Returns an instance of [GuildMember] if the command has the designed option + /// + /// Example : /// ```dart /// GuildMember? member = interaction.getMember('option_name'); /// ``` @@ -51,6 +59,8 @@ class CommandInteraction extends Interaction { } /// ### Returns an instance of [User] if the command has the designed option + /// + /// Example : /// ```dart /// User? user = interaction.getUser('option_name'); /// ``` @@ -60,6 +70,8 @@ class CommandInteraction extends Interaction { } /// ### Returns an [bool] if the command has the designed option + /// + /// Example : /// ```dart /// book? boolean = interaction.getBoolean('option_name'); /// ``` @@ -68,6 +80,8 @@ class CommandInteraction extends Interaction { } /// ### Returns an instance of [Role] if the command has the designed option + /// + /// Example : /// ```dart /// Role? role = interaction.getRole('option_name'); /// ``` @@ -76,6 +90,8 @@ class CommandInteraction extends Interaction { } /// ### Returns an [T] if the command has the designed option + /// + /// Example : /// ```dart /// String? str = interaction.getChoice('option_name'); /// int? value = interaction.getChoice('option_name'); @@ -85,6 +101,8 @@ class CommandInteraction extends Interaction { } /// ### Returns an value if the command has the designed option + /// + /// Example : /// ```dart /// dynamic mentionable = interaction.getMentionable('option_name'); /// ``` diff --git a/lib/src/api/interactions/interaction.dart b/lib/src/api/interactions/interaction.dart index 5a25c9031..b1c4a3bc6 100644 --- a/lib/src/api/interactions/interaction.dart +++ b/lib/src/api/interactions/interaction.dart @@ -27,6 +27,8 @@ class Interaction { Interaction({ required this.id, required this.applicationId, required this.version, required this.type, required this.token, required this.user }); /// ### Responds to this by an [Message] + /// + /// Example : /// ```dart /// await interaction.reply(content: 'Hello ${interaction.user.username}'); /// ``` @@ -60,6 +62,8 @@ class Interaction { } /// ### Responds to this by an [Modal] + /// + /// Example : /// ```dart /// Modal modal = Modal(customId: 'modal', label: 'My modal') /// .addInput(customId: 'my_text', label: 'First text') diff --git a/lib/src/api/interactions/modal_interaction.dart b/lib/src/api/interactions/modal_interaction.dart index 8a1481898..099b9934a 100644 --- a/lib/src/api/interactions/modal_interaction.dart +++ b/lib/src/api/interactions/modal_interaction.dart @@ -20,6 +20,8 @@ class ModalInteraction extends Interaction { }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); /// ### Return an [String] if the modal has the designed field + /// + /// Example : /// ```dart /// String? field = interaction.getText('custom_field_id'); /// ``` diff --git a/lib/src/api/interactions/select_menu_interaction.dart b/lib/src/api/interactions/select_menu_interaction.dart index 1fc2b5246..89752b52f 100644 --- a/lib/src/api/interactions/select_menu_interaction.dart +++ b/lib/src/api/interactions/select_menu_interaction.dart @@ -20,6 +20,8 @@ class SelectMenuInteraction extends Interaction { }) : super(id: id, version: version, token: token, type: type, user: user, applicationId: applicationId); /// ### Return an [List] of [T] if this has the designed field + /// + /// Example : /// ```dart /// List? fields = interaction.getValues(); /// List? fields = interaction.getValues(); @@ -27,6 +29,8 @@ class SelectMenuInteraction extends Interaction { List getValues () => data as List; /// ### Return the first [T] if this has the designed field + /// + /// Example : /// ```dart /// String? field = interaction.getValue(); /// int? field = interaction.getValue(); diff --git a/lib/src/api/managers/guild_role_manager.dart b/lib/src/api/managers/guild_role_manager.dart index b8785a222..ea2d60faf 100644 --- a/lib/src/api/managers/guild_role_manager.dart +++ b/lib/src/api/managers/guild_role_manager.dart @@ -17,6 +17,8 @@ class GuildRoleManager implements CacheManager { GuildRoleManager({ required this.guildId }); /// Synchronise the cache from the Discord API + /// + /// Example : /// ```dart /// await guild.roles.sync(); /// ``` @@ -42,6 +44,8 @@ class GuildRoleManager implements CacheManager { /// Create a this /// /// Warning: if you want to define an icon, the [Guid] must have the feature [GuildFeature.roleIcons] + /// + /// Example : /// ```dart /// await guild.roles.create( /// label: 'My role', diff --git a/lib/src/api/managers/member_role_manager.dart b/lib/src/api/managers/member_role_manager.dart index 77870824c..e84c5b016 100644 --- a/lib/src/api/managers/member_role_manager.dart +++ b/lib/src/api/managers/member_role_manager.dart @@ -18,6 +18,8 @@ class MemberRoleManager implements CacheManager { MemberRoleManager({ required this.manager, required this.memberId }); /// Add a [Role] to the [GuildMember] + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('446556480850755604'); /// final GuildMember? member = guild.members.cache.get('240561194958716924'); @@ -27,6 +29,8 @@ class MemberRoleManager implements CacheManager { /// } /// ``` /// You can pass a reason for the audit logs. + /// + /// Example : /// ```dart /// await member.roles.add('446556480850755604', reason: 'I love this user'); /// ``` @@ -55,6 +59,8 @@ class MemberRoleManager implements CacheManager { } /// Remove a [Role] from the [GuildMember] + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('446556480850755604'); /// final GuildMember? member = guild.members.cache.get('240561194958716924'); @@ -64,6 +70,8 @@ class MemberRoleManager implements CacheManager { /// ``` /// /// You can pass a reason for the audit logs. + /// + /// Example : /// ```dart /// await member.roles.remove('446556480850755604', reason: 'Hello, World!'); /// ``` @@ -86,6 +94,8 @@ class MemberRoleManager implements CacheManager { } /// Toggle a [Role] from the [GuildMember]. If the user has the role, this method will remove the role, else this method will add the role. + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('446556480850755604'); /// final GuildMember? member = guild.members.cache.get('240561194958716924'); @@ -95,6 +105,8 @@ class MemberRoleManager implements CacheManager { /// ``` /// /// You can pass a reason for the audit logs. + /// + /// Example : /// ```dart /// await member.roles.toggle('446556480850755604', reason: 'Hello, World!'); /// ``` diff --git a/lib/src/api/messages/message_embed.dart b/lib/src/api/messages/message_embed.dart index 1104307a5..94345ea5f 100644 --- a/lib/src/api/messages/message_embed.dart +++ b/lib/src/api/messages/message_embed.dart @@ -102,6 +102,8 @@ class MessageEmbed { }); /// ### Set the [title] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setTitle('My title'); @@ -112,6 +114,8 @@ class MessageEmbed { } /// ### Set the [description] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setDescription('My description'); @@ -122,6 +126,8 @@ class MessageEmbed { } /// ### Set the [footer] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setFooter(text: 'My title'); @@ -132,6 +138,8 @@ class MessageEmbed { } /// ### Set the [image] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setImage(url: 'https://..../images/my_picture.png'); @@ -142,6 +150,8 @@ class MessageEmbed { } /// ### Set the [thumbnail] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setThumbnail(url: 'https://..../images/my_picture.png'); @@ -152,6 +162,8 @@ class MessageEmbed { } /// ### Set the [author] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setAuthor(name: 'John Doe'); @@ -162,11 +174,15 @@ class MessageEmbed { } /// ### Set the [color] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setColor(Color.cyan_600); /// ``` /// Or with your custom color + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setColor(Color('#FFFFFF')); @@ -177,6 +193,8 @@ class MessageEmbed { } /// ### Set the [timestamp] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setTimestamp(); @@ -192,6 +210,8 @@ class MessageEmbed { } /// ### Set the [url] field and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .setUrl('https://.....com'); @@ -202,6 +222,8 @@ class MessageEmbed { } /// ### Add an field into [fields] and return this + /// + /// Example : /// ```dart /// final embed = MessageEmbed() /// .addField(name: 'My field', value: 'My custom value'); diff --git a/lib/src/api/moderation_rule.dart b/lib/src/api/moderation_rule.dart index 3c0b3f404..93b06b0dc 100644 --- a/lib/src/api/moderation_rule.dart +++ b/lib/src/api/moderation_rule.dart @@ -120,6 +120,8 @@ class ModerationRule { }); /// ### Update the label of this + /// + /// Example : /// ```dart /// await rule.setLabel('My label'); /// ``` @@ -133,6 +135,8 @@ class ModerationRule { } /// ### Update the event of this + /// + /// Example : /// ```dart /// await rule.setEventType(ModerationEventType.messageSend); /// ``` @@ -146,6 +150,8 @@ class ModerationRule { } /// ### Update the trigger metadata of this + /// + /// Example : /// ```dart /// final metadata = ModerationTriggerMetadata( /// keywordFilter: ['foo'], @@ -164,6 +170,8 @@ class ModerationRule { } /// ### Update actions of this + /// + /// Example : /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -186,6 +194,8 @@ class ModerationRule { } /// ### Update enabled of this + /// + /// Example : /// ```dart /// await rule.setEnabled(true); /// ``` @@ -199,6 +209,8 @@ class ModerationRule { } /// ### Defines which roles will not be affected by this + /// + /// Example : /// ```dart /// final role = guild.roles.cache.get('240561194958716924'); /// @@ -223,6 +235,8 @@ class ModerationRule { } /// ### Defines which roles will not be affected by this + /// + /// Example : /// ```dart /// final channel = guild.channels.cache.get('240561194958716924'); /// @@ -246,6 +260,8 @@ class ModerationRule { } } /// ### Delete this + /// + /// Example : /// ```dart /// await rule.delete(); /// ``` diff --git a/lib/src/api/role.dart b/lib/src/api/role.dart index 62aad0da1..554b39739 100644 --- a/lib/src/api/role.dart +++ b/lib/src/api/role.dart @@ -51,6 +51,8 @@ class Role { }); /// ### Modifies the [label] of the role. + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { @@ -67,6 +69,8 @@ class Role { } /// ### Modifies the permissions associated with this + /// + /// Example : /// ```dart /// import 'package:mineral/api.dart'; 👈 // then you can use Permission class /// @@ -87,6 +91,8 @@ class Role { } /// ### Modifies the [color] of the role. + /// + /// Example : /// ```dart /// import 'package:mineral/api.dart'; 👈 // then you can use Color class /// @@ -96,6 +102,8 @@ class Role { /// } /// ``` /// You can use a custom colour from a hexadecimal format. + /// + /// Example : /// ```dart /// await role.setColor(Color('#ffffff')); /// ``` @@ -110,6 +118,8 @@ class Role { } /// ### Modifies the [hoist] of the role from [bool]. + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { @@ -138,6 +148,8 @@ class Role { /// .env /// pubspec.yaml /// ``` + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { @@ -161,6 +173,8 @@ class Role { /// ### Remove the [icon] of the role. /// /// Your guild requires the [GuildFeature.roleIcons] to perform this action, otherwise throw [MissingFeatureException]. + /// + /// Example : /// ```dart /// import 'package:mineral/api.dart'; 👈 // then you can use GuildFeature enum /// @@ -186,6 +200,8 @@ class Role { /// ### Define the [unicodeEmoji] of the role from [String]. /// /// Your guild requires the [GuildFeature.roleIcons] to perform this action, otherwise throw [MissingFeatureException]. + /// + /// Example : /// ```dart /// import 'package:mineral/api.dart'; 👈 // then you can use GuildFeature enum /// @@ -209,6 +225,8 @@ class Role { } /// ### Modifies the [mentionable] of the role from [bool]. + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { @@ -225,6 +243,8 @@ class Role { } /// Removes the current this from the [MemberRoleManager]'s cache + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { @@ -232,6 +252,8 @@ class Role { /// } /// ``` /// You can specify a reason for this action + /// + /// Example : /// ```dart /// await role.delete(reason: 'I will destroy this..'); /// ``` @@ -251,6 +273,8 @@ class Role { } /// Returns this in discord notification format + /// + /// Example : /// ```dart /// final Role? role = guild.roles.cache.get('240561194958716924'); /// if (role != null) { diff --git a/lib/src/api/user.dart b/lib/src/api/user.dart index aeffc3c03..88c478ed9 100644 --- a/lib/src/api/user.dart +++ b/lib/src/api/user.dart @@ -30,6 +30,8 @@ class User { }); /// ### Envoie un message en DM à l'utilisateur + /// + /// Example : /// ```dart /// GuildMember? member = guild.members.cache.get('240561194958716924'); /// await member.user.send(content: 'Hello World !'); diff --git a/lib/src/api/voice.dart b/lib/src/api/voice.dart index af20efa3c..8fd4e2701 100644 --- a/lib/src/api/voice.dart +++ b/lib/src/api/voice.dart @@ -16,6 +16,8 @@ class Voice { }); /// ### Mutes a server member + /// + /// Example : /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -32,6 +34,8 @@ class Voice { } /// ### Remove mutes a server member + /// + /// Example : /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -48,6 +52,8 @@ class Voice { } /// ### Deafens a server member + /// + /// Example : /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -64,6 +70,8 @@ class Voice { } /// ### Remove deafens a server member + /// + /// Example : /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// @@ -80,6 +88,8 @@ class Voice { } /// ### Moves a member from one voice channel to another + /// + /// Example : /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// final voiceChannel = guild.channels.cache.get('240561194958716924'); @@ -97,6 +107,8 @@ class Voice { } } /// ### Disconnects the user from a voice channel + /// + /// Example : /// ```dart /// final member = guild.members.cache.get('240561194958716924'); /// diff --git a/lib/src/api/webhook.dart b/lib/src/api/webhook.dart index eeea42202..ea0af2b6a 100644 --- a/lib/src/api/webhook.dart +++ b/lib/src/api/webhook.dart @@ -43,6 +43,8 @@ class Webhook { }); /// ### Update the label of this + /// + /// Example : /// ```dart /// await webhook.setLabel('My webhook name'); /// ``` @@ -56,6 +58,8 @@ class Webhook { } /// ### Update the avatar of this + /// + /// Example : /// ```dart /// await webhook.setAvatar('assets/images/my_picture.png'); /// ``` @@ -71,6 +75,8 @@ class Webhook { /// ### Updates multiple properties of this in a single request. /// When you need to update more than 2 fields, we advise you to use this method to reduce the number of outgoing requests. + /// + /// Example : /// ```dart /// await webhook.update(label: 'My webhook name', avatar: 'assets/images/my_picture.png'); /// ``` @@ -91,6 +97,8 @@ class Webhook { } } /// ### Send a message from the webhook + /// + /// Example : /// ```dart /// await webhook.execute(content: 'Hello World !'); /// ``` @@ -123,6 +131,8 @@ class Webhook { } /// ### Delete this + /// + /// Example : /// ```dart /// await webhook.delete(); /// ``` diff --git a/lib/src/internal/extensions/collection.dart b/lib/src/internal/extensions/collection.dart index ca15a3890..ebdbdd5ae 100644 --- a/lib/src/internal/extensions/collection.dart +++ b/lib/src/internal/extensions/collection.dart @@ -3,6 +3,8 @@ import 'package:mineral/src/exceptions/not_exist.dart'; extension Collection on Map { /// Returns the value associated from the [K] parameter + /// + /// Example : /// ```dart /// Channel? channel = guild.channels.cache.get('991686152585232404'); /// print(channel); @@ -10,6 +12,8 @@ extension Collection on Map { T? get (K? key) => this[key] as T?; /// Returns the value associated from the [K] parameter or defined value + /// + /// Example : /// ```dart /// Channel firstChannel = guild.channels.cache.getOrFail('991686152585232404', defaultValue: myChannel ); /// Channel? secondChannel = guild.channels.cache.getOr('991686152585232404', defaultValue: firstChannel ); @@ -24,6 +28,8 @@ extension Collection on Map { } /// Inserts or replaces data in the collection + /// + /// Example : /// ```dart /// Channel channel = Channel.from({...}); /// guild.channels.cache.set(channel.id, channel); @@ -31,6 +37,8 @@ extension Collection on Map { void set (K key, V value) => this[key] = value; /// Replaces the value associated with a key if it exists + /// + /// Example : /// ```dart /// Channel channel = Channel.from({...}); /// guild.channels.cache.overrideIfPresent(channel.id, () => channel); @@ -41,11 +49,15 @@ extension Collection on Map { } /// Returns the value associated from the [K] parameter + /// + /// Example : /// ```dart /// Channel channel = guild.channels.cache.getOrFail('991686152585232404'); /// print(channel); /// ``` /// You can define an error customized message + /// + /// Example : /// ```dart /// Channel channel = guild.channels.cache.getOrFail('991686152585232404', message: 'Channel is undefined'); /// print(channel); @@ -60,6 +72,8 @@ extension Collection on Map { } /// Returns the first element satisfying test, or null if there are none. + /// + /// Example : /// ```dart /// Channel? channel = guild.channels.cache.find((channel) => channel.id == '991686152585232404'); /// print(channel); @@ -70,11 +84,15 @@ extension Collection on Map { } /// Returns the first element satisfying test, or throw if there are none. + /// + /// Example : /// ```dart /// Channel? channel = guild.channels.cache.find((channel) => channel.id == '991686152585232404'); /// print(channel); /// ``` /// You can define an error customized message + /// + /// Example : /// ```dart /// Channel channel = guild.channels.cache.find((channel) => channel.id == '991686152585232404', message: 'Channel is undefined'); /// print(channel); From 4ae5251cf162e70721a1642977edde790d97c9d3 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 12:39:17 +0200 Subject: [PATCH 60/68] feat: Implement edit message --- lib/src/api/messages/message.dart | 26 +++++++++++++++++++ lib/src/api/user.dart | 2 +- .../websockets/packets/guild_create.dart | 1 - 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/src/api/messages/message.dart b/lib/src/api/messages/message.dart index db86e6282..9ed1490ad 100644 --- a/lib/src/api/messages/message.dart +++ b/lib/src/api/messages/message.dart @@ -1,4 +1,6 @@ +import 'package:http/http.dart'; import 'package:mineral/api.dart'; +import 'package:mineral/core.dart'; import 'package:mineral/src/api/components/component.dart'; import 'package:mineral/src/api/messages/message_attachment.dart'; import 'package:mineral/src/api/messages/message_sticker_item.dart'; @@ -38,6 +40,30 @@ class Message extends PartialMessage { channel: channel, ); + Future edit ({ String? content, List? embeds, List? components, bool? tts }) async { + Http http = ioc.singleton(ioc.services.http); + + Response response = await http.patch( + url: '/channels/$channelId/messages/$id', + payload: { + 'content': content, + 'embeds': embeds, + 'flags': flags, + 'allowed_mentions': allowMentions, + 'components': components, + } + ); + + print(response.body); + if (response.statusCode == 200) { + this.content = content ?? this.content; + this.embeds = embeds ?? this.embeds; + this.components = components ?? this.components; + } + + return this; + } + factory Message.from({ required TextBasedChannel channel, required dynamic payload }) { GuildMember? guildMember = channel.guild?.members.cache.get(payload['author']['id']); List embeds = []; diff --git a/lib/src/api/user.dart b/lib/src/api/user.dart index 88c478ed9..d1be29b45 100644 --- a/lib/src/api/user.dart +++ b/lib/src/api/user.dart @@ -82,7 +82,7 @@ class User { username: payload['username'], tag: "${payload['username']}#${payload['discriminator']}", discriminator: payload['discriminator'], - bot: payload['bot'] == true, + bot: payload['bot'], publicFlags: payload['public_flags'] ?? 0, avatar: payload['avatar'], avatarDecoration: payload['avatar_decoration'] diff --git a/lib/src/internal/websockets/packets/guild_create.dart b/lib/src/internal/websockets/packets/guild_create.dart index 5987018b4..7c3a17e9d 100644 --- a/lib/src/internal/websockets/packets/guild_create.dart +++ b/lib/src/internal/websockets/packets/guild_create.dart @@ -5,7 +5,6 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/channels/channel.dart'; import 'package:mineral/src/api/managers/guild_role_manager.dart'; -import 'package:mineral/src/api/guilds/guild_scheduled_event.dart'; import 'package:mineral/src/api/managers/channel_manager.dart'; import 'package:mineral/src/api/managers/emoji_manager.dart'; import 'package:mineral/src/api/managers/guild_scheduled_event_manager.dart'; From 83ac4b328141926ef58f058ea3ef5ff747eb2709 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 15:49:22 +0200 Subject: [PATCH 61/68] feat: Work on documentation settings --- assets/images/banner.png | Bin 0 -> 44627 bytes assets/images/icon.png | Bin 0 -> 10185 bytes dartdoc_options.yaml | 2 ++ lib/api.dart | 2 -- lib/console.dart | 1 + lib/core.dart | 1 + lib/exception.dart | 1 + lib/helper.dart | 1 + lib/internal.dart | 3 +-- lib/src/api/emoji.dart | 31 ------------------------------- lib/src/api/guilds/guild.dart | 3 ++- 11 files changed, 9 insertions(+), 36 deletions(-) create mode 100644 assets/images/banner.png create mode 100644 assets/images/icon.png create mode 100644 dartdoc_options.yaml diff --git a/assets/images/banner.png b/assets/images/banner.png new file mode 100644 index 0000000000000000000000000000000000000000..31935eaeb3e3882e45296466c2556d40872bc684 GIT binary patch literal 44627 zcmeFac|4WR`#*kLvSm-U6cR}bWyu!DAxY?vN`>sZkS$w|oDhju$Qp-`WXo1awo;L$ z>^mvSUiSSv_k9b!KY#xozkiy?Bj-N%J#)=9&$+g_X71BHoW>bC8crGrg6PhwC}}|u za{vVGh@_$bcdVimUVsm3dzCAW5X8z4|06l8bzlmDc%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EMI3_IY zk>af3ea7z4VxT`nT;~Yo+*o&Z>Pf}~eWn?2oFSbM_F<9E20xk+SCl7N@|TwJg$ldh6HdGq`Q7UY=%3YRehp1ZQeYkgm<9TtPBh< zk>kfrLFB078gT}pO8c{?-$7ae0qn?ODEL+WQG86CDKN;d{BevFJ|xYsM7V2JeEoBS zda!w=$SG%r$L+Ot?Tc#W?9WN%&AEQ)R20JkDW|}%H}@8U6$i`@e+H@MLEMC>zwE#A z@Bg{6r}p!%oqKnhF>`O=ZMNmeVhGr4CldP3XuG+*x&6tYce0BDz}mlpno7zCEP$md z;#>fbjKyT3a1H;T74Zp)^U9t}Fg!~$7g4R6=?EDbPe88L7?{2^wl3m#?R35BDZh_Ia z1RK-T_Y_orF8o|99slFvje2+cw$%CGk~uH0wSWI9s$%-#f_*&-U(2VfvMrug#Q$;M z>h}MWRi^F+jgD?GssD94{{J_7$PDD^FZbuy<^B77`FvXa!nnWxqCY>sUmyJooRSYb z>Tt__du;u0;9${&)N=+UUz%;>&?A)?*4uJ?C0bAwl!bN84eh|Ii@$elR0QNcC*0elqWG0pO6{u`e-yK3Tp~13P3+C$c-hLckH!8S!-n%1{mx6^WciVB&|6^D0cR z1vziP1UZnaOqig68&atN6I4KM5x@i;B#^QvOt8TKIc>p26Gt5i3koPb8lq?c0z4pi zG>xK#$!KOm3lIi|(c%dsNJa~M^dK3nnb1RoVYIHt2$JF7C~5e=x%fD^J>L9h?edL_ z9l-1cNk_=I6>^9i=)uzLOK?LP27swHP)6#Y!vtptLe6c0@xk;NjzuVZFei-#F@Ox0 zHEseA^}zWc#;7w#t) z02yu6p@hefYI~x%d^D${1;=PkM-7nCoQ@J6SabT69P0zoZ+TBGYy)p(^>p=fS?83{ F1OOpInsWdE literal 0 HcmV?d00001 diff --git a/assets/images/icon.png b/assets/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..7ad301fff64bbcc4d230eb245389fd4098dbf589 GIT binary patch literal 10185 zcmeHtc{tSH`}ccBCfj7EXr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git a/dartdoc_options.yaml b/dartdoc_options.yaml new file mode 100644 index 000000000..c4a3d44a8 --- /dev/null +++ b/dartdoc_options.yaml @@ -0,0 +1,2 @@ +dartdoc: + favicon: assets/images/icon.png diff --git a/lib/api.dart b/lib/api.dart index adfd7e537..b0d35bc4b 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,6 +1,4 @@ /// The api is the Map of all the classes, enumerations of the framework -/// -/// {@category Api} library api; export 'src/api/client/mineral_client.dart' show MineralClient, ClientActivity, ClientStatus, Intent; diff --git a/lib/console.dart b/lib/console.dart index d4e8d86b6..ee781990e 100644 --- a/lib/console.dart +++ b/lib/console.dart @@ -1,3 +1,4 @@ +/// Console to print formatted and beautifully messages library console; import 'package:mineral/core.dart'; diff --git a/lib/core.dart b/lib/core.dart index f336999c0..6babcd560 100644 --- a/lib/core.dart +++ b/lib/core.dart @@ -1,3 +1,4 @@ +/// 🧡 The neuralgic heart of the application, this module gathers all the functionalities of the framework. library core; export 'src/internal/environment.dart' show Environment; diff --git a/lib/exception.dart b/lib/exception.dart index 46b556997..ae8592dfc 100644 --- a/lib/exception.dart +++ b/lib/exception.dart @@ -1,3 +1,4 @@ +/// Core exceptions library exception; export 'src/exceptions/token_exception.dart'; diff --git a/lib/helper.dart b/lib/helper.dart index 44f9822aa..869eccaf8 100644 --- a/lib/helper.dart +++ b/lib/helper.dart @@ -1,3 +1,4 @@ +/// Helper class to simplify actions library helper; import 'dart:convert'; diff --git a/lib/internal.dart b/lib/internal.dart index 8f4b0f171..912ea70a6 100644 --- a/lib/internal.dart +++ b/lib/internal.dart @@ -1,6 +1,5 @@ /// The internal library is the collection of all classes needed by the framework to work. -/// -/// {@category Internal} +/// @nodoc library internal; export 'src/internal/websockets/websockets.dart'; diff --git a/lib/src/api/emoji.dart b/lib/src/api/emoji.dart index 10141d9e6..680ee6d10 100644 --- a/lib/src/api/emoji.dart +++ b/lib/src/api/emoji.dart @@ -5,11 +5,9 @@ import 'package:mineral/src/api/managers/emoji_manager.dart'; import 'package:mineral/src/api/managers/member_manager.dart'; /// Represents an [Emoji] on [Guild] context. -/// {@category Api} class Emoji { Snowflake id; String label; - //List roles; GuildMember? creator; bool requireColons; bool managed; @@ -47,34 +45,6 @@ class Emoji { } } - /// ### Modifies the [roles] of this. - /// - /// Example : - /// ```dart - /// final Emoji? emoji = guild.emojis.cache.get('240561194958716924'); - /// final Role? role = guild.roles.cache.get('240561194958716924'); - /// - /// if (role != null && emoji != null) { - /// await emoji.setRoles([role.id]); - /// } - /// ``` - /*Future setRoles (List roles) async { - Http http = ioc.singleton(ioc.services.http); - Response response = await http.patch(url: "/guilds/${manager.guildId}/emojis/$id", payload: { 'roles': roles }); - - if (response.statusCode == 200) { - List _roles = []; - for (Snowflake id in roles) { - Role? role = manager.guild?.roles.cache.get(id); - if (role != null) { - _roles.add(role); - } - } - - this.roles = _roles; - } - }*/ - /// ### Removes the current this from the [EmojiManager]'s cache /// /// Example : @@ -118,7 +88,6 @@ class Emoji { return Emoji( id: payload['id'], label: payload['name'], - //roles: roles, creator: payload['user'] != null ? memberManager.cache.get(payload['user']['id']) : null, requireColons: payload['require_colons'] ?? false, managed: payload['managed'] ?? false, diff --git a/lib/src/api/guilds/guild.dart b/lib/src/api/guilds/guild.dart index bdafbab06..180ff6f3d 100644 --- a/lib/src/api/guilds/guild.dart +++ b/lib/src/api/guilds/guild.dart @@ -213,11 +213,12 @@ class Guild { afkChannelId = channel.id; } } + /// ### Update the owner of this /// /// Warning : This method only works if the server was created via a discord bot and the bot is the current owner /// - /// See [documentation](Warning: This method only works if the server was created via a discord bot) + /// See [documentation](https://discord.com/developers/docs/resources/guild#modify-guild) /// /// Example : /// ```dart From 85ce3bc4f786b1225b95cc398dadfb8c9eaacd02 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 15:51:01 +0200 Subject: [PATCH 62/68] docs: Write README --- README.md | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 8b55e735b..b9c169e42 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,19 @@ - +The Mineral framework currently allows you to use the latest Discord features: +- Slashcommands/Subcommands/Subcommand group +- Modals +- Scheduled events +- Auto-moderation +- Select menus +- Buttons +- Ephemeral messages -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. +And much more... -## Features +Join our ranks and add your contribution to the best discord framework for Dart 💪 -TODO: List what your package can do. Maybe include images, gifs, or videos. - -## Getting started - -TODO: List prerequisites and provide or point to information on how to -start using the package. - -## Usage - -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. - -```dart -const like = 'sample'; -``` - -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. +https://github.com/mineral-dart From 1448a04b9c190761297a91c9328a59f3f72efe4e Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 16:12:45 +0200 Subject: [PATCH 63/68] chore: Create .pubignore --- .pubignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .pubignore diff --git a/.pubignore b/.pubignore new file mode 100644 index 000000000..ee889666e --- /dev/null +++ b/.pubignore @@ -0,0 +1 @@ +assets/ From 817f0d1120804bb8d29835f441c614342214d0f4 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 17:32:28 +0200 Subject: [PATCH 64/68] fix: Work in progress --- README.md | 2 +- lib/api.dart | 1 - lib/src/api/color.dart | 11 +- lib/src/api/guilds/guild_member.dart | 1 - lib/src/api/managers/voice_manager.dart | 39 ++++++- lib/src/api/voice.dart | 135 ------------------------ 6 files changed, 43 insertions(+), 146 deletions(-) delete mode 100644 lib/src/api/voice.dart diff --git a/README.md b/README.md index b9c169e42..1aac3707b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Mineral -![banner](https://github.com/mineral-dart/core/blob/develop/assets/images/banner.png) +![banner](https://raw.githubusercontent.com/mineral-dart/core/develop/assets/images/banner.png) Mineral is a robust, powerful and scalable framework designed to let you develop discord bots with the Dart language. diff --git a/lib/api.dart b/lib/api.dart index b0d35bc4b..48d1a3946 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -10,7 +10,6 @@ export 'src/api/status.dart' show Status, StatusType; export 'src/api/activity.dart' show Activity; export 'src/api/guilds/guild_member.dart' show GuildMember; export 'src/api/managers/member_role_manager.dart' show MemberRoleManager; -export 'src/api/voice.dart' show Voice; export 'src/api/guilds/guild.dart' show Guild; export 'src/api/moderation_rule.dart' show ModerationEventType, ModerationTriggerType, ModerationPresetType, ModerationActionType, ModerationTriggerMetadata, ModerationActionMetadata, ModerationAction, ModerationRule; diff --git a/lib/src/api/color.dart b/lib/src/api/color.dart index c57b56486..54fc44d79 100644 --- a/lib/src/api/color.dart +++ b/lib/src/api/color.dart @@ -1,17 +1,14 @@ /// Instance of colour. /// You can use a pre-designed colour panel /// -/// Example -/// - /// Example : - /// ```dart +/// Example : +/// ```dart /// import 'package:mineral/api.dart'; /// print(Color.cyan_600); /// ``` /// Or create your own colour instances -/// - /// Example : - /// ```dart +/// Example : +/// ```dart /// import 'package:mineral/api.dart'; /// print(Color('#FFFFFF')); // ``` diff --git a/lib/src/api/guilds/guild_member.dart b/lib/src/api/guilds/guild_member.dart index e00255534..ef3e0cee0 100644 --- a/lib/src/api/guilds/guild_member.dart +++ b/lib/src/api/guilds/guild_member.dart @@ -2,7 +2,6 @@ import 'package:http/http.dart'; import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; import 'package:mineral/src/api/managers/guild_role_manager.dart'; -import 'package:mineral/src/api/managers/member_role_manager.dart'; import 'package:mineral/src/api/managers/voice_manager.dart'; class GuildMember { diff --git a/lib/src/api/managers/voice_manager.dart b/lib/src/api/managers/voice_manager.dart index e2ff6135b..8b6d8127c 100644 --- a/lib/src/api/managers/voice_manager.dart +++ b/lib/src/api/managers/voice_manager.dart @@ -22,6 +22,15 @@ class VoiceManager { required this.channel }); + /// ### Mutes or unmute a server member + /// + /// Example : + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await member.setMute(true); + /// } Future setMute(bool value) async { final Http http = ioc.singleton(ioc.services.http); @@ -35,6 +44,15 @@ class VoiceManager { } } + /// ### Deafens or not a server member + /// + /// Example : + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await member.setDeaf(true); + /// } Future setDeaf(bool value) async { final Http http = ioc.singleton(ioc.services.http); final Response response = await http.patch( @@ -47,10 +65,29 @@ class VoiceManager { } } + /// ### Moves a member from one voice channel to another + /// + /// Example : + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// final voiceChannel = guild.channels.cache.get('240561194958716924'); + /// + /// if (member != null && voiceChannel != null) { + /// await member.move(voiceChannel.id); + /// } Future move(Snowflake channelId) async { _updateChannel(channelId); } + /// ### Disconnects the user from a voice channel + /// + /// Example : + /// ```dart + /// final member = guild.members.cache.get('240561194958716924'); + /// + /// if (member != null) { + /// await member.disconnect(); + /// } Future disconnect() async { _updateChannel(null); } @@ -83,4 +120,4 @@ class VoiceManager { } -} \ No newline at end of file +} diff --git a/lib/src/api/voice.dart b/lib/src/api/voice.dart deleted file mode 100644 index 8fd4e2701..000000000 --- a/lib/src/api/voice.dart +++ /dev/null @@ -1,135 +0,0 @@ -import 'package:http/http.dart'; -import 'package:mineral/api.dart'; -import 'package:mineral/core.dart'; - -class Voice { - Snowflake? channelId; - VoiceChannel? channel; - bool isDeaf; - bool isMuted; - late GuildMember member; - - Voice({ - required this.isDeaf, - required this.isMuted, - required this.channelId, - }); - - /// ### Mutes a server member - /// - /// Example : - /// ```dart - /// final member = guild.members.cache.get('240561194958716924'); - /// - /// if (member != null) { - /// await member.mute(); - /// } - Future mute () async { - Http http = ioc.singleton(ioc.services.http); - - Response response = await http.patch(url: "/guilds/${member.guild.id}/members/${member.user.id}", payload: { 'mute': true }); - if (response.statusCode == 200) { - isMuted = true; - } - } - - /// ### Remove mutes a server member - /// - /// Example : - /// ```dart - /// final member = guild.members.cache.get('240561194958716924'); - /// - /// if (member != null) { - /// await member.unmute(); - /// } - Future unmute () async { - Http http = ioc.singleton(ioc.services.http); - - Response response = await http.patch(url: "/guilds/${member.guild.id}/members/${member.user.id}", payload: { 'mute': false }); - if (response.statusCode == 200) { - isMuted = false; - } - } - - /// ### Deafens a server member - /// - /// Example : - /// ```dart - /// final member = guild.members.cache.get('240561194958716924'); - /// - /// if (member != null) { - /// await member.deaf(); - /// } - Future deaf () async { - Http http = ioc.singleton(ioc.services.http); - - Response response = await http.patch(url: "/guilds/${member.guild.id}/members/${member.user.id}", payload: { 'deaf': true }); - if (response.statusCode == 200) { - isDeaf = true; - } - } - - /// ### Remove deafens a server member - /// - /// Example : - /// ```dart - /// final member = guild.members.cache.get('240561194958716924'); - /// - /// if (member != null) { - /// await member.undeaf(); - /// } - Future undeaf () async { - Http http = ioc.singleton(ioc.services.http); - - Response response = await http.patch(url: "/guilds/${member.guild.id}/members/${member.user.id}", payload: { 'deaf': false }); - if (response.statusCode == 200) { - isDeaf = false; - } - } - - /// ### Moves a member from one voice channel to another - /// - /// Example : - /// ```dart - /// final member = guild.members.cache.get('240561194958716924'); - /// final voiceChannel = guild.channels.cache.get('240561194958716924'); - /// - /// if (member != null && voiceChannel != null) { - /// await member.move(voiceChannel); - /// } - Future move (VoiceChannel channel) async { - Http http = ioc.singleton(ioc.services.http); - - Response response = await http.patch(url: "/guilds/${member.guild.id}/members/${member.user.id}", payload: { 'channel_id': channel.id }); - if (response.statusCode == 200) { - channelId = channel.id; - this.channel = channel; - } - } - /// ### Disconnects the user from a voice channel - /// - /// Example : - /// ```dart - /// final member = guild.members.cache.get('240561194958716924'); - /// - /// if (member != null) { - /// await member.disconnect(); - /// } - Future disconnect () async { - Http http = ioc.singleton(ioc.services.http); - - Response response = await http.patch(url: "/guilds/${member.guild.id}/members/${member.user.id}", payload: { 'channel_id': null }); - if (response.statusCode == 200) { - channelId = null; - channel = null; - } - } - - factory Voice.from ({ required dynamic payload }) { - return Voice( - isDeaf: payload['deaf'] == false, - isMuted: payload['mute'] == false, - channelId: payload['channel_id'], - ); - } -} From 28a78cc0838a5b94a5f69334e69aefedb55bae3c Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 21:38:26 +0200 Subject: [PATCH 65/68] fix: user is bot --- lib/src/api/user.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/api/user.dart b/lib/src/api/user.dart index d1be29b45..88c478ed9 100644 --- a/lib/src/api/user.dart +++ b/lib/src/api/user.dart @@ -82,7 +82,7 @@ class User { username: payload['username'], tag: "${payload['username']}#${payload['discriminator']}", discriminator: payload['discriminator'], - bot: payload['bot'], + bot: payload['bot'] == true, publicFlags: payload['public_flags'] ?? 0, avatar: payload['avatar'], avatarDecoration: payload['avatar_decoration'] From ab33520281e0fd9dbfdfdb79305c7b9a8197951c Mon Sep 17 00:00:00 2001 From: Vic256 Date: Sat, 16 Jul 2022 22:30:16 +0200 Subject: [PATCH 66/68] fix: replace late by nullable field --- lib/src/api/managers/voice_manager.dart | 10 +++++----- .../websockets/packets/guild_member_update.dart | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/api/managers/voice_manager.dart b/lib/src/api/managers/voice_manager.dart index 8b6d8127c..a71ff1d78 100644 --- a/lib/src/api/managers/voice_manager.dart +++ b/lib/src/api/managers/voice_manager.dart @@ -3,7 +3,7 @@ import 'package:mineral/api.dart'; import 'package:mineral/core.dart'; class VoiceManager { - late final GuildMember member; + GuildMember? member; bool isDeaf; bool isMute; bool isSelfMute; @@ -35,7 +35,7 @@ class VoiceManager { final Http http = ioc.singleton(ioc.services.http); final Response response = await http.patch( - url: '/guilds/${member.guild.id}/members/${member.user.id}', + url: '/guilds/${member!.guild.id}/members/${member!.user.id}', payload: {'mute': value} ); @@ -56,7 +56,7 @@ class VoiceManager { Future setDeaf(bool value) async { final Http http = ioc.singleton(ioc.services.http); final Response response = await http.patch( - url: '/guilds/${member.guild.id}/members/${member.user.id}', + url: '/guilds/${member!.guild.id}/members/${member!.user.id}', payload: {'deaf': value} ); @@ -95,12 +95,12 @@ class VoiceManager { Future _updateChannel(Snowflake? channelId) async { final Http http = ioc.singleton(ioc.services.http); final Response response = await http.patch( - url: '/guilds/${member.guild.id}/members/${member.user.id}', + url: '/guilds/${member!.guild.id}/members/${member!.user.id}', payload: {'channel_id': channelId} ); if (response.statusCode == 204 || response.statusCode == 200) { - final VoiceChannel? channel = member.guild.channels.cache.get(channelId); + final VoiceChannel? channel = member!.guild.channels.cache.get(channelId); if (channel != null) { this.channel = channel; } diff --git a/lib/src/internal/websockets/packets/guild_member_update.dart b/lib/src/internal/websockets/packets/guild_member_update.dart index 4a6aee67a..4916a6439 100644 --- a/lib/src/internal/websockets/packets/guild_member_update.dart +++ b/lib/src/internal/websockets/packets/guild_member_update.dart @@ -34,7 +34,7 @@ class GuildMemberUpdate implements WebsocketPacket { ); after.guild = guild; - after.voice.member = after; + after.voice.member ??= after; //after.voice.member = after; //after.voice.channel = guild.channels.cache.get(after.voice.channelId); From 1970f9fe5701bfd42ee701f755a663a6d31c6a08 Mon Sep 17 00:00:00 2001 From: Freeze455 Date: Sat, 16 Jul 2022 23:29:31 +0200 Subject: [PATCH 67/68] refactor: Move delete channel method --- lib/src/api/channels/channel.dart | 9 +++++++++ lib/src/api/channels/text_based_channel.dart | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/src/api/channels/channel.dart b/lib/src/api/channels/channel.dart index 429b6464a..18bf2e792 100644 --- a/lib/src/api/channels/channel.dart +++ b/lib/src/api/channels/channel.dart @@ -95,6 +95,15 @@ class Channel extends PartialChannel { return this as T; } + Future delete () async { + Http http = ioc.singleton(ioc.services.http); + Response response = await http.destroy(url: "/channels/$id"); + + guild?.channels.cache.remove(id); + + return response.statusCode == 200; + } + @override String toString () => "<#$id>"; } diff --git a/lib/src/api/channels/text_based_channel.dart b/lib/src/api/channels/text_based_channel.dart index f566918c3..dccc64b52 100644 --- a/lib/src/api/channels/text_based_channel.dart +++ b/lib/src/api/channels/text_based_channel.dart @@ -111,13 +111,4 @@ class TextBasedChannel extends Channel { guild?.channels.cache.set(channel.id, channel); return channel; } - - Future delete () async { - Http http = ioc.singleton(ioc.services.http); - Response response = await http.destroy(url: "/channels/$id"); - - guild?.channels.cache.remove(id); - - return response.statusCode == 200; - } } From a3dd40218533b6f5e237d310dd229e64a9ffc20a Mon Sep 17 00:00:00 2001 From: Vic256 Date: Sun, 17 Jul 2022 00:55:22 +0200 Subject: [PATCH 68/68] fix: Return null if guild feature don't exist --- lib/src/api/guilds/guild.dart | 10 ++++++++-- lib/src/api/utils.dart | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/api/guilds/guild.dart b/lib/src/api/guilds/guild.dart index 180ff6f3d..e1c42c55e 100644 --- a/lib/src/api/guilds/guild.dart +++ b/lib/src/api/guilds/guild.dart @@ -16,6 +16,8 @@ import 'package:mineral/src/api/managers/guild_scheduled_event_manager.dart'; import 'package:mineral/src/api/sticker.dart'; import 'package:mineral/src/api/welcome_screen.dart'; +import 'package:collection/collection.dart'; + enum VerificationLevel { none(0), low(1), @@ -520,8 +522,12 @@ class Guild { List features = []; for (String element in payload['features']) { - GuildFeature feature = GuildFeature.values.firstWhere((feature) => feature.value == element); - features.add(feature); + GuildFeature? feature = GuildFeature.values.firstWhereOrNull((feature) => feature.value == element); + if(feature == null) { + Console.warn(message: 'Guild feature $element don\'t exist! Please report this to our team.'); + } else { + features.add(feature); + } } return Guild( diff --git a/lib/src/api/utils.dart b/lib/src/api/utils.dart index 1e8b9dcec..387908910 100644 --- a/lib/src/api/utils.dart +++ b/lib/src/api/utils.dart @@ -143,6 +143,7 @@ enum GuildFeature { partnered('PARTNERED'), preview('PREVIEW_ENABLED'), privateThreads('PRIVATE_THREADS'), + threeDayThreadArchive('THREE_DAY_THREAD_ARCHIVE'), roleIcons('ROLE_ICONS'), ticketedEvents('TICKETED_EVENTS_ENABLED'), vanityUrl('VANITY_URL'),