From 2f8c23eb6bddd77cfcbf71300c8af5998bd2e1ba Mon Sep 17 00:00:00 2001 From: Emily J Date: Sat, 10 Oct 2020 19:36:58 +1100 Subject: [PATCH] ported from v1 --- bot/commands/Test/msearch.js | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 bot/commands/Test/msearch.js diff --git a/bot/commands/Test/msearch.js b/bot/commands/Test/msearch.js new file mode 100644 index 0000000..bb22037 --- /dev/null +++ b/bot/commands/Test/msearch.js @@ -0,0 +1,41 @@ +const Command = require("../../base/Command.js"); + +class Msearch extends Command { + constructor (client) { + super(client, { + description: "Lists all members found that match the input", + usage: "`msearch` [query] - Finds users in this server that match the query.`", + aliases: ['membersearch'] + }); + } + + async run (message, args, data) { // eslint-disable-line no-unused-vars + if (!args[0]) + return message.channel.send( + `No username provided.` + ); + + var mlist = ""; + var count = 0; + + this.client.functions.searchForMembers(message.guild, args[0]).forEach((member) => { + if (member) { + mlist += `\`${member.user.tag}\``; + count = count + 1; + } + mlist += "**, **"; + }); + + mlist = mlist.substring(0, mlist.length - 6); + + var mlist1 = `Found ${count} users:\n` + mlist; + + if (!mlist1) { + return message.channel.send("No users found!"); + }; + + message.channel.send(mlist1); + } +} + +module.exports = Msearch;