pingu
pingu
DIAdiscord.js - Imagine an app
Created by pingu on 4/16/2024 in #djs-questions
Working collaboratively on discord bot
Kinda a general question, but how do I let other people contribute to and run my discord bot? I'm in a group project ^^
7 replies
DIAdiscord.js - Imagine an app
Created by pingu on 4/15/2024 in #djs-questions
Trying to get user input for a Wordle game (interaction.channel is null)
Hi, I'm trying to create a slashcommand which takes in user input as guesses and compares it against a random word. I'm getting a TypeError though when running the code (below), which I feel I've narrowed down to interaction.channel being null itself. How do I fix this? here's the error: TypeError: Cannot read properties of null (reading 'createMessageCollector') and here's the code: `` const { SlashCommandBuilder } = require('discord.js'); // const fs = require('node:fs'); const { OpenAI } = require('openai'); module.exports = { data: new SlashCommandBuilder() .setName('startwordle') .setDescription('starts a game of wordle~'), async execute(interaction) { // const dictionary = fs.readFileSync('dictionary.txt', 'utf-8').split('\n').filter(word => word.length === 5).map(word => word.toLowerCase()); await interaction.reply({ content: Hi, ${interaction.user}. Starting a game of Wordle., ephemeral: true }); // const randomWord = await dictionary[Math.floor(Math.random() * dictionary.length)]; // const randomWord = await getRandom5LetterWordFromChatgpt(); const randomWord = 'SILLY'; let numGuesses = 3; await interaction.followUp({ content: randomWord, ephemeral: true }); const gameStatus = true; while (numGuesses > 0 && gameStatus == true) { const collectorFilter = m => m.content.includes('discord'); const collector = interaction.channel.createMessageCollector({ filter: collectorFilter, time: 15_000 }); collector.on('collect', m => { console.log(Collected ${m.content}); }); collector.on('end', collected => { console.log(Collected ${collected.size} items`); }); numGuesses--; } }, };
17 replies