Skip to content

Commit

Permalink
feat(utility): letmegooglethat command
Browse files Browse the repository at this point in the history
  • Loading branch information
D4isDAVID committed Sep 27, 2024
1 parent d054628 commit 66e7dce
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/components/utility/commands/letmegooglethat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {
ApplicationCommandOptionType,
ApplicationCommandType,
} from '@discordjs/core';
import { hideLinkEmbed } from '@discordjs/formatters';
import { ChatInputCommand } from '/components/types.js';
import { mapChatInputOptionValues } from '/utils/interactions.js';

export const letmegooglethatCommand = {
data: {
type: ApplicationCommandType.ChatInput,
name: 'letmegooglethat',
description: 'Let me google that for you',
options: [
{
type: ApplicationCommandOptionType.String,
name: 'query',
description: 'Search query',
required: true,
},
{
type: ApplicationCommandOptionType.String,
name: 'type',
description: 'Search type',
choices: [
{
name: 'Books',
value: 'bks',
},
{
name: 'Images',
value: 'isch',
},
{
name: 'News',
value: 'nws',
},
{
name: 'Shopping',
value: 'shop',
},
{
name: 'Videos',
value: 'vid',
},
],
},
],
},
async execute({ api, data: interaction }) {
const { query, type } = mapChatInputOptionValues(interaction.data) as {
query: string;
type: string | undefined;
};

await api.interactions.reply(interaction.id, interaction.token, {
content: [
'Here, let me google that for you:',
hideLinkEmbed(
`https://google.com/search?q=${encodeURI(query)}${type ? `&tbm=${type}` : ''}`,
),
].join('\n'),
});
},
} satisfies ChatInputCommand;
2 changes: 2 additions & 0 deletions src/components/utility/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '../types.js';
import { guildCommand } from './commands/guild.js';
import { letmegooglethatCommand } from './commands/letmegooglethat.js';
import { plshelpCommand } from './commands/plshelp/chat-input-command.js';
import { plshelpMessageCommand } from './commands/plshelp/message-command.js';
import { spoonfeedCommand } from './commands/spoonfeed/chat-input-command.js';
Expand All @@ -8,6 +9,7 @@ import { spoonfeedMessageCommand } from './commands/spoonfeed/message-command.js
export default {
commands: [
guildCommand,
letmegooglethatCommand,
plshelpCommand,
plshelpMessageCommand,
spoonfeedCommand,
Expand Down

0 comments on commit 66e7dce

Please sign in to comment.