summaryrefslogtreecommitdiff
path: root/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/commands.c b/commands.c
index e7ba6cb..1928281 100644
--- a/commands.c
+++ b/commands.c
@@ -43,23 +43,14 @@ int help_command(struct string sender, struct string original_message, struct st
for (uint64_t i = 0; i < user_commands.len; i++) {
struct command_def *def = user_commands.array[i].ptr;
- uint64_t len = command_prefix.len;
- len += user_commands.array[i].name.len;
- len += 2;
- len += def->summary.len;
-
- char data[len];
- struct string message = {.data = data, .len = len};
- uint64_t offset = 0;
- memcpy(&(message.data[offset]), command_prefix.data, command_prefix.len);
- offset += command_prefix.len;
- memcpy(&(message.data[offset]), user_commands.array[i].name.data, user_commands.array[i].name.len);
- offset += user_commands.array[i].name.len;
- memcpy(&(message.data[offset]), "\x0F" " ", 2);
- offset += 2;
- memcpy(&(message.data[offset]), def->summary.data, def->summary.len);
-
- privmsg(STRING("1HC000000"), to, message);
+ struct string message[] = {
+ command_prefix,
+ user_commands.array[i].name,
+ STRING("\x0F" " "),
+ def->summary,
+ };
+
+ privmsg(STRING("1HC000000"), to, sizeof(message)/sizeof(*message), message);
}
return 0;