File tree Expand file tree Collapse file tree 3 files changed +56
-2
lines changed Expand file tree Collapse file tree 3 files changed +56
-2
lines changed Original file line number Diff line number Diff line change 77 "start" : " yarn build && yarn build:watch" ,
88 "build" : " tsc" ,
99 "build:watch" : " yarn tsc-watch --onSuccess 'node dist/App.js'" ,
10+ "test" : " jest" ,
1011 "auto:changelog" : " yarn auto changelog" ,
1112 "auto:version" : " yarn version --`auto version`" ,
1213 "auto:release" : " yarn auto:changelog && yarn auto:version" ,
3435 "tsc-watch" : " ^6.0.0" ,
3536 "typescript" : " ^5.0.2"
3637 },
38+ "jest" : {
39+ "preset" : " ts-jest" ,
40+ "testEnvironment" : " node" ,
41+ "testMatch" : [
42+ " **/src/**/*.test.ts"
43+ ]
44+ },
3745 "engines" : {
3846 "node" : " >=16.13.0"
3947 }
Original file line number Diff line number Diff line change 1+ import { generateHelloEmbed } from '.' ;
2+
3+ describe ( 'Hello Command' , ( ) => {
4+ it ( 'generates an embed correctly' , ( ) => {
5+ const embed = generateHelloEmbed ( ) ;
6+
7+ expect ( embed ) . not . toBeUndefined ( ) ;
8+ } ) ;
9+ it ( 'displays the correct fields in the embed' , ( ) => {
10+ const embed = generateHelloEmbed ( ) ;
11+
12+ expect ( embed . description ) . not . toBeUndefined ( ) ;
13+ expect ( embed . color ) . not . toBeUndefined ( ) ;
14+ expect ( embed . fields ) . not . toBeUndefined ( ) ;
15+ expect ( embed . fields && embed . fields . length ) . toBe ( 3 ) ;
16+ } ) ;
17+ } ) ;
Original file line number Diff line number Diff line change 1- import { SlashCommandBuilder } from 'discord.js' ;
1+ import { APIEmbed , SlashCommandBuilder } from 'discord.js' ;
22import { sendErrorLog } from '../../utils/helpers' ;
33import { AppCommand , AppCommandOptions } from '../commands' ;
44
5+ export function generateHelloEmbed ( ) : APIEmbed {
6+ const embed : APIEmbed = {
7+ title : 'Hello Command' ,
8+ color : 55296 ,
9+ description : 'Hi there! (◕ᴗ◕✿)' ,
10+ thumbnail : {
11+ url : 'https://cdn.discordapp.com/attachments/1089616880576245853/1094559253395689562/mitsuha.jpg' ,
12+ } ,
13+ fields : [
14+ {
15+ name : 'Field 1' ,
16+ value : 'This is a normal field!' ,
17+ } ,
18+ {
19+ name : 'Field 2' ,
20+ value : 'This is an inline field!' ,
21+ inline : true ,
22+ } ,
23+ {
24+ name : 'Field 3' ,
25+ value : 'This is an inline field too!' ,
26+ inline : true ,
27+ } ,
28+ ] ,
29+ } ;
30+ return embed ;
31+ }
32+
533export default {
634 data : new SlashCommandBuilder ( ) . setName ( 'hello' ) . setDescription ( 'Greets the user!' ) ,
735 async execute ( { interaction } : AppCommandOptions ) {
836 try {
937 await interaction . deferReply ( ) ;
10- await interaction . editReply ( 'Hello!' ) ;
38+ const embed = generateHelloEmbed ( ) ;
39+ await interaction . editReply ( { embeds : [ embed ] } ) ;
1140 } catch ( error ) {
1241 sendErrorLog ( { error, interaction } ) ;
1342 }
You can’t perform that action at this time.
0 commit comments