如何将 variable/string(特定于 URL)从 discord 消息导出到 JS 文件?
How can I export a variable/string (URL specific) from discord message to the JS file?
我想知道如何将消息不和谐聊天中的字符串(URL)导出到 JS 文件并将其用作变量。我正在我的网站上测试一些抓取。
例如:
client.on('message', (msg) => {
if(msg.content === "!command " + "URL typed on discord chat" (example "https://www.Google.com") {
[...puppeteer stuff]
await page.goto(the URL I typed on discord chat, in this case "https://www.Google.com")
})
client.on('message', (msg) => {
// check if the message starts with '!command'
if(msg.content.startsWith("!command")) {
// splits message by spaces
// and gets second item in the array
// ["!command", "https://example.com", "foo"]
// ^^^^^^^^^^^^^^^^^^^
// which should be an URL
const url = msg.content.split(/\s+/)[1];
// puppeteer stuff
await page.goto(url);
}
})
我想知道如何将消息不和谐聊天中的字符串(URL)导出到 JS 文件并将其用作变量。我正在我的网站上测试一些抓取。 例如:
client.on('message', (msg) => {
if(msg.content === "!command " + "URL typed on discord chat" (example "https://www.Google.com") {
[...puppeteer stuff]
await page.goto(the URL I typed on discord chat, in this case "https://www.Google.com")
})
client.on('message', (msg) => {
// check if the message starts with '!command'
if(msg.content.startsWith("!command")) {
// splits message by spaces
// and gets second item in the array
// ["!command", "https://example.com", "foo"]
// ^^^^^^^^^^^^^^^^^^^
// which should be an URL
const url = msg.content.split(/\s+/)[1];
// puppeteer stuff
await page.goto(url);
}
})