Skip to content

Commit

Permalink
Merge pull request #391 from nyxx-discord/dev
Browse files Browse the repository at this point in the history
Release 4.2.0
  • Loading branch information
l7ssha authored Nov 13, 2022
2 parents 1d3c4c1 + 9e2c73e commit a42d778
Show file tree
Hide file tree
Showing 30 changed files with 634 additions and 722 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## 4.2.0
__13.11.2022__

- feature: missing forum channel features (#387)
- feature: Add `activeDeveloper` flag (#388)
- feature: Add support for new select menus components (#380
- feature: Prefer using throw over returning Future.error
- bug: Fix null-assert error on shard disposal; don't reconnect shard after disposing
- bug: Cache user when fetching (#384)
- bug: add message content to client (#389)

## 4.2.0-dev.0
__11.11.2022__

- feature: missing forum channel features (#387)
- bug: Cache user when fetching (#384)

## 4.1.3
__01.11.2022__

Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.PHONY: help
help:
@fgrep -h "##" $(MAKEFILE_LIST) | sed -e 's/\(\:.*\#\#\)/\:\ /' | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
help: ## display help
@grep -F -h "##" $(MAKEFILE_LIST) | sed -e 's/\(\:.*\#\#\)/\:\ /' | grep -F -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

.PHONY: app-check ## Run basic format checks and then generate code coverage
app-check: format-check generate-coverage
.PHONY: app-check
app-check: format-check generate-coverage ## Run basic format checks and then generate code coverage

.PHONY: format-check ## Check basic format
format-check: format analyze
.PHONY: format-check
format-check: format analyze ## Check basic format

.PHONY: generate-coverage
generate-coverage: integration-tests unit-tests coverage-format coverage-gen-html ## Run all test and generate html code coverage
Expand Down
2 changes: 1 addition & 1 deletion example/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "package:nyxx/nyxx.dart";
// Main function
void main() async {
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand Down
4 changes: 2 additions & 2 deletions example/create_add_role.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "package:nyxx/nyxx.dart";
// Main function
void main() async {
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand All @@ -20,7 +20,7 @@ void main() async {
if (e.message.content == "!role") {

// Make sure that message was sent in guild not im dm, because we cant add roles in dms
if(e.message.guild != null) {
if (e.message.guild != null) {
return;
}

Expand Down
7 changes: 3 additions & 4 deletions example/embeds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ DiscordColor getColorForUserFromMessage(IMessage message) {
// Main function
void main() async {
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
..connect();

// Listen to ready event. Invoked when bot is connected to all shards. Note that cache can be empty or not incomplete.
bot.eventsWs.onReady.listen((IReadyEvent e) {
print("Ready!");
});

// Listen to all incoming messages
bot.eventsWs.onMessageReceived.listen((IMessageReceivedEvent e) {
bot.eventsWs.onMessageReceived.listen((IMessageReceivedEvent e) async {
// Check if message content equals "!embed"
if (e.message.content == "!embed") {

Expand All @@ -44,7 +43,7 @@ void main() async {
..color = getColorForUserFromMessage(e.message);

// Sent an embed to channel where message received was sent
e.message.channel.sendMessage(MessageBuilder.embed(embed));
await e.message.channel.sendMessage(MessageBuilder.embed(embed));
}
});

Expand Down
20 changes: 11 additions & 9 deletions example/emojis.dart
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
import 'package:nyxx/nyxx.dart';

void main(List<String> args) {
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
..connect();

bot.eventsWs.onReady.listen((_) {
print('Ready!');
});

// This event is called when a message is received
bot.eventsWs.onMessageReceived.listen((event) async {
if(event.message.content == '!emoji') {
if (event.message.content == '!emoji') {
final emoji = event.message.guild?.getFromCache()?.emojis.values.firstWhere((emo) => emo.name == 'nyxx');
final msg = await event.message.channel.sendMessage(MessageBuilder.content('Look at this emoji: $emoji'));
msg.createReaction(emoji!);
await msg.createReaction(emoji!);
// For unicode emoji use `UnicodeEmoji` class
msg.createReaction(UnicodeEmoji('🤔'));
await msg.createReaction(UnicodeEmoji('🤔'));
}
});

// This event is called when a reaction has been added to a message
bot.eventsWs.onMessageReactionAdded.listen((event) {
bot.eventsWs.onMessageReactionAdded.listen((event) async {
if (event.emoji is UnicodeEmoji) {
event.message?.channel.sendMessage(
await event.message?.channel.sendMessage(
MessageBuilder.content(
'Woah! This is a unicode emoji: ${event.emoji}',
),
);
} else if (event.emoji is IGuildEmojiPartial) {
if(event.emoji is IResolvableGuildEmojiPartial) {
if (event.emoji is IResolvableGuildEmojiPartial) {
final emoji = (event.emoji as IResolvableGuildEmojiPartial).resolve();
event.message?.channel.sendMessage(
await event.message?.channel.sendMessage(
MessageBuilder.content(
'Woah! This is a custom emoji: ${emoji.name}',
),
Expand Down
2 changes: 1 addition & 1 deletion example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "package:nyxx/nyxx.dart";
// Main function
void main() {
// Create new bot instance
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand Down
6 changes: 3 additions & 3 deletions example/invite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "package:nyxx/nyxx.dart";
// Main function
void main() {
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand All @@ -16,10 +16,10 @@ void main() {

// Listen to all incoming messages
bot.eventsWs.onMessageReceived.listen((IMessageReceivedEvent e) async {
// Check if message content equals "!embed"
// Check if message content equals "!create_channel"
if (e.message.content == "!create_channel") {
// Make sure that message was sent in guild not im dm, because we cant add roles in dms
if(e.message.guild != null) {
if (e.message.guild != null) {
return;
}

Expand Down
22 changes: 11 additions & 11 deletions example/kick_ban.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import "package:nyxx/nyxx.dart";

// Returns user that can be banned from message. Parses mention or raw id from message
SnowflakeEntity getUserToBan(IMessage message) {
SnowflakeEntity getUserToKickOrBan(IMessage message) {
// If mentions are not empty return first mention
if(message.mentions.isNotEmpty) {
if (message.mentions.isNotEmpty) {
return message.mentions.first.id.toSnowflakeEntity();
}

// Otherwise split message by spaces then take lst part and parse it to snowflake and return as Snowflake entity
// Otherwise split message by spaces then take last part and parse it to snowflake and return as Snowflake entity
return SnowflakeEntity(message.content.split(" ").last.toSnowflake());
}

// Main function
void main() {
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand All @@ -27,16 +27,16 @@ void main() {

// Listen to all incoming messages
bot.eventsWs.onMessageReceived.listen((IMessageReceivedEvent e) async {
// Check if message content equals "!embed"
// Check if message content equals "!ban"
if (e.message.content == "!ban") {

// Make sure that message was sent in guild not im dm, because we cant add roles in dms
if(e.message.guild != null) {
if (e.message.guild != null) {
return;
}

// Get user to ban
final userToBan = getUserToBan(e.message);
final userToBan = getUserToKickOrBan(e.message);

// Ban user using variable initialized before
await e.message.guild!.getFromCache()!.ban(userToBan);
Expand All @@ -45,15 +45,15 @@ void main() {
await e.message.channel.sendMessage(MessageBuilder.content("👍"));
}

// Check if message content equals "!embed"
if (e.message.content == "!ban") {
// Check if message content equals "!kick"
if (e.message.content == "!kick") {
// Make sure that message was sent in guild not im dm, because we cant add roles in dms
if(e.message.guild != null) {
if (e.message.guild != null) {
return;
}

// Get user to kick
final userToBan = getUserToBan(e.message);
final userToBan = getUserToKickOrBan(e.message);

// Kick user
await e.message.guild!.getFromCache()!.kick(userToBan);
Expand Down
2 changes: 1 addition & 1 deletion example/permissions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "package:nyxx/nyxx.dart";
// Main function
void main() {
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand Down
6 changes: 3 additions & 3 deletions example/ping_pong.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "package:nyxx/nyxx.dart";
// Main function
void main() {
// Create new bot instance
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand All @@ -15,11 +15,11 @@ void main() {
});

// Listen to all incoming messages
bot.eventsWs.onMessageReceived.listen((e) {
bot.eventsWs.onMessageReceived.listen((e) async {
// Check if message content equals "!ping"
if (e.message.content == "!ping") {
// Send "Pong!" to channel where message was received
e.message.channel.sendMessage(MessageBuilder.content("Pong!"));
await e.message.channel.sendMessage(MessageBuilder.content("Pong!"));
}
});
}
4 changes: 2 additions & 2 deletions example/reply_to_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "package:nyxx/nyxx.dart";
// Main function
void main() {
// Create new bot instance. Replace string with your token
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand All @@ -24,7 +24,7 @@ void main() {
final messageBuilder = MessageBuilder.content("This is how replies work")
..replyBuilder = replyBuilder;

// If you dont want to mention user that invoked that command user AllowedMentions
// If you dont want to mention user that invoked that command, use AllowedMentions
final allowedMentionsBuilder = AllowedMentions()
..allow(reply: false);

Expand Down
3 changes: 1 addition & 2 deletions example/sending_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "package:nyxx/nyxx.dart";
// Main function
void main() {
// Create new bot instance
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged)
final bot = NyxxFactory.createNyxxWebsocket("<TOKEN>", GatewayIntents.allUnprivileged | GatewayIntents.messageContent) // Here we use the privilegied intent message content to receive incoming messages.
..registerPlugin(Logging()) // Default logging plugin
..registerPlugin(CliIntegration()) // Cli integration for nyxx allows stopping application via SIGTERM and SIGKILl
..registerPlugin(IgnoreExceptions()) // Plugin that handles uncaught exceptions that may occur
Expand Down Expand Up @@ -50,7 +50,6 @@ void main() {
..thumbnailUrl = attachment.attachUrl;

// Send everything we created before to channel where message was received.
// e.message.channel.getFromCache()?.sendMessage(files: [attachment], embed: embed, content: "HEJKA!");
e.message.channel.sendMessage(
MessageBuilder.content("HEJKA!")
..embeds = [embed]
Expand Down
12 changes: 8 additions & 4 deletions lib/nyxx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export 'src/core/channel/cacheable_text_channel.dart' show ICacheableTextChannel
export 'src/core/channel/channel.dart' show IChannel, ChannelType;
export 'src/core/channel/dm_channel.dart' show IDMChannel;
export 'src/core/channel/text_channel.dart' show ITextChannel;
export 'src/core/channel/guild/forum/forum_channel.dart' show IForumChannel;
export 'src/core/channel/guild/forum/forum_channel.dart' show IForumChannel, ForumSortOrder;
export 'src/core/channel/guild/forum/forum_channel_tags.dart' show IForumChannelTags;
export 'src/core/channel/guild/forum/forum_tag.dart' show IForumTag;
export 'src/core/channel/thread_channel.dart' show IThreadMember, IThreadChannel;
export 'src/core/channel/thread_preview_channel.dart' show IThreadPreviewChannel;
Expand Down Expand Up @@ -69,15 +70,18 @@ export 'src/core/message/components/component_style.dart' show ButtonStyle;
export 'src/core/message/components/message_component.dart'
show
IMessageButton,
ICustomMessageButton,
ILinkMessageButton,
IMessageComponent,
IMessageComponentEmoji,
IMessageMultiselect,
IMessageMultiselectOption,
MessageComponentEmoji,
ComponentType,
IMessageTextInput;
IMessageTextInput,
IMessageUserMultiSelect,
IMessageRoleMultiSelect,
IMessageMentionableMultiSelect,
IMessageChannelMultiSelect;
export 'src/core/permissions/permission_overrides.dart' show IPermissionsOverrides;
export 'src/core/permissions/permissions.dart' show IPermissions;
export 'src/core/permissions/permissions_constants.dart' show PermissionsConstants;
Expand Down Expand Up @@ -182,7 +186,7 @@ export 'src/utils/builders/reply_builder.dart' show ReplyBuilder;
export 'src/utils/builders/sticker_builder.dart' show StickerBuilder;
export 'src/utils/builders/thread_builder.dart' show ThreadArchiveTime, ThreadBuilder;
export 'src/utils/builders/guild_event_builder.dart' show GuildEventBuilder;
export 'src/utils/builders/forum_thread_builder.dart' show ForumThreadBuilder;
export 'src/utils/builders/forum_thread_builder.dart' show ForumThreadBuilder, ForumTagBuilder;
export 'src/utils/builders/auto_moderation_builder.dart' show ActionMetadataBuilder, ActionStructureBuilder, AutoModerationRuleBuilder, TriggerMetadataBuilder;
export 'src/utils/extensions.dart' show IntExtensions, SnowflakeEntityListExtensions, StringExtensions;
export 'src/utils/permissions.dart' show PermissionsUtils;
Expand Down
Loading

0 comments on commit a42d778

Please sign in to comment.