Skip to content

Commit

Permalink
:D
Browse files Browse the repository at this point in the history
  • Loading branch information
Vendicated committed May 8, 2021
1 parent 0509d2d commit feda2a3
Showing 1 changed file with 35 additions and 49 deletions.
84 changes: 35 additions & 49 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,42 @@
/* eslint-disable indent */
const { Plugin } = require('powercord/entities');
const { inject, uninject } = require('powercord/injector');
const { findInReactTree } = require('powercord/util');
const { getModule } = require('powercord/webpack');
const { Plugin } = require("powercord/entities");
const { inject, uninject } = require("powercord/injector");
const { getModule, React } = require("powercord/webpack");

function getRandomUserID () {
const Members = getModule([ 'getMemberIds' ], false)
.getMemberIds(getModule([ 'getLastSelectedGuildId' ], false)
.getLastSelectedGuildId());
return Members[Math.floor(Math.random() * Members.length)];
}
const {
AUTOCOMPLETE_OPTIONS: { MENTIONS }
} = getModule(["AUTOCOMPLETE_OPTIONS"], false);

const Someone = require("./Someone");

module.exports = class atSomeone extends Plugin {
async startPlugin () {
this._injectAutoComplete();
powercord.api.commands.registerCommand({
command: '@/Someone',
aliases: [ '@s' ],
description: 'Ats Someone',
usage: '',
async executor () {
return {
send: true,
result: `<@${getRandomUserID()}>`
};
}
});
}
async startPlugin() {
this._injectAutoComplete();
powercord.api.commands.registerCommand({
command: "@/Someone",
aliases: ["@s"],
description: "Ats Someone",
usage: "",
async executor() {
return {
send: true,
result: `<@${getRandomUserID()}>`
};
}
});
}

_injectAutoComplete() {
inject("as-mention-container", MENTIONS, "renderResults", (args, res) => {
if (!"someone".includes(args[1].toLowerCase())) return res;

async _injectAutoComplete () {
const { AUTOCOMPLETE_OPTIONS: { MENTIONS } } = getModule([ 'AUTOCOMPLETE_OPTIONS' ], false);
inject('as-mention-container', MENTIONS, 'renderResults', (args, res) => {
if (args[7].globals.length === 2 || args[7].globals.length === 0) {
args[7].globals.push({
description: 'Mentions Someone!',
text: '@someone'
});
}
try {
const sex = findInReactTree(res, ({ key }) => key === '@someone');
sex.props.onClick = () => {
const currentChannel = require('powercord/webpack').channels.getChannelId();
require('powercord/webpack').getModule([ 'sendMessage' ], false)
.sendMessage(currentChannel, { content: '<@' + getRandomUserID() + '>' });
};
} catch {}
return res;
});
}
res.props.children[3]?.unshift(React.createElement(Someone));
return res;
});
}

pluginWillUnload () {
powercord.api.commands.unregisterCommand('@/Someone');
uninject('as-mention-container');
}
pluginWillUnload() {
powercord.api.commands.unregisterCommand("@/Someone");
uninject("as-mention-container");
}
};

0 comments on commit feda2a3

Please sign in to comment.