Add some more data structures
This commit is contained in:
parent
8cbf2466cf
commit
eae1f391de
5 changed files with 818 additions and 1 deletions
0
lib/discord/networking/guild.dart
Normal file
0
lib/discord/networking/guild.dart
Normal file
0
lib/discord/networking/sticker.dart
Normal file
0
lib/discord/networking/sticker.dart
Normal file
705
lib/discord/structures/guild.dart
Normal file
705
lib/discord/structures/guild.dart
Normal file
|
@ -0,0 +1,705 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:libac_dart/discord/structures/sticker.dart';
|
||||
import 'package:libac_dart/discord/structures/user.dart';
|
||||
import 'package:libac_dart/structs/Bitmasks.dart';
|
||||
import 'package:libac_dart/structs/Snowflake.dart';
|
||||
import 'package:libac_dart/utils/DictTools.dart';
|
||||
|
||||
class Guild {
|
||||
Snowflake id;
|
||||
String name;
|
||||
String? icon;
|
||||
String? icon_hash;
|
||||
String? splash;
|
||||
String? discoverySplash;
|
||||
bool? owner;
|
||||
Snowflake owner_id;
|
||||
BitMask? permissions;
|
||||
String? region;
|
||||
Snowflake? afk_channel_id;
|
||||
int afkTimeout;
|
||||
bool? widgetEnabled;
|
||||
Snowflake? widgetChannelID;
|
||||
int verificationLevel;
|
||||
int defaultMessageNotify;
|
||||
int explicitContentFilter;
|
||||
List<Role> roles;
|
||||
List<Emoji> emojis;
|
||||
List<GuildFeatures> features;
|
||||
int mfaLevel;
|
||||
Snowflake? applicationId;
|
||||
Snowflake? systemChannelId;
|
||||
int systemChannelFlags;
|
||||
Snowflake? rulesChannelId;
|
||||
int? maxPresences;
|
||||
int? maxMembers;
|
||||
String? vanityUrlCode;
|
||||
String? description;
|
||||
String? banner;
|
||||
int premiumTier;
|
||||
int? premiumSubscriptionCount;
|
||||
String preferredLocale;
|
||||
Snowflake? publicUpdateChannelId;
|
||||
int? maxVideoChannelUsers;
|
||||
int? maxStageVideoChannelUsers;
|
||||
int? approximateMemberCount;
|
||||
int? approximatePresenceCount;
|
||||
WelcomeScreen? welcomeScreen;
|
||||
int nsfwLevel;
|
||||
List<Sticker>? stickers;
|
||||
bool premiumProgressBarEnabled;
|
||||
Snowflake? safetyAlertsChannelId;
|
||||
|
||||
Guild(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
required this.icon,
|
||||
this.icon_hash,
|
||||
required this.splash,
|
||||
required this.discoverySplash,
|
||||
this.owner,
|
||||
required this.owner_id,
|
||||
this.permissions,
|
||||
this.region,
|
||||
required this.afk_channel_id,
|
||||
required this.afkTimeout,
|
||||
this.widgetEnabled,
|
||||
this.widgetChannelID,
|
||||
required this.verificationLevel,
|
||||
required this.defaultMessageNotify,
|
||||
required this.explicitContentFilter,
|
||||
required this.roles,
|
||||
required this.emojis,
|
||||
required this.features,
|
||||
required this.mfaLevel,
|
||||
required this.applicationId,
|
||||
required this.systemChannelId,
|
||||
required this.systemChannelFlags,
|
||||
required this.rulesChannelId,
|
||||
this.maxPresences,
|
||||
this.maxMembers,
|
||||
required this.vanityUrlCode,
|
||||
required this.description,
|
||||
required this.banner,
|
||||
required this.premiumTier,
|
||||
this.premiumSubscriptionCount,
|
||||
required this.preferredLocale,
|
||||
required this.publicUpdateChannelId,
|
||||
this.maxVideoChannelUsers,
|
||||
this.maxStageVideoChannelUsers,
|
||||
this.approximateMemberCount,
|
||||
this.approximatePresenceCount,
|
||||
this.welcomeScreen,
|
||||
required this.nsfwLevel,
|
||||
this.stickers,
|
||||
required this.premiumProgressBarEnabled,
|
||||
required this.safetyAlertsChannelId});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
List<Map<String, dynamic>> rolesJs = [];
|
||||
for (Role role in roles) {
|
||||
rolesJs.add(role.toJson());
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> emojiJs = [];
|
||||
for (Emoji emoji in emojis) {
|
||||
emojiJs.add(emoji.toJson());
|
||||
}
|
||||
|
||||
List<String> featureJs = [];
|
||||
for (GuildFeatures feature in features) {
|
||||
featureJs.add(feature.name);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>>? stickersJs = null;
|
||||
if (stickers != null) {
|
||||
stickersJs = [];
|
||||
|
||||
for (Sticker sticker in stickers!) {
|
||||
stickersJs.add(sticker.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"id": id.toString(),
|
||||
"name": name,
|
||||
"icon": icon ?? null,
|
||||
if (icon_hash != null) "icon_hash": icon_hash,
|
||||
"splash": splash ?? null,
|
||||
"discovery_splash": discoverySplash ?? null,
|
||||
if (owner != null) "owner": owner,
|
||||
"owner_id": owner_id.toString(),
|
||||
if (permissions != null) "permissions": permissions.toString(),
|
||||
if (region != null) "region": region,
|
||||
"afk_channel_id": afk_channel_id ?? null,
|
||||
if (widgetEnabled != null) "widget_enabled": widgetEnabled,
|
||||
if (widgetChannelID != null) "widget_channel_id": widgetChannelID,
|
||||
"verification_level": verificationLevel,
|
||||
"default_message_notifications": defaultMessageNotify,
|
||||
"explicit_content_filter": explicitContentFilter,
|
||||
"roles": rolesJs,
|
||||
"emojis": emojiJs,
|
||||
"features": featureJs,
|
||||
"mfa_level": mfaLevel,
|
||||
"application_id": applicationId == null ? null : applicationId.toString(),
|
||||
"system_channel_id":
|
||||
systemChannelId == null ? null : systemChannelId.toString(),
|
||||
"system_channel_flags": systemChannelFlags,
|
||||
"rules_channel_id":
|
||||
rulesChannelId != null ? rulesChannelId.toString() : null,
|
||||
if (maxPresences != null) "max_presences": maxPresences,
|
||||
if (maxMembers != null) "max_members": maxMembers,
|
||||
"vanity_url_code": vanityUrlCode,
|
||||
"description": description,
|
||||
"banner": banner,
|
||||
"premium_tier": premiumTier,
|
||||
if (premiumSubscriptionCount != null)
|
||||
"premium_subscription_count": premiumSubscriptionCount,
|
||||
"preferred_locale": preferredLocale,
|
||||
"public_updates_channel_id": publicUpdateChannelId == null
|
||||
? null
|
||||
: publicUpdateChannelId.toString(),
|
||||
if (maxVideoChannelUsers != null)
|
||||
"max_video_channel_users": maxVideoChannelUsers,
|
||||
if (maxStageVideoChannelUsers != null)
|
||||
"max_stage_video_channel_users": maxStageVideoChannelUsers,
|
||||
if (approximateMemberCount != null)
|
||||
"approximate_member_count": approximateMemberCount,
|
||||
if (approximatePresenceCount != null)
|
||||
"approximate_presence_count": approximatePresenceCount,
|
||||
if (welcomeScreen != null) "welcome_screen": welcomeScreen!.toJson(),
|
||||
"nsfw_level": nsfwLevel,
|
||||
if (stickers != null) "stickers": stickersJs,
|
||||
"premium_progress_bar_enabled": premiumProgressBarEnabled,
|
||||
"safety_alerts_channel_id": safetyAlertsChannelId == null
|
||||
? null
|
||||
: safetyAlertsChannelId.toString()
|
||||
};
|
||||
}
|
||||
|
||||
factory Guild.fromJson(String js) {
|
||||
return Guild.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory Guild.decode(Map<String, dynamic> js) {
|
||||
List<Role> JsRoles = [];
|
||||
List<Map<String, dynamic>> rolesJs =
|
||||
js['roles'] as List<Map<String, dynamic>>;
|
||||
for (var entry in rolesJs) {
|
||||
JsRoles.add(Role.decode(entry));
|
||||
}
|
||||
|
||||
List<Emoji> JsEmoji = [];
|
||||
for (var entry in js['emojis'] as List<Map<String, dynamic>>) {
|
||||
JsEmoji.add(Emoji.decode(entry));
|
||||
}
|
||||
|
||||
List<GuildFeatures> JsFeatures = [];
|
||||
for (var entry in js['features'] as List<String>) {
|
||||
GuildFeatures? gf = GuildFeatures.byName(entry);
|
||||
if (gf != null) JsFeatures.add(gf);
|
||||
}
|
||||
|
||||
List<Sticker>? JsSStickers = null;
|
||||
if (js.containsKey("stickers")) {
|
||||
JsSStickers = [];
|
||||
for (var entry in js['stickers'] as List<Map<String, dynamic>>) {
|
||||
JsSStickers.add(Sticker.decode(entry));
|
||||
}
|
||||
}
|
||||
|
||||
return Guild(
|
||||
id: Snowflake.parse(js['id'], Snowflake.DiscordEpoch),
|
||||
name: js['name'],
|
||||
icon: js['icon'],
|
||||
icon_hash: setor(js, "icon_hash", null),
|
||||
splash: js['splash'],
|
||||
discoverySplash: js['discovery_splash'],
|
||||
permissions: js.containsKey("permissions")
|
||||
? BitMask.of(int.parse(js['permissions']))
|
||||
: null,
|
||||
owner_id: Snowflake.parse(js['owner_id'], Snowflake.DiscordEpoch),
|
||||
afk_channel_id: js['afk_channel_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(js['afk_channel_id'], Snowflake.DiscordEpoch),
|
||||
afkTimeout: int.parse(js['afk_timeout']),
|
||||
widgetEnabled: js['widget_enabled'] == null
|
||||
? null
|
||||
: bool.parse(js['widget_enabled']),
|
||||
verificationLevel: int.parse(js['verification_level']),
|
||||
defaultMessageNotify: int.parse(js['default_message_notifications']),
|
||||
explicitContentFilter: int.parse(js['explicit_content_filter']),
|
||||
roles: JsRoles,
|
||||
emojis: JsEmoji,
|
||||
features: JsFeatures,
|
||||
mfaLevel: int.parse(js['mfa_level']),
|
||||
applicationId: js['application_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(js['application_id'], Snowflake.DiscordEpoch),
|
||||
systemChannelId: js['system_channel_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(js['system_channel_id'], Snowflake.DiscordEpoch),
|
||||
systemChannelFlags: int.parse(js['system_channel_flags']),
|
||||
rulesChannelId: js['rules_channel_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(js['rules_channel_id'], Snowflake.DiscordEpoch),
|
||||
maxPresences: js.containsKey("max_presences")
|
||||
? int.parse(js['max_presences'])
|
||||
: null,
|
||||
maxMembers:
|
||||
js.containsKey("max_members") ? int.parse(js['max_members']) : null,
|
||||
vanityUrlCode: setor(js, "vanity_url_code", null),
|
||||
description: setor(js, "description", null),
|
||||
banner: setor(js, "banner", null),
|
||||
premiumTier: int.parse(js['premium_tier']),
|
||||
premiumSubscriptionCount: js.containsKey("premium_subscription_count")
|
||||
? int.parse(js['premium_subscription_count'])
|
||||
: null,
|
||||
preferredLocale: js['preferred_locale'],
|
||||
publicUpdateChannelId: js['public_updates_channel_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(
|
||||
js['public_updates_channel_id'], Snowflake.DiscordEpoch),
|
||||
maxVideoChannelUsers: js.containsKey("max_video_channel_users")
|
||||
? int.parse(js['max_video_channel_users'])
|
||||
: null,
|
||||
maxStageVideoChannelUsers:
|
||||
js.containsKey("max_stage_video_channel_users")
|
||||
? int.parse(js['max_stage_video_channel_users'])
|
||||
: null,
|
||||
approximateMemberCount: js.containsKey("approximate_member_count")
|
||||
? int.parse(js['approximate_member_count'])
|
||||
: null,
|
||||
approximatePresenceCount: js.containsKey("approximate_presence_count")
|
||||
? int.parse(js['approximate_presence_count'])
|
||||
: null,
|
||||
welcomeScreen: js.containsKey("welcome_screen")
|
||||
? WelcomeScreen.decode(js['welcome_screen'])
|
||||
: null,
|
||||
nsfwLevel: int.parse(js['nsfw_level']),
|
||||
stickers: JsSStickers,
|
||||
premiumProgressBarEnabled:
|
||||
bool.parse(js['premium_progress_bar_enabled']),
|
||||
safetyAlertsChannelId: js['safety_alerts_channel_id'] != null
|
||||
? Snowflake.parse(
|
||||
js['safety_alerts_channel_id'], Snowflake.DiscordEpoch)
|
||||
: null);
|
||||
}
|
||||
}
|
||||
|
||||
class Role {
|
||||
Snowflake id;
|
||||
String name;
|
||||
int color;
|
||||
bool hoist;
|
||||
String? icon;
|
||||
String? unicodeEmoji;
|
||||
int position;
|
||||
BitMask perms;
|
||||
bool managed;
|
||||
bool mentionable;
|
||||
RoleTags? tags;
|
||||
BitMask flags;
|
||||
|
||||
Role(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
required this.color,
|
||||
required this.hoist,
|
||||
this.icon,
|
||||
this.unicodeEmoji,
|
||||
required this.position,
|
||||
required this.perms,
|
||||
required this.managed,
|
||||
required this.mentionable,
|
||||
this.tags,
|
||||
required this.flags});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"id": id.toString(),
|
||||
"name": name,
|
||||
"color": color,
|
||||
"hoist": hoist,
|
||||
if (icon != null) "icon": icon,
|
||||
if (unicodeEmoji != null) "unicode_emoji": unicodeEmoji,
|
||||
"position": position,
|
||||
"permissions": perms.toString(),
|
||||
"managed": managed,
|
||||
"mentionable": mentionable,
|
||||
if (tags != null) "tags": tags,
|
||||
"flags": flags
|
||||
};
|
||||
}
|
||||
|
||||
factory Role.fromJson(String js) {
|
||||
return Role.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory Role.decode(Map<String, dynamic> js) {
|
||||
return Role(
|
||||
id: Snowflake.parse(js['id'], Snowflake.DiscordEpoch),
|
||||
name: js['name'],
|
||||
color: int.parse(js['color']),
|
||||
hoist: bool.parse(js['hoist']),
|
||||
icon: js['icon'] == null ? null : js['icon'],
|
||||
unicodeEmoji: js['unicode_emoji'] == null ? null : js['unicode_emoji'],
|
||||
position: int.parse(js['position']),
|
||||
perms: BitMask.of(int.parse(js['permissions'])),
|
||||
managed: bool.parse(js['managed']),
|
||||
mentionable: bool.parse(js['mentionable']),
|
||||
tags: js['tags'] == null
|
||||
? null
|
||||
: RoleTags.decode(js['tags'] as Map<String, dynamic>),
|
||||
flags: BitMask.of(int.parse(js['flags'])));
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents one of discord's weird booleans in JSON that is null when true, and not present when false.
|
||||
class NullBool {
|
||||
dynamic getValue() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class RoleTags {
|
||||
Snowflake? bot_id;
|
||||
Snowflake? integrationId;
|
||||
NullBool? premiumSubscriber;
|
||||
Snowflake? subscriptionListingId;
|
||||
NullBool? availableForPurchase;
|
||||
NullBool? guildConnections;
|
||||
|
||||
RoleTags(
|
||||
{this.bot_id,
|
||||
this.integrationId,
|
||||
this.premiumSubscriber,
|
||||
this.subscriptionListingId,
|
||||
this.availableForPurchase,
|
||||
this.guildConnections});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (bot_id != null) "bot_id": bot_id.toString(),
|
||||
if (integrationId != null) "integration_id": integrationId.toString(),
|
||||
if (premiumSubscriber != null) "premium_subscriber": null,
|
||||
if (subscriptionListingId != null)
|
||||
"subscription_listing_id": subscriptionListingId.toString(),
|
||||
if (availableForPurchase != null) "available_for_purchase": null,
|
||||
if (guildConnections != null) "guild_connections": null
|
||||
};
|
||||
}
|
||||
|
||||
factory RoleTags.fromJson(String js) {
|
||||
return RoleTags.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory RoleTags.decode(Map<String, dynamic> js) {
|
||||
return RoleTags(
|
||||
bot_id: js['bot_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(js['bot_id'], Snowflake.DiscordEpoch),
|
||||
integrationId: js['integration_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(js['integration_id'], Snowflake.DiscordEpoch),
|
||||
premiumSubscriber:
|
||||
js.containsKey("premium_subscriber") ? NullBool() : null,
|
||||
subscriptionListingId: js['subscription_listing_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(
|
||||
js['subscription_listing_id'], Snowflake.DiscordEpoch),
|
||||
availableForPurchase:
|
||||
js.containsKey("available_for_purchase") ? NullBool() : null,
|
||||
guildConnections:
|
||||
js.containsKey("guild_connections") ? NullBool() : null);
|
||||
}
|
||||
}
|
||||
|
||||
enum PermissionFlags {
|
||||
CREATE_INSTANT_INVITE,
|
||||
KICK_MEMBERS,
|
||||
BAN_MEMBERS,
|
||||
ADMINISTRATOR,
|
||||
MANAGE_CHANNELS,
|
||||
MANAGE_GUILD,
|
||||
ADD_REACTIONS,
|
||||
VIEW_AUDIT_LOGS,
|
||||
PRIORITY_SPEAKER,
|
||||
STREAM,
|
||||
VIEW_CHANNEL,
|
||||
SEND_MESSAGES,
|
||||
SEND_TTS_MESSAGES,
|
||||
MANAGE_MESSAGES,
|
||||
EMBED_LINKS,
|
||||
ATTACH_FILES,
|
||||
READ_MESSAGE_HISTORY,
|
||||
MENTION_EVERYONE,
|
||||
USE_EXTERNAL_EMOJIS,
|
||||
VIEW_GUILD_INSIGHTS,
|
||||
CONNECT,
|
||||
SPEAK,
|
||||
MUTE_MEMBERS,
|
||||
DEAFEN_MEMBERS,
|
||||
MOVE_MEMBERS,
|
||||
USE_VAD,
|
||||
CHANGE_NICKNAME,
|
||||
MANAGE_NICKNAMES,
|
||||
MANAGE_ROLES,
|
||||
MANAGE_WEBHOOKS,
|
||||
MANAGE_GUILD_EXPRESSIONS,
|
||||
USE_APPLICATION_COMMANDS,
|
||||
REQUEST_TO_SPEAK,
|
||||
MANAGE_EVENTS,
|
||||
MANAGE_THREADS,
|
||||
CREATE_PUBLIC_THREADS,
|
||||
CREATE_PRIVATE_THREADS,
|
||||
USE_EXTERNAL_STICKERS,
|
||||
SEND_MESSAGES_IN_THREADS,
|
||||
USE_EMBEDDED_ACTIVITIES,
|
||||
MODERATE_MEMBERS,
|
||||
VIEW_CREATOR_MONETIZATION_ANALYTICS,
|
||||
USE_SOUNDBOARD,
|
||||
CREATE_GUILD_EXPRESSIONS,
|
||||
CREATE_EVENTS,
|
||||
USE_EXTERNAL_SOUNDS,
|
||||
SEND_VOICE_MESSAGES,
|
||||
SEND_POLLS,
|
||||
USE_EXTERNAL_APPS
|
||||
}
|
||||
|
||||
class Emoji {
|
||||
Snowflake id;
|
||||
String? name;
|
||||
List<Role>? roles;
|
||||
User? user;
|
||||
bool? requireColons;
|
||||
bool? managed;
|
||||
bool? animated;
|
||||
bool? available;
|
||||
|
||||
Emoji(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
this.roles,
|
||||
this.user,
|
||||
this.requireColons,
|
||||
this.managed,
|
||||
this.animated,
|
||||
this.available});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
List<Map<String, dynamic>> rolesJs = [];
|
||||
if (roles != null) {
|
||||
for (Role role in roles!) {
|
||||
rolesJs.add(role.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"id": id.toString(),
|
||||
"name": name,
|
||||
if (roles != null) "roles": rolesJs,
|
||||
if (user != null) "user": user!.toJson(),
|
||||
if (requireColons != null) "require_colons": requireColons,
|
||||
if (managed != null) "managed": managed,
|
||||
if (animated != null) "animated": animated,
|
||||
if (available != null) "available": available
|
||||
};
|
||||
}
|
||||
|
||||
factory Emoji.fromJson(String js) {
|
||||
return Emoji.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory Emoji.decode(Map<String, dynamic> js) {
|
||||
List<Role>? JsRoles = null;
|
||||
if (js.containsKey("roles")) {
|
||||
JsRoles = [];
|
||||
for (var entry in js['roles'] as List<Map<String, dynamic>>) {
|
||||
JsRoles.add(Role.decode(entry));
|
||||
}
|
||||
}
|
||||
return Emoji(
|
||||
id: Snowflake.parse(js['id'], Snowflake.DiscordEpoch),
|
||||
name: js['name'],
|
||||
roles: JsRoles,
|
||||
user: js.containsKey("user") ? User.decode(js['user']) : null,
|
||||
requireColons: js.containsKey("require_colons")
|
||||
? bool.parse(js['require_colons'])
|
||||
: null,
|
||||
managed: js.containsKey("managed") ? bool.parse(js['managed']) : null,
|
||||
animated:
|
||||
js.containsKey("animated") ? bool.parse(js['animated']) : null,
|
||||
available:
|
||||
js.containsKey("available") ? bool.parse(js['available']) : null);
|
||||
}
|
||||
}
|
||||
|
||||
/// Values obtained by names
|
||||
enum GuildFeatures {
|
||||
ANIMATED_BANNER,
|
||||
ANIMATED_ICON,
|
||||
APPLICATION_COMMAND_PERMISSIONS_V2,
|
||||
AUTO_MODERATION,
|
||||
BANNER,
|
||||
|
||||
/// Required Administrator
|
||||
COMMUNITY,
|
||||
CREATOR_MONETIZABLE_PROVISIONAL,
|
||||
CREATOR_STORE_PAGE,
|
||||
DEVELOPER_SUPPORT_SERVER,
|
||||
|
||||
/// Required Administrator
|
||||
DISCOVERABLE,
|
||||
FEATURABLE,
|
||||
|
||||
/// Requires Manage Guild
|
||||
INVITES_DISABLED,
|
||||
INVITE_SPLASH,
|
||||
MEMBER_VERIFICATION_GATE_ENABLED,
|
||||
MORE_STICKERS,
|
||||
NEWS,
|
||||
PARTNERED,
|
||||
PREVIEW_ENABLED,
|
||||
|
||||
/// Requires Manage Guild
|
||||
RAID_ALERTS_DISABLED,
|
||||
ROLE_ICONS,
|
||||
ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE,
|
||||
ROLE_SUBSCRIPTIONS_ENABLED,
|
||||
TICKETED_EVENTS_ENABLED,
|
||||
VANITY_URL,
|
||||
VERIFIED,
|
||||
VIP_REGIONS,
|
||||
WELCOME_SCREEN_ENABLED;
|
||||
|
||||
static GuildFeatures? byName(String sName) {
|
||||
for (GuildFeatures gf in GuildFeatures.values) {
|
||||
if (gf.name == sName) return gf;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Flags obtained by value
|
||||
enum SystemChannelFlags {
|
||||
SUPPRESS_JOIN_NOTIFICATIONS,
|
||||
SUPPRESS_PREMIUM_SUBSCRIPTIONS,
|
||||
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS,
|
||||
SUPPRESS_JOIN_NOTIFICATION_REPLIES,
|
||||
SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATIONS,
|
||||
SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATION_REPLIES
|
||||
}
|
||||
|
||||
/// Levels obtained by index
|
||||
enum PremiumTiers { NONE, TIER_1, TIER_2, TIER_3 }
|
||||
|
||||
/// Levels obtained by index
|
||||
enum GuildNSFWLevel { DEFAULT, EXPLICIT, SAFE, AGE_RESTRICTED }
|
||||
|
||||
/// Levels obtained by index
|
||||
enum VerificationLevel { NONE, LOW, MEDIUM, HIGH, VERY_HIGH }
|
||||
|
||||
/// Levels obtained by index
|
||||
enum MFALevel { NONE, ELEVATED }
|
||||
|
||||
/// Levels obtains by index
|
||||
enum ExplicitContentFilterLevels {
|
||||
DISABLED,
|
||||
MEMBERS_WITHOUT_ROLES,
|
||||
ALL_MEMBERS
|
||||
}
|
||||
|
||||
/// Levels obtained via index
|
||||
enum DefaultMessageNotificationLevel { ALL_MESSAGES, ONLY_MEMBERS }
|
||||
|
||||
class WelcomeScreen {
|
||||
String? description;
|
||||
List<WelcomeScreenChannel> welcomeChannels;
|
||||
|
||||
WelcomeScreen({required this.description, required this.welcomeChannels});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
List<Map<String, dynamic>> wscJs = [];
|
||||
for (WelcomeScreenChannel wsc in welcomeChannels) {
|
||||
wscJs.add(wsc.toJson());
|
||||
}
|
||||
|
||||
return {"description": description, "welcome_channels": wscJs};
|
||||
}
|
||||
|
||||
factory WelcomeScreen.fromJson(String js) {
|
||||
return WelcomeScreen.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory WelcomeScreen.decode(Map<String, dynamic> js) {
|
||||
List<WelcomeScreenChannel> wsc = [];
|
||||
for (var entry in js['welcome_channels']) {
|
||||
wsc.add(WelcomeScreenChannel.decode(entry));
|
||||
}
|
||||
|
||||
return WelcomeScreen(description: js['description'], welcomeChannels: wsc);
|
||||
}
|
||||
}
|
||||
|
||||
class WelcomeScreenChannel {
|
||||
Snowflake channelId;
|
||||
String description;
|
||||
Snowflake? emojiId;
|
||||
String? emojiName;
|
||||
|
||||
WelcomeScreenChannel(
|
||||
{required this.channelId,
|
||||
required this.description,
|
||||
required this.emojiId,
|
||||
required this.emojiName});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"channel_id": channelId.toString(),
|
||||
"description": description,
|
||||
"emoji_id": emojiId == null ? null : emojiId.toString(),
|
||||
"emoji_name": emojiName
|
||||
};
|
||||
}
|
||||
|
||||
factory WelcomeScreenChannel.fromJson(String js) {
|
||||
return WelcomeScreenChannel.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory WelcomeScreenChannel.decode(Map<String, dynamic> js) {
|
||||
return WelcomeScreenChannel(
|
||||
channelId: Snowflake.parse(js['channel_id'], Snowflake.DiscordEpoch),
|
||||
description: js['description'],
|
||||
emojiId: js['emoji_id'] == null
|
||||
? null
|
||||
: Snowflake.parse(js['emoji_id'], Snowflake.DiscordEpoch),
|
||||
emojiName: js['emoji_name']);
|
||||
}
|
||||
}
|
112
lib/discord/structures/sticker.dart
Normal file
112
lib/discord/structures/sticker.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:libac_dart/discord/structures/user.dart';
|
||||
|
||||
import '../../structs/Snowflake.dart';
|
||||
|
||||
class Sticker {
|
||||
Snowflake id;
|
||||
Snowflake? packId;
|
||||
String name;
|
||||
String? description;
|
||||
String tags;
|
||||
String? asset;
|
||||
int type;
|
||||
int formatType;
|
||||
bool? available;
|
||||
Snowflake? guildId;
|
||||
User? user;
|
||||
int? sortValue;
|
||||
|
||||
Sticker(
|
||||
{required this.id,
|
||||
this.packId,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.tags,
|
||||
this.asset,
|
||||
required this.type,
|
||||
required this.formatType,
|
||||
this.available,
|
||||
this.guildId,
|
||||
this.user,
|
||||
this.sortValue});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"id": id.toString(),
|
||||
if (packId != null) "pack_id": packId.toString(),
|
||||
"name": name,
|
||||
"description": description,
|
||||
"tags": tags,
|
||||
if (asset != null) "asset": asset,
|
||||
"type": type,
|
||||
"format_type": formatType,
|
||||
if (available != null) "available": available,
|
||||
if (guildId != null) "guild_id": guildId,
|
||||
if (user != null) "user": user!.toJson(),
|
||||
if (sortValue != null) "sort_value": sortValue
|
||||
};
|
||||
}
|
||||
|
||||
factory Sticker.fromJson(String js) {
|
||||
return Sticker.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory Sticker.decode(Map<String, dynamic> js) {
|
||||
return Sticker(
|
||||
id: Snowflake.parse(js['id'], Snowflake.DiscordEpoch),
|
||||
packId: js.containsKey("pack_id")
|
||||
? Snowflake.parse(js['pack_id'], Snowflake.DiscordEpoch)
|
||||
: null,
|
||||
name: js['name'],
|
||||
description: js['description'],
|
||||
tags: js['tags'],
|
||||
asset: js['asset'],
|
||||
type: js['type'],
|
||||
formatType: js['format_type'],
|
||||
available:
|
||||
js.containsKey("available") ? bool.parse(js['available']) : null,
|
||||
guildId: js.containsKey("guild_id")
|
||||
? Snowflake.parse(js['guild_id'], Snowflake.DiscordEpoch)
|
||||
: null,
|
||||
user: js.containsKey("user") ? User.decode(js['user']) : null,
|
||||
sortValue:
|
||||
js.containsKey("sort_value") ? int.parse(js['sort_value']) : null);
|
||||
}
|
||||
}
|
||||
|
||||
enum StickerType { STANDARD, GUILD }
|
||||
|
||||
enum StickerFormatTypes { PNG, APNG, LOTTIE, GIF }
|
||||
|
||||
class StickerItem {
|
||||
Snowflake id;
|
||||
String name;
|
||||
int formatType;
|
||||
|
||||
StickerItem({required this.id, required this.name, required this.formatType});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {"id": id.toString(), "name": name, "format_type": formatType};
|
||||
}
|
||||
|
||||
factory StickerItem.fromJson(String js) {
|
||||
return StickerItem.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory StickerItem.decode(Map<String, dynamic> js) {
|
||||
return StickerItem(
|
||||
id: Snowflake.parse(js['id'], Snowflake.DiscordEpoch),
|
||||
name: js['name'],
|
||||
formatType: int.parse(js['format_type']));
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
name: libac_dart
|
||||
description: "Aria's Creations code library"
|
||||
version: 1.2.071024+0309
|
||||
version: 1.2.071124+0214
|
||||
homepage: "https://zontreck.com"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue