Ggahramaq
DIAdiscord.js - Imagine an app
•Created by Ggahramaq on 12/10/2023 in #djs-questions
ExpectedConstraintError > s.string.regex
code:
const reactions = require('./src/Schemas/reactionrolesSchema');
client.on(Events.MessageReactionAdd, async (reaction, user) => {
if (!reaction.message.guildId) return;
if (user.bot) return;
let cID = `<${reaction.emoji.name}:${reaction.emoji.id}>`;
if (!reaction.emoji.id) cID = reaction.emoji.name;
const data = await reactions.findOne({ Guild: ireaction.message.guildId, Message: reaction.message.id, Emoji: cID});
if (!data) return;
const guild = await client.guild.cache.get(reaction.message.guildId);
const member = await guild.members.cache.get(user.id);
try {
await member.roles.add(data.Role);
} catch (e) {
return;
}
})
client.on(Events.MessageReactionRemove, async (reaction, user) => {
if (!reaction.message.guildId) return;
if (user.bot) return;
let cID = `<${reaction.emoji.name}:${reaction.emoji.id}>`;
if (!reaction.emoji.id) cID = reaction.emoji.name;
const data = await reactions.findOne({ Guild: ireaction.message.guildId, Message: reaction.message.id, Emoji: cID});
if (!data) return;
const guild = await client.guild.cache.get(reaction.message.guildId);
const member = await guild.members.cache.get(user.id);
try {
await member.roles.remove(data.Role);
} catch (e) {
return;
}
})
const reactions = require('./src/Schemas/reactionrolesSchema');
client.on(Events.MessageReactionAdd, async (reaction, user) => {
if (!reaction.message.guildId) return;
if (user.bot) return;
let cID = `<${reaction.emoji.name}:${reaction.emoji.id}>`;
if (!reaction.emoji.id) cID = reaction.emoji.name;
const data = await reactions.findOne({ Guild: ireaction.message.guildId, Message: reaction.message.id, Emoji: cID});
if (!data) return;
const guild = await client.guild.cache.get(reaction.message.guildId);
const member = await guild.members.cache.get(user.id);
try {
await member.roles.add(data.Role);
} catch (e) {
return;
}
})
client.on(Events.MessageReactionRemove, async (reaction, user) => {
if (!reaction.message.guildId) return;
if (user.bot) return;
let cID = `<${reaction.emoji.name}:${reaction.emoji.id}>`;
if (!reaction.emoji.id) cID = reaction.emoji.name;
const data = await reactions.findOne({ Guild: ireaction.message.guildId, Message: reaction.message.id, Emoji: cID});
if (!data) return;
const guild = await client.guild.cache.get(reaction.message.guildId);
const member = await guild.members.cache.get(user.id);
try {
await member.roles.remove(data.Role);
} catch (e) {
return;
}
})
9 replies
DIAdiscord.js - Imagine an app
•Created by Ggahramaq on 12/8/2023 in #djs-questions
bot not answering
i created command !membercount and when I enter the command, the bot does not display the membercount
Theres no error
code:
const { Client, GatewayIntentBits, ActivityType } = require("discord.js");
const prefix = "!";
const client = new Client({
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true,
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
],
});
client.on("message", message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
//
const messageArray = message.content.split("");
const argument = messageArray.slice(1)
const cmd = messageArray[0];
//
if (cmd === `${prefix}membercount`){
message.channel.send(`**membercount:** ${message.guild.memberCount}`)
}
})
const { Client, GatewayIntentBits, ActivityType } = require("discord.js");
const prefix = "!";
const client = new Client({
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true,
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
],
});
client.on("message", message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
//
const messageArray = message.content.split("");
const argument = messageArray.slice(1)
const cmd = messageArray[0];
//
if (cmd === `${prefix}membercount`){
message.channel.send(`**membercount:** ${message.guild.memberCount}`)
}
})
17 replies