2020-11-06 07:31:53 +00:00
|
|
|
import { Client, Message, Intents } from '../mod.ts'
|
|
|
|
|
|
|
|
const client = new Client();
|
|
|
|
|
|
|
|
client.on("ready", () => {
|
|
|
|
console.log(`Logged in as ${client.user?.tag}!`);
|
|
|
|
});
|
|
|
|
|
|
|
|
client.on("messageCreate", (msg: Message) => {
|
2020-11-07 02:32:14 +00:00
|
|
|
if (msg.content === "!ping") {
|
2020-11-06 07:31:53 +00:00
|
|
|
console.log("Command Used: Ping");
|
|
|
|
msg.reply("pong!");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log("discord.deno - ping example");
|
|
|
|
|
|
|
|
const token = prompt("Input Bot Token:");
|
2020-11-07 02:53:42 +00:00
|
|
|
if (token === null) {
|
2020-11-06 07:31:53 +00:00
|
|
|
console.log("No token provided");
|
|
|
|
Deno.exit();
|
|
|
|
}
|
|
|
|
|
2020-11-06 10:42:00 +00:00
|
|
|
const intents = prompt("Input Intents (0 = All, 1 = Presence, 2 = Server Members, 3 = None):");
|
2020-11-07 02:53:42 +00:00
|
|
|
if (intents === null || !["0", "1", "2", "3"].includes(intents)) {
|
2020-11-06 07:31:53 +00:00
|
|
|
console.log("No intents provided");
|
|
|
|
Deno.exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
let ints;
|
2020-11-07 02:53:42 +00:00
|
|
|
if (intents === "0") {
|
2020-11-06 07:31:53 +00:00
|
|
|
ints = Intents.All;
|
2020-11-07 02:53:42 +00:00
|
|
|
} else if (intents === "1") {
|
2020-11-06 07:31:53 +00:00
|
|
|
ints = Intents.Presence;
|
2020-11-07 02:53:42 +00:00
|
|
|
} else if (intents === "2") {
|
2020-11-06 07:31:53 +00:00
|
|
|
ints = Intents.GuildMembers;
|
2020-11-06 10:42:00 +00:00
|
|
|
} else {
|
|
|
|
ints = Intents.None;
|
2020-11-06 07:31:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
client.connect(token, ints);
|