Plugin
Search
Searchs the web.
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import { ApplicationCommandOptionType, findOption } from "@api/Commands";8
import { Devs } from "@utils/constants";9
import definePlugin from "@utils/types";10
11
export default definePlugin({12
name: "Search",13
authors: [Devs.FiveCord],14
description: "Searchs the web.",15
dependencies: ["CommandsAPI"],16
commands: [{17
name: "search",18
description: "Generates search link.",19
options: [20
{21
type: ApplicationCommandOptionType.STRING,22
name: "Search query",23
description: "What do you want to search?",24
required: true25
},26
{27
type: ApplicationCommandOptionType.STRING,28
name: "Search engine",29
description: "What do you want to search?",30
required: true,31
choices: [32
{ label: "Google", name: "Google", value: "google" },33
{ label: "Bing", name: "Bing", value: "bing" },34
{ label: "DuckDuckGo", name: "DuckDuckGo", value: "duckduckgo" },35
{ label: "Brave", name: "Brave", value: "brave" },36
{ label: "Yahoo", name: "Yahoo", value: "yahoo" },37
{ label: "Yandex", name: "Yandex", value: "yandex" },38
]39
}40
],41
42
execute(args) {43
const rfc3986EncodeURIComponent = str => encodeURIComponent(str).replace(/[!039;()*]/g, escape);44
const query = findOption<string>(args, "Search query");45
const engine = findOption<string>(args, "Search engine");46
let link;47
switch (engine) {48
case "google":49
link = `https:class="ts-cmt">//google.com/search?query=${rfc3986EncodeURIComponent(query)}`;50
break;51
case "bing":52
link = `https:class="ts-cmt">//bing.com/search?q=${rfc3986EncodeURIComponent(query)}`;53
break;54
case "duckduckgo":55
link = `https:class="ts-cmt">//duckduckgo.com/${rfc3986EncodeURIComponent(query)}`;56
break;57
case "brave":58
link = `https:class="ts-cmt">//search.brave.com/search?q=${rfc3986EncodeURIComponent(query)}`;59
break;60
case "yahoo":61
link = `https:class="ts-cmt">//search.yahoo.com/search?p=${rfc3986EncodeURIComponent(query)}`;62
break;63
case "yandex":64
link = `https:class="ts-cmt">//yandex.com/search?text=${rfc3986EncodeURIComponent(query)}`;65
break;66
}67
return {68
content: link69
};70
}71
}],72
});73