LOADING JASON DISCORD HOST V1
LOADING JASON DISCORD HOST V1
Jason Discord Host V1
Drop this bot into a community server when you want lightweight fun without API keys. All punchlines ship in the repo so it works on a fresh VPS with zero extra services.
Enable: Guilds only.
require("dotenv").config();
const {
Client,
GatewayIntentBits,
EmbedBuilder,
SlashCommandBuilder,
Events,
MessageFlags,
} = require("discord.js");
const TOKEN = process.env.DISCORD_TOKEN;
const GUILD_ID = process.env.GUILD_ID?.trim();
if (!TOKEN) {
console.error("Missing DISCORD_TOKEN. Copy .env.example to .env and add your bot token.");
process.exit(1);
}
const client = new Client({
intents: [GatewayIntentBits.Guilds],
});
const jokes = [
"I told my Discord bot a joke about UDP, but I am not sure it got it.",
"Why did the developer go broke? Because they used up all their cache.",
"I would tell you a UDP joke, but you might not get it.",
"A SQL query walks into a bar, walks up to two tables, and asks: may I join you?",
"There are only 10 kinds of people: those who understand binary and those who do not.",
"Why do programmers prefer dark mode? Because light attracts bugs.",
"I changed my password to \"incorrect\" so that when I forget it, the computer says it is incorrect.",
"How do you comfort a JavaScript bug? You console it.",
"A pixel walks into a bar looking for a drink. The bartender says: sorry, we are out of refreshments.",
"Why was the computer cold? It left its Windows open.",
];
const eightBall = [
"It is certain.",
"Without a doubt.",
"Yes — definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Signs point to yes.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Don't count on it.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful.",
];
const memes = [
"Nobody:\nAbsolutely nobody:\nThis bot: deploying slash commands like it is 2019.",
"Task failed successfully.",
"It is not a bug, it is an undocumented feature.",
"Me: I will only add one more slash command.\nAlso me: `/rps`, `/wyr`, `/meme`…",
"When the ticket is just \"hi\".",
"Production is just staging with extra confidence.",
"Have you tried turning the router off and on again?",
];
const wyrs = [
["Ship on Friday", "Hotfix on Saturday"],
["Unlimited RAM", "Unlimited coffee"],
["Never use dark mode again", "Never use Stack Overflow again"],
["Voice chat with 200ms ping forever", "Text chat that only allows GIFs"],
["One endless meeting", "One endless merge conflict"],
];
function pick(list) {
return list[Math.floor(Math.random() * list.length)];
}
function neonEmbed(title, description) {
return new EmbedBuilder()
.setColor(0xff2bd6)
.setTitle(title)
.setDescription(description)
.setFooter({ text: "Jason Discord Host V1 · Fun Bot" })
.setTimestamp();
}
const commands = [
new SlashCommandBuilder().setName("ping").setDescription("Check that Fun Bot is online."),
new SlashCommandBuilder().setName("joke").setDescription("Tell a random programming / Discord joke."),
new SlashCommandBuilder()
.setName("8ball")
.setDescription("Ask the magic eight ball a question.")
.addStringOption((o) => o.setName("question").setDescription("Your question").setRequired(true)),
new SlashCommandBuilder().setName("coinflip").setDescription("Flip a coin."),
new SlashCommandBuilder()
.setName("rps")
.setDescription("Play rock-paper-scissors against the bot.")
.addStringOption((o) =>
o
.setName("choice")
.setDescription("Your move")
.setRequired(true)
.addChoices(
{ name: "Rock", value: "rock" },
{ name: "Paper", value: "paper" },
{ name: "Scissors", value: "scissors" },
),
),
new SlashCommandBuilder().setName("wyr").setDescription("Would you rather?"),
new SlashCommandBuilder().setName("meme").setDescription("Drop a text meme."),
].map((c) => c.toJSON());
function rpsResult(player, bot) {
if (player === bot) return "It's a tie.";
const wins =
(player === "rock" && bot === "scissors") ||
(player === "paper" && bot === "rock") ||
(player === "scissors" && bot === "paper");
return wins ? "You win!" : "The bot wins.";
}
async function registerCommands() {
if (GUILD_ID) {
const guild = await client.guilds.fetch(GUILD_ID);
await guild.commands.set(commands);
console.log(`Registered guild commands in ${guild.name}`);
return;
}
await client.application.commands.set(commands);
console.log("Registered global slash commands.");
}
client.once(Events.ClientReady, async () => {
console.log(`Fun Bot online as ${client.user.tag}`);
try {
await registerCommands();
} catch (error) {
console.error("Failed to register commands:", error);
}
});
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;
try {
switch (interaction.commandName) {
case "ping":
await interaction.reply({ content: `Pong — ${client.ws.ping}ms`, flags: MessageFlags.Ephemeral });
break;
case "joke":
await interaction.reply({ embeds: [neonEmbed("Joke", pick(jokes))] });
break;
case "8ball": {
const question = interaction.options.getString("question", true);
await interaction.reply({
embeds: [neonEmbed("Magic 8-Ball", `**${question}**\n\n${pick(eightBall)}`)],
});
break;
}
case "coinflip":
await interaction.reply({ embeds: [neonEmbed("Coin flip", Math.random() < 0.5 ? "Heads" : "Tails")] });
break;
case "rps": {
const choice = interaction.options.getString("choice", true);
const bot = pick(["rock", "paper", "scissors"]);
await interaction.reply({
embeds: [
neonEmbed(
"Rock · Paper · Scissors",
`You chose **${choice}**. I chose **${bot}**.\n\n**${rpsResult(choice, bot)}**`,
),
],
});
break;
}
case "wyr": {
const pair = pick(wyrs);
await interaction.reply({
embeds: [neonEmbed("Would you rather", `**A.** ${pair[0]}\n**B.** ${pair[1]}`)],
});
break;
}
case "meme":
await interaction.reply({ embeds: [neonEmbed("Meme drop", pick(memes))] });
break;
default:
break;
}
} catch (error) {
console.error(error);
if (!interaction.replied) {
await interaction.reply({ content: "The joke machine jammed. Try again.", flags: MessageFlags.Ephemeral }).catch(() => null);
}
}
});
client.login(TOKEN).catch((error) => {
console.error("Login failed. Check DISCORD_TOKEN.", error);
process.exit(1);
});