Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeseller.js #12

Open
UnoIsSugar1 opened this issue Jan 31, 2022 · 2 comments
Open

removeseller.js #12

UnoIsSugar1 opened this issue Jan 31, 2022 · 2 comments

Comments

@UnoIsSugar1
Copy link

UnoIsSugar1 commented Jan 31, 2022

/home/runner/ShopKeeper/commands/shop/removeseller.js:12
let seller = message.mentions.first.id
^

TypeError: Cannot read properties of undefined (reading 'id')
at Object.run (/home/runner/ShopKeeper/commands/shop/removeseller.js:12:45)
at Client. (/home/runner/ShopKeeper/index.js:55:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

@UnoIsSugar1
Copy link
Author

Instead of using

const { MessageEmbed } = require('discord.js')
const Seller = require('../../models/seller')
const embedColor = require('../../config.json').embedColor
module.exports = {
name: "removeseller",
category: "moderation",
category: "shop",
description: "Remove a users verified seller status so they cant create products",
usage: "[userID | reason]",
run: async (client, message, args) => {
if (!message.member.hasPermission('ADMINISTRATOR')) return;
let seller = message.mentions.first.id
let reason = args[1]
if (!seller) return message.channel.send(new MessageEmbed().setDescription('Please provide a user ID').setColor(embedColor.error))
try {
await client.users.fetch(seller)
} catch {
return message.channel.send(new MessageEmbed().setDescription('The user ID you provided is invalid').setColor(embedColor.error))
}
let sellerFinder = await Seller.findOne({ sellerID: seller })
if (!sellerFinder) return message.channel.send(new MessageEmbed().setDescription('This user is not a verified seller').setColor(embedColor.error))
await Seller.deleteOne({ sellerID: seller })
let foundSeller = await client.users.fetch(seller)
if (reason) try { await foundSeller.send(new MessageEmbed().setDescription('You are no longer a verified seller').setColor(embedColor.success)) } catch {}
message.channel.send(seller + ' is no longer a verified seller')
}
}

you should be using

const { MessageEmbed } = require('discord.js')
const Seller = require('../../models/seller')
const embedColor = require('../../config.json').embedColor
module.exports = {
name: "removeseller",
category: "moderation",
category: "shop",
description: "Remove a users verified seller status so they cant create products",
usage: "[userID | reason]",
run: async (client, message, args) => {
if (!message.member.hasPermission('ADMINISTRATOR')) return;
let seller = args[0]
let reason = args[1]
if (!seller) return message.channel.send(new MessageEmbed().setDescription('Please provide a user ID').setColor(embedColor.error))
try {
await client.users.fetch(seller)
} catch {
return message.channel.send(new MessageEmbed().setDescription('The user ID you provided is invalid').setColor(embedColor.error))
}
let sellerFinder = await Seller.findOne({ sellerID: seller })
if (!sellerFinder) return message.channel.send(new MessageEmbed().setDescription('This user is not a verified seller').setColor(embedColor.error))
await Seller.deleteOne({ sellerID: seller })
let foundSeller = await client.users.fetch(seller)
if (reason) try { await foundSeller.send(new MessageEmbed().setDescription('You are no longer a verified seller').setColor(embedColor.success)) } catch {}
message.channel.send(seller + ' is no longer a verified seller')
}
}

@Jaxenormus
Copy link
Owner

You can make a pull request with this change, and I'll merge the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants