forked from Astaboi768/Ilom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefine.js
More file actions
44 lines (35 loc) · 1.33 KB
/
define.js
File metadata and controls
44 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const axios = require('axios');
module.exports = {
config: {
name: "def",
aliases: ['Define', 'define'],
author: "Hassan",
version: "1.0",
shortDescription: "Get the definition of a word",
longDescription: "Retrieve the definition of a specified word using the Hassan Dictionary API.",
category: "education",
guide: {
vi: "",
en: ""
}
},
onStart: async function ({ message, args }) {
if (args.length === 0) {
return message.reply("Please provide a word to define.");
}
const word = args[0];
const url = `https://hassan-definition-api.onrender.com/dictionary/${word}`;
try {
message.reply(`🔄 searching"${word}"...`);
const response = await axios.get(url);
const data = response.data;
if (!data.valid) {
return message.reply(`Sorry, no definition found for "${word}".`);
}
const definition = data.definition;
return message.reply(`📖 Definition of "${word}":\n\n${definition}`);
} catch (error) {
console.error('Error fetching definition:', error);
return message.reply("Sorry, there was an error fetching the definition.");
}
}