You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{ICommand}from'wokcommands';import{MessageEmbed}from'discord.js';importwarnSchemafrom'../../models/warn-schema';exportdefault{category: 'Moderation',description: 'Warns a user',permissions: ['ADMINISTRATOR'],requireRoles: true,slash: true,//Lagacy command and slash commandtestOnly: true,//False to turn off test onlyguildOnly: true,options: [{type: 'SUB_COMMAND',name: 'add',description: 'Adds a warning to a user',options: [{name: 'user',type: 'USER',description: 'The user to add a warn to',required: true,},{name: 'reason',type: 'STRING',description: 'The reason for the warning',required: true,},],},{type: 'SUB_COMMAND',name: 'remove',description: 'Removes a warning from a user',options: [{name: 'user',type: 'USER',description: 'The user to remove a warn from',required: true,},{name: 'id',type: 'STRING',description: 'The id of the warning to remove',required: true,},],},{type: 'SUB_COMMAND',name: 'list',description: 'Lists all warnings for a user',options: [{name: 'user',type: 'USER',description: 'The user to list warnings for',required: true,},],},],callback: async({ guild,member: staff, interaction })=>{constsubCommand=interaction.options.getSubcommand();constuser=interaction.options.getUser('user');constreason=interaction.options.getString('reason');constid=interaction.options.getString('id');console.log('comando escolhido: ',{ subCommand, user });if(subCommand==='add'){constwarning=awaitwarnSchema.create({userId: user?.id,guildId: guild?.id,staffId: staff.id,
reason,});console.log('o que aconteceu com o attempt: ',warning);return{custom: true,content: `Added warning ${warning.id} to <@${user?.tag}>`,allowedMentions: {users: [],},};}elseif(subCommand==='remove'){awaitwarnSchema.findByIdAndDelete(id);return{custom: true,content: `Removed warning ${id} from <@${user?.id}>`,allowedMentions: {users: [],},};}elseif(subCommand==='list'){constwarnings=awaitwarnSchema.find({userId: user?.id,guildId: guild?.id,});letdescription=`Warnings for: <@${user?.id}>\n\n`;for(constwarningofwarnings){description+=`**ID:** ${warning._id}\n`;description+=`**Date:** ${warning.createdAt.toLocaleString()}\n`;//.toUTCStringdescription+=`**Staff:** <@${warning.staffId}>\n`;description+=`**Reason:** ${warning.reason}\n\n`;}constembed=newMessageEmbed().setDescription(description);returnembed;}},}asICommand;
But when try to create new schema in the Mongo using the /warn command it throws the following error:
I had tried some the follows comments on the internet:
Hellos guys, sorry in advance if this is no issue.
The scenarios is using the follow:
"axios": "^0.25.0", "discord.js": "^13.6.0", "dotenv": "^14.2.0", "mongoose": "^6.1.8", "wokcommands": "^1.5.3"
"@types/node": "^17.0.10", "rimraf": "^3.0.2", "typescript": "^4.5.5"
I followed the video How to connect your Discord bot to a MongoDB Database - Discord.JS v13.
It`s look like is everything good with the connection and the default collections were made:
index.ts
Running bash:
warn-schema.ts
Defaults Collections on Atlas:
But the new schema
warn-schema
that i created weren't made i noticed that after i made the follow video Discord.JS v13 - Warn System with Slash Commands (Add, Remove, List), because i was very confident that everything would work properly because it all quite simple.warn.ts
But when try to create new schema in the Mongo using the
/warn
command it throws the following error:I had tried some the follows comments on the internet:
GitHub Issue 9732
Stackoverflow
Its look like is something new, i found this comments in the mongo official community:
mongooseerror-operation-users-insertone-buffering-timed-out-after-10000ms
If anyone helps me would be very appreciated, i'll keep eye in the oficial mongo community if get something and let you know.
If this is no issue please let me know then i erase the thread.
Thank you!
The text was updated successfully, but these errors were encountered: