Skip to content

Commit 6a2a1b6

Browse files
committed
refactor(commands/help): Move examples to a dedicated file
1 parent cf4f7c6 commit 6a2a1b6

File tree

9 files changed

+43
-73
lines changed

9 files changed

+43
-73
lines changed

commands/add.js

-13
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ module.exports = class AddCommand extends Command {
2020
flag: ['--reverse', '-r'],
2121
},
2222
],
23-
options: {
24-
help: {
25-
examples: [
26-
':emojiName:',
27-
'EmojiName :emojiName:',
28-
':emojiName: EmojiName',
29-
'EmojiName https://i.imgur.com/8jGJzmd.png',
30-
'https://i.imgur.com/8jGJzmd.png EmojiName',
31-
'EmojiName https://i.imgur.com/8jGJzmd.png --reverse',
32-
'EmojiName (supply only a name with an image attachment)',
33-
],
34-
},
35-
},
3623
})
3724
}
3825

commands/approve.js

-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ module.exports = class ApproveCommand extends Command {
1616
'default': 'emoji',
1717
},
1818
],
19-
options: {
20-
help: {
21-
examples: [
22-
'EmojiName (if `--mode=x` argument is omitted, defaults to `emoji`)',
23-
'EmojiName --mode=emoji (approves a pending emoji poll)',
24-
'EmojiName --mode=rename (approves a pending rename poll)',
25-
],
26-
},
27-
},
2819
})
2920
}
3021

commands/data/examples.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
add: [
3+
':emojiName:',
4+
'EmojiName :emojiName:',
5+
':emojiName: EmojiName',
6+
'EmojiName https: //i.imgur.com/8jGJzmd.png',
7+
'https: //i.imgur.com/8jGJzmd.png EmojiName',
8+
'EmojiName https: //i.imgur.com/8jGJzmd.png --reverse',
9+
'EmojiName (supply only a name with an image attachment)',
10+
],
11+
approve: [
12+
'EmojiName (if `--mode=x` argument is omitted, defaults to `emoji`)',
13+
'EmojiName --mode=emoji (approves a pending emoji poll)',
14+
'EmojiName --mode=rename (approves a pending rename poll)',
15+
],
16+
deny: [
17+
'EmojiName (if `--mode=x` argument is omitted, defaults to `emoji`)',
18+
'EmojiName --mode=emoji (approves a pending emoji poll)',
19+
'EmojiName --mode=rename (approves a pending rename poll)',
20+
],
21+
'emoji-search': ['EmojiName', ':emoji:'],
22+
help: ['', 'add'],
23+
rename: [
24+
'oldName newName (if `--mode=x` argument is omitted, defaults to `emoji`)',
25+
'oldName newName --mode=poll (renames a pending poll you\'ve made)',
26+
':oldEmoji: newName',
27+
'newName :oldEmoji:',
28+
],
29+
server: ['1'],
30+
sync: [
31+
'all',
32+
'invites',
33+
'info 2 (`1` is invalid)',
34+
'galleries',
35+
'gallery 2',
36+
'status',
37+
],
38+
}

commands/deny.js

-9
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ module.exports = class DenyCommand extends Command {
1515
'default': 'emoji',
1616
},
1717
],
18-
options: {
19-
help: {
20-
examples: [
21-
'EmojiName (if `--mode=x` argument is omitted, defaults to `emoji`)',
22-
'EmojiName --mode=emoji (approves a pending emoji poll)',
23-
'EmojiName --mode=rename (approves a pending rename poll)',
24-
],
25-
},
26-
},
2718
})
2819
}
2920

commands/emoji-search.js

-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ module.exports = class EmojiSearchCommand extends Command {
1717
},
1818
},
1919
],
20-
options: {
21-
help: {
22-
examples: ['EmojiName', ':emoji:'],
23-
},
24-
},
2520
})
2621
}
2722

commands/help.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { MessageEmbed } = require('discord.js')
22
const { Command } = require('discord-akairo')
33
const { colors } = require('../config.js')
4+
const examples = require('./data/examples.js')
45
const textUtil = require('../util/text.js')
56
const permissionsUtil = require('../util/permissions.js')
67

@@ -26,11 +27,6 @@ module.exports = class HelpCommand extends Command {
2627
},
2728
},
2829
],
29-
options: {
30-
help: {
31-
examples: ['', 'add'],
32-
},
33-
},
3430
})
3531
}
3632

@@ -60,12 +56,11 @@ module.exports = class HelpCommand extends Command {
6056
embed.addField('User permissions needed', permissionsUtil.formatNames(command.userPermissions), true)
6157
}
6258

63-
// NOTE: `Command.options` has been removed; need to approach this differently
64-
// const { help: helpData = {} } = command.options;
59+
const { [command]: commandExamples } = examples
6560

66-
// if (helpData.examples && helpData.examples.length) {
67-
// embed.addField('Examples', helpData.examples.map(example => `${prefix}${command.id} ${example}`).join('\n'));
68-
// }
61+
if (commandExamples && commandExamples.length) {
62+
embed.addField('Examples', commandExamples.map(example => `${prefix}${command.id} ${example}`).join('\n'))
63+
}
6964

7065
return message.util.send(embed)
7166
}

commands/rename.js

-10
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ module.exports = class RenameCommand extends Command {
2525
match: 'rest',
2626
},
2727
],
28-
options: {
29-
help: {
30-
examples: [
31-
'oldName newName (if `--mode=x` argument is omitted, defaults to `emoji`)',
32-
'oldName newName --mode=poll (renames a pending poll you\'ve made)',
33-
':oldEmoji: newName',
34-
'newName :oldEmoji:',
35-
],
36-
},
37-
},
3828
})
3929
}
4030

commands/server.js

-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ module.exports = class ServerCommand extends Command {
1717
},
1818
},
1919
],
20-
options: {
21-
help: {
22-
examples: ['1'],
23-
},
24-
},
2520
})
2621
}
2722

commands/sync.js

-12
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ module.exports = class SyncCommand extends Command {
3232
flag: ['--force', '-f'],
3333
},
3434
],
35-
options: {
36-
help: {
37-
examples: [
38-
'all',
39-
'invites',
40-
'info 2 (`1` is invalid)',
41-
'galleries',
42-
'gallery 2',
43-
'status',
44-
],
45-
},
46-
},
4735
})
4836
}
4937

0 commit comments

Comments
 (0)