diff --git a/lib/src/main/builders/EmbedBuilder.dart b/lib/src/main/builders/EmbedBuilder.dart index 9d5f0a448..b420713b6 100644 --- a/lib/src/main/builders/EmbedBuilder.dart +++ b/lib/src/main/builders/EmbedBuilder.dart @@ -58,44 +58,32 @@ class EmbedBuilder { Map build() { Map tmp = new Map(); - if(title != null) - tmp["title"] = title; + if (title != null) tmp["title"] = title; - if(type != null) - tmp["type"] = type; + if (type != null) tmp["type"] = type; - if(description != null) - tmp["description"] = description; + if (description != null) tmp["description"] = description; - if(url != null) - tmp["url"] = url; + if (url != null) tmp["url"] = url; - if(timestamp != null) - tmp["timestamp"] = timestamp.toIso8601String(); + if (timestamp != null) tmp["timestamp"] = timestamp.toIso8601String(); - if(color != null) - tmp["color"] = color; + if (color != null) tmp["color"] = color; - if(footer != null) - tmp["footer"] = footer.build(); + if (footer != null) tmp["footer"] = footer.build(); - if(imageUrl != null) - tmp["image"] = { "url": imageUrl }; + if (imageUrl != null) tmp["image"] = {"url": imageUrl}; - if(thumbnailUrl != null) - tmp["thumbnail"] = { "url": thumbnailUrl }; + if (thumbnailUrl != null) + tmp["thumbnail"] = {"url": thumbnailUrl}; - if(videoUrl != null) - tmp["video"] = { "url": videoUrl }; + if (videoUrl != null) tmp["video"] = {"url": videoUrl}; - if(provider != null) - tmp["provider"] = provider.build(); + if (provider != null) tmp["provider"] = provider.build(); - if(author != null) - tmp["author"] = author.build(); + if (author != null) tmp["author"] = author.build(); - if(_fields.length > 0) - tmp["fields"] = _fields; + if (_fields.length > 0) tmp["fields"] = _fields; return tmp; } @@ -118,13 +106,11 @@ class EmbedFieldBuilder { Map build() { Map tmp = new Map(); - if(name != null) - tmp["name"] = name; + if (name != null) tmp["name"] = name; - if(content != null) - tmp["value"] = content; + if (content != null) tmp["value"] = content; - if(inline != null) + if (inline != null) tmp["inline"] = inline; else tmp["inline"] = false; @@ -144,11 +130,9 @@ class EmbedFooterBuilder { Map build() { Map tmp = new Map(); - if (text != null) - tmp["text"] = text; + if (text != null) tmp["text"] = text; - if (iconUrl != null) - tmp["icon_url"] = iconUrl; + if (iconUrl != null) tmp["icon_url"] = iconUrl; return tmp; } @@ -165,11 +149,9 @@ class EmbedProviderBuilder { Map build() { Map tmp = new Map(); - if (name != null) - tmp["name"] = name; + if (name != null) tmp["name"] = name; - if (url != null) - tmp["url"] = url; + if (url != null) tmp["url"] = url; return tmp; } @@ -189,14 +171,11 @@ class EmbedAuthorBuilder { Map build() { Map tmp = new Map(); - if (name != null) - tmp["name"] = name; + if (name != null) tmp["name"] = name; - if (url != null) - tmp["url"] = url; + if (url != null) tmp["url"] = url; - if (iconUrl != null) - tmp["icon_url"] = iconUrl; + if (iconUrl != null) tmp["icon_url"] = iconUrl; return tmp; } diff --git a/lib/src/main/objects/Embed.dart b/lib/src/main/objects/Embed.dart index 5f740d5e3..61db33600 100644 --- a/lib/src/main/objects/Embed.dart +++ b/lib/src/main/objects/Embed.dart @@ -21,7 +21,7 @@ class Embed { /// The embed's URL String url; - /// Timestamp of embed content + /// Timestamp of embed content DateTime timestamp; /// Color of embed @@ -54,7 +54,7 @@ class Embed { this.type = raw['type']; this.description = raw['description']; - if(raw['timestamp'] != null) + if (raw['timestamp'] != null) this.timestamp = DateTime.parse(raw['timestamp']); this.color = raw['color']; @@ -66,16 +66,19 @@ class Embed { this.video = new EmbedVideo._new(raw['video'] as Map); if (raw.containsKey('image')) - this.image = new EmbedThumbnail._new(raw['image'] as Map); + this.image = + new EmbedThumbnail._new(raw['image'] as Map); - if(raw.containsKey('footer')) + if (raw.containsKey('footer')) this.footer = new EmbedFooter._new(raw['footer'] as Map); if (raw.containsKey('thumbnail')) - this.thumbnail = new EmbedThumbnail._new(raw['thumbnail'] as Map); + this.thumbnail = + new EmbedThumbnail._new(raw['thumbnail'] as Map); if (raw.containsKey('provider')) - this.provider = new EmbedProvider._new(raw['provider'] as Map); + this.provider = + new EmbedProvider._new(raw['provider'] as Map); fields = new Map(); raw['fields'].forEach((Map o) { diff --git a/lib/src/main/objects/EmbedAuthor.dart b/lib/src/main/objects/EmbedAuthor.dart index 88c279432..771e90130 100644 --- a/lib/src/main/objects/EmbedAuthor.dart +++ b/lib/src/main/objects/EmbedAuthor.dart @@ -23,4 +23,4 @@ class EmbedAuthor { this.icon_url = raw['icon_url']; this.iconProxyUrl = raw['iconProxyUrl']; } -} \ No newline at end of file +} diff --git a/lib/src/main/objects/EmbedField.dart b/lib/src/main/objects/EmbedField.dart index 7d2cfeff3..7166ae91a 100644 --- a/lib/src/main/objects/EmbedField.dart +++ b/lib/src/main/objects/EmbedField.dart @@ -2,7 +2,6 @@ part of discord; /// Single instance of Embed's field. Can contain null elements. class EmbedField { - /// Field name String name; @@ -25,4 +24,4 @@ class EmbedField { this.embed.fields[name] = this; } -} \ No newline at end of file +} diff --git a/lib/src/main/objects/EmbedFooter.dart b/lib/src/main/objects/EmbedFooter.dart index 44b8674b2..31b83aa9c 100644 --- a/lib/src/main/objects/EmbedFooter.dart +++ b/lib/src/main/objects/EmbedFooter.dart @@ -19,4 +19,4 @@ class EmbedFooter { iconUrl = raw['icon_url']; iconProxyUrl = raw['icon_proxy_url']; } -} \ No newline at end of file +} diff --git a/lib/src/main/objects/EmbedVideo.dart b/lib/src/main/objects/EmbedVideo.dart index 6e7b5be14..0765319aa 100644 --- a/lib/src/main/objects/EmbedVideo.dart +++ b/lib/src/main/objects/EmbedVideo.dart @@ -1,7 +1,7 @@ part of discord; /// Video attached to embed. Can contain null elements. -class EmbedVideo { +class EmbedVideo { /// The embed video's URL. String url; @@ -19,4 +19,4 @@ class EmbedVideo { this.height = raw['height']; this.width = raw['width']; } -} \ No newline at end of file +} diff --git a/lib/src/main/objects/TextChannel.dart b/lib/src/main/objects/TextChannel.dart index 280a1598f..884fcc156 100644 --- a/lib/src/main/objects/TextChannel.dart +++ b/lib/src/main/objects/TextChannel.dart @@ -57,8 +57,10 @@ class TextChannel extends GuildChannel { newContent = content; } - final HttpResponse r = await this.client.http.send( - 'POST', '/channels/${this.id}/messages', body: { + final HttpResponse r = await this + .client + .http + .send('POST', '/channels/${this.id}/messages', body: { "content": newContent, "tts": tts, "nonce": nonce, @@ -69,6 +71,7 @@ class TextChannel extends GuildChannel { } @deprecated + /// Sends a message. /// /// Throws an [Exception] if the HTTP request errored. diff --git a/test/discord.dart b/test/discord.dart index e76acd40c..da92384e6 100644 --- a/test/discord.dart +++ b/test/discord.dart @@ -36,8 +36,7 @@ void main() { m.channel.send(content: "Command '${m.content}' not found!"); }) ..cooldownEvent.listen((m) { - m.channel - .send(content: "Command is on cooldown!. Wait a few seconds!"); + m.channel.send(content: "Command is on cooldown!. Wait a few seconds!"); }) ..ignoreBots = false; @@ -48,7 +47,7 @@ void main() { discord.EmbedBuilder createTestEmbed() { return new discord.EmbedBuilder("Test title") - ..addField(name: "Test field", value: "Test value"); + ..addField(name: "Test field", value: "Test value"); } bot.onReady.listen((e) async { @@ -78,7 +77,8 @@ void main() { await cc.delete(); print("TESTING EMBEDS"); - var e = await channel.send(content: "Testing embed!", embed: createTestEmbed()); + var e = + await channel.send(content: "Testing embed!", embed: createTestEmbed()); await e.delete(); }); @@ -112,12 +112,14 @@ void main() { if (m.channel.id == "422285619952222208" && m.author.id == bot.user.id && m.content == "Testing embed!") { - if(m.embeds.length > 0) { + if (m.embeds.length > 0) { var embed = m.embeds.values.toList()[0]; - if(embed.title == "Test title" && embed.fields.length > 0) { + if (embed.title == "Test title" && embed.fields.length > 0) { var field = embed.fields.values.toList()[0]; - if(field.name == "Test field" && field.content == "Test value" && !field.inline) { + if (field.name == "Test field" && + field.content == "Test value" && + !field.inline) { await m.channel.send(content: "Tests completed successfully!"); print("Nyxx tests completed successfully!"); await bot.destroy();