Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Client, IntentsBitField, ActivityType} = require('discord.js');
- const fs = require('fs');
- const cron = require('node-cron');
- const fact = require('./commands/fact');
- const wikipedia = require('../commands/wikipedia');
- const search = require('../commands/googleSearch');
- const imageSearch = require('../commands/googleImageSearch')
- const quiz = require('../commands/quiz')
- const client = new Client({
- intents: [
- IntentsBitField.Flags.Guilds,
- IntentsBitField.Flags.GuildMembers,
- IntentsBitField.Flags.GuildMessages,
- IntentsBitField.Flags.MessageContent,
- IntentsBitField.Flags.GuildPresences,
- ],
- });
- client.on('ready', () => {
- console.log(`Logged in as ${client.user.tag}!`);
- client.user.setActivity("the battlefield", { type: ActivityType.Watching })
- client.user.setStatus("dnd")
- });
- // Get the command
- client.on('interactionCreate', async (interaction) => {
- if (!interaction.isChatInputCommand()) return;
- // Fact
- if (interaction.commandName === 'fact') {
- fact(interaction);
- }
- // Wikipedia
- if (interaction.commandName === 'fact') {
- wikipedia(interaction);
- }
- // Google search
- if (interaction.commandName === 'search') {
- search(interaction);
- }
- // Google image search
- if (interaction.commandName === 'image-search') {
- imageSearch(interaction);
- }
- //Quiz
- if (interaction.commandName === 'ww2-quiz') {
- quiz(interaction);
- }
- })
- cron.schedule('57 19 * * *', () => {
- try {
- const facts = JSON.parse(fs.readFileSync('facts.json', 'utf8'));
- console.log(facts);
- const randomFact = facts[Math.floor(Math.random() * facts.length)];
- const channel = client.channels.cache.get('1094015791713759372');
- channel.send(randomFact);
- } catch (error) {
- console.error(`${error}`);
- }
- });
- client.login("");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement