#Trying to read a message from DMs
7 messages · Page 1 of 1 (latest)
require('dotenv').config(); //initialize dotenv
const { Client, GatewayIntentBits, GuildChannelManager, ChannelType, Partials } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.DirectMessages], partials: [Partials.Message, Partials.Channel] });
const mcutil = require('minecraft-server-util');
const options = {
timeout: 1000 * 5, // timeout in milliseconds
enableSRV: true // SRV record lookup
};
function updatePresence() {
mcutil.status('play.aresuk.net', 25565, options)
.then((result) => {
client.user.setPresence({ activities: [{ name: result.players.online+'/'+result.players.max }], status: 'online' });
})
.catch((error) => {
console.error(error);
});
}
const randomStrings = ['&online&','Stellar is upgrading me!', 'Slimepain...', 'Cosmia best nation! (Not biased)','Shaking and crying','Litrally me','INTERLINKED','STOP! join the server :)','am I alive?'];
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
const randomString = randomStrings[Math.floor(Math.random() * randomStrings.length)];
if (randomString == '&online&') {
updatePresence();
} else {
client.user.setPresence({ activities: [{ name: randomString }], status: 'online' });
}
setInterval(() => {
const randomString = randomStrings[Math.floor(Math.random() * randomStrings.length)];
if (randomString == '&online&') {
updatePresence();
} else {
client.user.setPresence({ activities: [{ name: randomString }], status: 'online' });
}
}, 60000);
});
let tempvctable = [];
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'createvc') {
let maxLimit = interaction.options.getInteger('maxlimit');
if (maxLimit <= 0) {
maxLimit = 10;
} else if (maxLimit > 10) {
maxLimit = 10;
}
const channel = await interaction.guild.channels.create({
name: `${interaction.user.username.replace(/ /g, "-")}'s-VC`,
type: ChannelType.GuildVoice,
parent: '1096931422767427596',
userLimit: maxLimit,
});
tempvctable.push({userID: interaction.user.id, voiceChannelID: channel.id});
console.log(tempvctable);
await interaction.reply('Voice channel created!');
setTimeout(() => {
console.log(channel.members.size);
if (channel.members.size === 0) {
channel.delete();
interaction.channel.send('Voice channel deleted as you did not join within 30 seconds.');
}
}, 30000);
}
});
client.on('message', message => {
if (message.channel.type === 1) {
console.log(`[${message.author.tag}]: ${message.content}`);
}
});
/*
client.on('messageCreate', async message => {
console.log(message.content);
if (message.channel.type === 1) {
const chatgpt = await import('discord-chat-gpt');
const response = await chatgpt.getResponse(message.content);
message.channel.send(response);
}
});
*/
client.login(process.env.TOKEN);
messageCreate
[email protected] D:\stellarx.dev\aresuk_discordbot v16.13.0
ChannelType.DM is better than using 1 btw