lor3512
lor3512
DIAdiscord.js - Imagine an app
Created by lor3512 on 4/7/2024 in #djs-questions
I cannout untimeout a user
const { MongoClient, ObjectId } = require('mongodb');
const findCase = require('./findcase.js')

// Connection URI
const uri = process.env.MONGO_URI;

// Create a new MongoClient
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });

async function closeCase(caseId, caseType, instance) {
const foundCase = await findCase(caseId, caseType)

if (foundCase == null) {
return "CASENOTFOUND";
}
if (foundCase.closed) {
return "ALREADYCLOSED";
}

// Select the database and collection
const database = client.db('cases');
const collection = database.collection(caseType);

if (caseType == "mute") {
const guild = instance._client.guilds.cache.get(foundCase.guildId);
const userid = foundCase.user
const targetMember = guild.members.cache.get(userid)

console.log(guild.members)

targetMember.timeout(1)
}

const updatedCase = await collection.findOneAndUpdate(
{ _id: new ObjectId(caseId) },
{ $set: { closed: true, beingReviewed: false} },
{ returnOriginal: false } // Return the updated document
);

return "DONE";
}

// Export the findCaseById function to use it in other modules
module.exports = closeCase;
const { MongoClient, ObjectId } = require('mongodb');
const findCase = require('./findcase.js')

// Connection URI
const uri = process.env.MONGO_URI;

// Create a new MongoClient
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });

async function closeCase(caseId, caseType, instance) {
const foundCase = await findCase(caseId, caseType)

if (foundCase == null) {
return "CASENOTFOUND";
}
if (foundCase.closed) {
return "ALREADYCLOSED";
}

// Select the database and collection
const database = client.db('cases');
const collection = database.collection(caseType);

if (caseType == "mute") {
const guild = instance._client.guilds.cache.get(foundCase.guildId);
const userid = foundCase.user
const targetMember = guild.members.cache.get(userid)

console.log(guild.members)

targetMember.timeout(1)
}

const updatedCase = await collection.findOneAndUpdate(
{ _id: new ObjectId(caseId) },
{ $set: { closed: true, beingReviewed: false} },
{ returnOriginal: false } // Return the updated document
);

return "DONE";
}

// Export the findCaseById function to use it in other modules
module.exports = closeCase;
19 replies
DIAdiscord.js - Imagine an app
Created by lor3512 on 4/6/2024 in #djs-questions
I cant put emojis in buttons.
const appealEmbed = new EmbedBuilder() .setTitle("Appeal A Moderator Action") .setDescription("If you received a warning, mute, or ban and wish to appeal, use the buttons below based on your punishment.") .addFields( { name: "⚠️ Warn Appeals", value: "Appeal if you received a warning." }, { name: "🔇 Mute Appeals", value: "Appeal if you were muted." }, { name: "❌ Ban Appeals", value: "Appeal if you were banned." } ); const warnButton = new ButtonBuilder() .setCustomId("warnappeal") .setLabel("Warn Appeals") .setStyle(ButtonStyle.Secondary) const muteButton = new ButtonBuilder() .setCustomId("muteappeal") .setLabel("Mute Appeals") .setStyle(ButtonStyle.Secondary) const banButton = new ButtonBuilder() .setCustomId("banappeal") .setLabel("Ban Appeals") .setStyle(ButtonStyle.Secondary) const row = new ActionRowBuilder() .addComponents(warnButton, muteButton, banButton); Will not work with the following error:
70 replies