-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from nyxx-discord/next
Release 4.0.0
- Loading branch information
Showing
59 changed files
with
2,100 additions
and
603 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'package:nyxx/nyxx.dart'; | ||
|
||
/// Additionnal info for certain action types | ||
/// | ||
/// [Look here for more](https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events) | ||
abstract class IAuditLogOptions { | ||
/// The channel in which the entites were targeted. | ||
Snowflake? get channelId; | ||
|
||
/// The number of entities targeted. | ||
int? get count; | ||
|
||
/// The number of days after which inactive users will be kicked. | ||
Duration? get deleteMemberDuration; | ||
|
||
/// Id of the overwritten entity. | ||
Snowflake? get id; | ||
|
||
/// The number of the members removed by the prune. | ||
int? get pruneCount; | ||
|
||
/// The id of the message that was targeted. | ||
Snowflake? get messageId; | ||
|
||
/// The name of the role that was targeted. (Not present if [overwrittenType] is `member`). | ||
String? get roleName; | ||
|
||
/// Type of overwritten entity. | ||
/// One of: | ||
/// - `role` | ||
/// - `member` | ||
String? get overwrittenType; | ||
} | ||
|
||
class AuditLogOptions implements IAuditLogOptions { | ||
/// The channel in which the entites were targeted. | ||
@override | ||
late final Snowflake? channelId; | ||
|
||
/// The number of entities targeted. | ||
@override | ||
late final int? count; | ||
|
||
/// The number of days after which inactive users will be kicked. | ||
@override | ||
late final Duration? deleteMemberDuration; | ||
|
||
/// Id of the overwritten entity. | ||
@override | ||
late final Snowflake? id; | ||
|
||
/// The number of the members removed by the prune. | ||
@override | ||
late final int? pruneCount; | ||
|
||
/// The id of the message that was targeted. | ||
@override | ||
late final Snowflake? messageId; | ||
|
||
/// The name of the role that was targeted. (Not present if [overwrittenType] is `member`). | ||
@override | ||
late final String? roleName; | ||
|
||
/// Type of overwritten entity. | ||
/// One of: | ||
/// - `role` | ||
/// - `member` | ||
@override | ||
late final String? overwrittenType; | ||
|
||
AuditLogOptions(RawApiMap raw) { | ||
channelId = (raw['channel_id'] as String?)?.toSnowflake(); | ||
count = raw['count'] != null ? int.parse(raw['count'] as String) : null; | ||
deleteMemberDuration = (raw['delete_member_days'] as String?) != null ? Duration(days: int.parse(raw['delete_member_days'] as String)) : null; | ||
id = (raw['id'] as String?)?.toSnowflake(); | ||
pruneCount = (raw['members_removed'] as String?) != null ? int.parse(raw['members_removed'] as String) : null; | ||
messageId = (raw['message_id'] as String?)?.toSnowflake(); | ||
roleName = raw['role_name'] as String?; | ||
switch (raw['type']) { | ||
case '0': | ||
overwrittenType = 'role'; | ||
break; | ||
case '1': | ||
overwrittenType = 'member'; | ||
break; | ||
default: | ||
overwrittenType = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'package:nyxx/src/core/channel/guild/forum/forum_tag.dart'; | ||
import 'package:nyxx/src/core/channel/guild/guild_channel.dart'; | ||
import 'package:nyxx/src/core/channel/thread_channel.dart'; | ||
import 'package:nyxx/src/core/channel/thread_preview_channel.dart'; | ||
import 'package:nyxx/src/core/snowflake.dart'; | ||
import 'package:nyxx/src/internal/interfaces/mentionable.dart'; | ||
import 'package:nyxx/src/internal/response_wrapper/thread_list_result_wrapper.dart'; | ||
import 'package:nyxx/src/nyxx.dart'; | ||
import 'package:nyxx/src/typedefs.dart'; | ||
import 'package:nyxx/src/utils/builders/forum_thread_builder.dart'; | ||
|
||
abstract class IForumChannel implements IGuildChannel, Mentionable { | ||
/// Tags available to assign to forum posts | ||
List<IForumTag> get availableTags; | ||
|
||
/// Creates a thread in a channel, that only retrieves a [ThreadPreviewChannel] | ||
Future<IThreadChannel> createThread(ForumThreadBuilder builder); | ||
|
||
/// Fetches joined private and archived thread channels | ||
Future<IThreadListResultWrapper> fetchJoinedPrivateArchivedThreads({DateTime? before, int? limit}); | ||
|
||
/// Fetches private, archived thread channels | ||
Future<IThreadListResultWrapper> fetchPrivateArchivedThreads({DateTime? before, int? limit}); | ||
|
||
/// Fetches public, archives thread channels | ||
Future<IThreadListResultWrapper> fetchPublicArchivedThreads({DateTime? before, int? limit}); | ||
} | ||
|
||
class ForumChannel extends GuildChannel implements IForumChannel { | ||
@override | ||
late final List<IForumTag> availableTags; | ||
|
||
/// Creates an instance of [TextGuildChannel] | ||
ForumChannel(INyxx client, RawApiMap raw, [Snowflake? guildId]) : super(client, raw, guildId) { | ||
availableTags = (raw['available_tags'] as List<dynamic>).cast<RawApiMap>().map((e) => ForumTag(e)).toList(); | ||
} | ||
|
||
/// The channel's mention string. | ||
@override | ||
String get mention => "<#$id>"; | ||
|
||
/// Creates a thread in a channel, that only retrieves a [ThreadPreviewChannel] | ||
@override | ||
Future<IThreadChannel> createThread(ForumThreadBuilder builder) => client.httpEndpoints.startForumThread(id, builder); | ||
|
||
/// Fetches joined private and archived thread channels | ||
@override | ||
Future<IThreadListResultWrapper> fetchJoinedPrivateArchivedThreads({DateTime? before, int? limit}) => | ||
client.httpEndpoints.fetchJoinedPrivateArchivedThreads(id, before: before, limit: limit); | ||
|
||
/// Fetches private, archived thread channels | ||
@override | ||
Future<IThreadListResultWrapper> fetchPrivateArchivedThreads({DateTime? before, int? limit}) => | ||
client.httpEndpoints.fetchPrivateArchivedThreads(id, before: before, limit: limit); | ||
|
||
/// Fetches public, archives thread channels | ||
@override | ||
Future<IThreadListResultWrapper> fetchPublicArchivedThreads({DateTime? before, int? limit}) => | ||
client.httpEndpoints.fetchPublicArchivedThreads(id, before: before, limit: limit); | ||
} |
Oops, something went wrong.