Knabbiii ♡ ˚₊‧⁺˖
Knabbiii ♡ ˚₊‧⁺˖
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 8/29/2023 in #djs-questions
Timeout Error
i did that, seems like the error is gone, but now i got the new one, like i said
11 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 8/29/2023 in #djs-questions
Timeout Error
and the user is not above me
11 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 8/29/2023 in #djs-questions
Timeout Error
thank you, now i get the error from:
if (!timeMember.kickable) return await interaction.reply
if (!timeMember.kickable) return await interaction.reply
11 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 8/29/2023 in #djs-questions
Timeout Error
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions, MessageActionRow, MessageButton, PermissionFlagsBits, PermissionsBitField } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('timeout')
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers)
.setDescription('Timeoute einen User.')
.addUserOption(option =>
option.setName('user')
.setDescription('User, der getimeoutet wird.')
.setRequired(true))
.addStringOption(option =>
option.setName('duration')
.setDescription('Dauer des Timeoutes (z.B. 30m, 2h, 3d)')
.setRequired(true))
.addStringOption(option =>
option.setName('reason')
.setDescription('Grund des Timeoutes.')
.setRequired(false))
.addAttachmentOption(option =>
option.setName('proof')
.setDescription('Beweisbild (Screenshot) hinzufügen.')
.setRequired(false))
.addBooleanOption(option =>
option.setName('dm')
.setDescription('User wird per dm benachrichtigt.')
.setRequired(false)),

async execute(interaction, client) {
const durationInput = interaction.options.getString('duration');
const reason = interaction.options.getString('reason') || 'Kein Grund angegeben.';
const dm = interaction.options.getBoolean('dm');
const timeUser = interaction.options.getUser('user');
const timeMember = interaction.guild.members.fetch(timeUser.id);
const proof = interaction.options.getAttachment('proof');

// Duration
function calculateDurationInMinutes(input) {
const regex = /(\d+)([mhd])/;
const match = input.match(regex);

if (!match) return null;

const value = parseInt(match[1]);
const unit = match[2];

switch (unit) {
case 'm':
return value;
case 'h':
return value * 60;
case 'd':
return value * 60 * 24;
default:
return null;
}
}

const durationInMinutes = calculateDurationInMinutes(durationInput);

if (!durationInMinutes) {
await interaction.reply('Ungültiges Format für die Dauer. Verwende z.B. "30m" für Minuten, "2h" für Stunden oder "3d" für Tage.');
return;
}

// Logical Statements
if (!interaction.member.permissions.has(PermissionsBitField.Flags.ModerateMembers)) return await interaction.reply({ content: `Du brauchst die "Moderate Member" Permission um zu timeouten.`, ephermeral: true })
if (!timeMember) return await interaction.reply({ content: `Der User ist nicht auf dem Server`, ephermeral: true });
if (!timeMember.kickable) return await interaction.reply({ content: `Ich kann diesen User nicht timeouten. Das kann daran liegen, dass der User oder die Rolle des Users über meiner ist.`, ephermeral: true });
if (interaction.member.id === timeMember.id) return await interaction.reply({ content: 'Du kannst dich nicht selbst timeouten!', ephermeral: true });
if (timeMember.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: `Du kannst keinen User mit Administrator Rechten timeouten!`, ephermeral: true })

// Timeout member
await timeMember.timeout(durationInMinutes * 60 * 1000, reason)

await interaction.reply('Timeout done.')

}
}
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions, MessageActionRow, MessageButton, PermissionFlagsBits, PermissionsBitField } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('timeout')
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers)
.setDescription('Timeoute einen User.')
.addUserOption(option =>
option.setName('user')
.setDescription('User, der getimeoutet wird.')
.setRequired(true))
.addStringOption(option =>
option.setName('duration')
.setDescription('Dauer des Timeoutes (z.B. 30m, 2h, 3d)')
.setRequired(true))
.addStringOption(option =>
option.setName('reason')
.setDescription('Grund des Timeoutes.')
.setRequired(false))
.addAttachmentOption(option =>
option.setName('proof')
.setDescription('Beweisbild (Screenshot) hinzufügen.')
.setRequired(false))
.addBooleanOption(option =>
option.setName('dm')
.setDescription('User wird per dm benachrichtigt.')
.setRequired(false)),

async execute(interaction, client) {
const durationInput = interaction.options.getString('duration');
const reason = interaction.options.getString('reason') || 'Kein Grund angegeben.';
const dm = interaction.options.getBoolean('dm');
const timeUser = interaction.options.getUser('user');
const timeMember = interaction.guild.members.fetch(timeUser.id);
const proof = interaction.options.getAttachment('proof');

// Duration
function calculateDurationInMinutes(input) {
const regex = /(\d+)([mhd])/;
const match = input.match(regex);

if (!match) return null;

const value = parseInt(match[1]);
const unit = match[2];

switch (unit) {
case 'm':
return value;
case 'h':
return value * 60;
case 'd':
return value * 60 * 24;
default:
return null;
}
}

const durationInMinutes = calculateDurationInMinutes(durationInput);

if (!durationInMinutes) {
await interaction.reply('Ungültiges Format für die Dauer. Verwende z.B. "30m" für Minuten, "2h" für Stunden oder "3d" für Tage.');
return;
}

// Logical Statements
if (!interaction.member.permissions.has(PermissionsBitField.Flags.ModerateMembers)) return await interaction.reply({ content: `Du brauchst die "Moderate Member" Permission um zu timeouten.`, ephermeral: true })
if (!timeMember) return await interaction.reply({ content: `Der User ist nicht auf dem Server`, ephermeral: true });
if (!timeMember.kickable) return await interaction.reply({ content: `Ich kann diesen User nicht timeouten. Das kann daran liegen, dass der User oder die Rolle des Users über meiner ist.`, ephermeral: true });
if (interaction.member.id === timeMember.id) return await interaction.reply({ content: 'Du kannst dich nicht selbst timeouten!', ephermeral: true });
if (timeMember.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: `Du kannst keinen User mit Administrator Rechten timeouten!`, ephermeral: true })

// Timeout member
await timeMember.timeout(durationInMinutes * 60 * 1000, reason)

await interaction.reply('Timeout done.')

}
}
11 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/10/2022 in #djs-questions
memberCount filter only Users
Yea you're probably right hahaa
2 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
Dont tell me non stop that i dont know javascript basic. This isnt helping a beginner at all
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
I just started blindly like many other programmers did
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
i think with those answers, i just get to know what i know so or so
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
do i even need it
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
nice
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
tell me
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
i forgot it
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
truly
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
bro idk
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
sry i mean ":"
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
so i delete the options const and just write in after the ":"?
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
Can you help me fix it then?
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
You have a fix?
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
take text from options
41 replies
DIAdiscord.js - Imagine an app
Created by Knabbiii ♡ ˚₊‧⁺˖ on 10/7/2022 in #djs-questions
membercount as activity precence
const memberCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)
const options =
{
type: ActivityType.Playing,
text: `mit ${memberCount} usern`,
status: "online"
}
await client.user.setPresence({
activities: {
name: [options].text,
type: [options].type
},
status: [options].status
})
const memberCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)
const options =
{
type: ActivityType.Playing,
text: `mit ${memberCount} usern`,
status: "online"
}
await client.user.setPresence({
activities: {
name: [options].text,
type: [options].type
},
status: [options].status
})
No error anymore... but no activiety still
41 replies