Last active
July 5, 2022 18:38
-
-
Save jeffque/9f277c168bfaeaf5c3a2adc5c72bb023 to your computer and use it in GitHub Desktop.
Alternativas para enviar mensagem em um canal, então fechar o bot.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as dotenvsafe from "dotenv-safe" | |
import * as Discord from "discord.js" | |
const createDeffered = () => { | |
let d = {}; | |
const promise = new Promise((resolve, reject) => { | |
d = { resolve, reject }; | |
}); | |
return { ...d, promise }; | |
}; | |
dotenvsafe.config(); | |
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] }); | |
const metaUploader = (discordChannel) => { | |
if (!discordChannel) { | |
throw new Error('aaaaahhhh'); | |
} | |
return async (msg) => { | |
await discordChannel.send(msg); | |
} | |
} | |
const d = createDeffered(); | |
await client.login(process.env.DISCORD_TOKEN); | |
let alakazamUploader; | |
client.on('ready', async () => { | |
alakazamUploader = metaUploader(client.channels.cache.get(process.env.DISCORD_OPS_CHANNEL_ID)); | |
d.resolve(); | |
}); | |
await d.promise; | |
await alakazamUploader('msg'); | |
await alakazamUploader('outra coisa'); | |
await client.destroy(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as dotenvsafe from "dotenv-safe" | |
import * as Discord from "discord.js" | |
dotenvsafe.config(); | |
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] }); | |
const metaUploader = (discordChannel) => { | |
if (!discordChannel) { | |
throw new Error('aaaaahhhh'); | |
} | |
return async (msg) => { | |
await discordChannel.send(msg); | |
} | |
} | |
client.onReady = new Promise((resolve), client.on('ready') => resolve()); | |
await client.login(process.env.DISCORD_TOKEN); | |
await client.onReady; | |
const alakazamUploader = metaUploader(client.channels.cache.get(process.env.DISCORD_OPS_CHANNEL_ID)); | |
await alakazamUploader('msg'); | |
await alakazamUploader('outra coisa'); | |
await client.destroy(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as dotenvsafe from "dotenv-safe" | |
import * as Discord from "discord.js" | |
dotenvsafe.config(); | |
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] }); | |
const metaUploader = (discordChannel) => { | |
if (!discordChannel) { | |
throw new Error('aaaaahhhh'); | |
} | |
return async (msg) => { | |
await discordChannel.send(msg); | |
} | |
} | |
await client.login(process.env.DISCORD_TOKEN); | |
const alakazamUploader = await new Promise(async (resolve, reject) => { | |
client.on('ready', async () => { | |
const alakazamAppUploader = metaUploader(client.channels.cache.get(process.env.DISCORD_OPS_CHANNEL_ID)); | |
resolve(alakazamAppUploader); | |
}); | |
}); | |
await alakazamUploader('msg'); | |
await alakazamUploader('outra coisa'); | |
await client.destroy(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as dotenvsafe from "dotenv-safe" | |
import * as Discord from "discord.js" | |
dotenvsafe.config(); | |
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] }); | |
const metaUploader = (discordChannel) => { | |
if (!discordChannel) { | |
throw new Error('aaaaahhhh'); | |
} | |
return async (msg) => { | |
await discordChannel.send(msg); | |
} | |
} | |
await client.login(process.env.DISCORD_TOKEN); | |
client.on('ready', async () => { | |
const alakazamUploader = metaUploader(client.channels.cache.get(process.env.DISCORD_OPS_CHANNEL_ID)); | |
await alakazamUploader('msg'); | |
await alakazamUploader('outra coisa'); | |
await client.destroy(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment