feat(slash): more...
This commit is contained in:
		
							parent
							
								
									6e014b353e
								
							
						
					
					
						commit
						b0d6092c25
					
				
					 2 changed files with 30 additions and 9 deletions
				
			
		|  | @ -277,11 +277,11 @@ export class RESTManager { | ||||||
|       message: body?.message, |       message: body?.message, | ||||||
|       errors: Object.fromEntries( |       errors: Object.fromEntries( | ||||||
|         Object.entries( |         Object.entries( | ||||||
|           body?.errors as { |           (body?.errors as { | ||||||
|             [name: string]: { |             [name: string]: { | ||||||
|               _errors: Array<{ code: string; message: string }> |               _errors: Array<{ code: string; message: string }> | ||||||
|             } |             } | ||||||
|           } |           }) ?? {} | ||||||
|         ).map((entry) => { |         ).map((entry) => { | ||||||
|           return [entry[0], entry[1]._errors] |           return [entry[0], entry[1]._errors] | ||||||
|         }) |         }) | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| import { Client, Intents } from '../../mod.ts' | import { Client, Intents } from '../../mod.ts' | ||||||
|  | import { Embed } from '../structures/embed.ts' | ||||||
| import { SlashCommandOptionType } from '../types/slash.ts' | import { SlashCommandOptionType } from '../types/slash.ts' | ||||||
| import { TOKEN } from './config.ts' | import { TOKEN } from './config.ts' | ||||||
| 
 | 
 | ||||||
|  | @ -9,12 +10,12 @@ client.on('ready', () => { | ||||||
|   client.slash.commands |   client.slash.commands | ||||||
|     .create( |     .create( | ||||||
|       { |       { | ||||||
|         name: 'eval', |         name: 'send', | ||||||
|         description: 'Run some JS code!', |         description: 'Send a Message through Bot!', | ||||||
|         options: [ |         options: [ | ||||||
|           { |           { | ||||||
|             name: 'code', |             name: 'content', | ||||||
|             description: 'Code to run', |             description: 'Message to send', | ||||||
|             type: SlashCommandOptionType.STRING, |             type: SlashCommandOptionType.STRING, | ||||||
|             required: true |             required: true | ||||||
|           } |           } | ||||||
|  | @ -45,7 +46,7 @@ client.on('interactionCreate', async (d) => { | ||||||
|         } |         } | ||||||
|         d.respond({ |         d.respond({ | ||||||
|           content: '```js\n' + `${res}` + '\n```' |           content: '```js\n' + `${res}` + '\n```' | ||||||
|         }) |         }).catch(() => {}) | ||||||
|       } catch (e) { |       } catch (e) { | ||||||
|         d.respond({ |         d.respond({ | ||||||
|           content: '```js\n' + `${e.stack}` + '\n```' |           content: '```js\n' + `${e.stack}` + '\n```' | ||||||
|  | @ -53,10 +54,30 @@ client.on('interactionCreate', async (d) => { | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     return |     return | ||||||
|  |   } else if (d.name === 'hug') { | ||||||
|  |     const id = d.data.options.find((e) => e.name === 'user')?.value as string | ||||||
|  |     const user = (await client.users.get(id)) ?? (await client.users.fetch(id)) | ||||||
|  |     const url = await fetch('https://nekos.life/api/v2/img/hug') | ||||||
|  |       .then((r) => r.json()) | ||||||
|  |       .then((e) => e.url) | ||||||
|  | 
 | ||||||
|  |     d.respond({ | ||||||
|  |       embeds: [ | ||||||
|  |         new Embed() | ||||||
|  |           .setTitle(`${d.user.username} hugged ${user?.username}!`) | ||||||
|  |           .setImage({ url }) | ||||||
|  |           .setColor(0x2f3136) | ||||||
|  |       ] | ||||||
|  |     }) | ||||||
|  |     return | ||||||
|  |   } else if (d.name === 'send') { | ||||||
|  |     d.respond({ | ||||||
|  |       content: d.data.options.find((e) => e.name === 'content')?.value as string | ||||||
|  |     }) | ||||||
|  |     return | ||||||
|   } |   } | ||||||
|   await d.respond({ |   await d.respond({ | ||||||
|     content: `Hi, ${d.member.user.username}!`, |     content: `Hi, ${d.member.user.username}! You used /${d.name}` | ||||||
|     flags: 64 |  | ||||||
|   }) |   }) | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue