Skip to content

Commit

Permalink
rename project to powercord
Browse files Browse the repository at this point in the history
  • Loading branch information
aetheryx committed Dec 7, 2018
1 parent b16e9ea commit 9c64db3
Show file tree
Hide file tree
Showing 58 changed files with 223 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"globals": {
"aethcord": true,
"powercord": true,
"webpackJsonp": true
},
"parserOptions": {
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.idea
node_modules

src/Aethcord/plugins/stylemanager/styles/*
!src/Aethcord/plugins/stylemanager/styles/ac-*.css
!src/Aethcord/plugins/stylemanager/styles/ac-*.scss
src/Powercord/plugins/stylemanager/styles/*
!src/Powercord/plugins/stylemanager/styles/ac-*.css
!src/Powercord/plugins/stylemanager/styles/ac-*.scss

config.json
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Aethcord
Aethcord is a lightweight client mod focused on simplicity and performance.
As of right now, Aethcord is in *very* early stages of development, so feel free to join [this server](https://discord.gg/Yphr6WG) for any questions.
# Powercord
Powercord is a lightweight client mod focused on simplicity and performance.
As of right now, Powercord is in *very* early stages of development, so feel free to join [this server](https://discord.gg/Yphr6WG) for any questions.

# Features
## Spotify Modal
Expand All @@ -18,10 +18,10 @@ You can see an image preview of the codeblocks [here](https://discord.coffee/cf1
3. Windows or Linux (I don't have a macOS machine)

# Installation steps
1. `git clone https://github.com/Aetheryx/aethcord`
2. `cd aethcord`
1. `git clone https://github.com/aetheryx/powercord`
2. `cd powercord`
3. `npm i`
4. `npm run inject` <sup>(Side note: if you're on Linux, you need root perms for this command)</sup>
5. Completely kill your Discord Client (right click system tray icon -> Quit DiscordCanary)
6. Start Discord back up and Aethcord should be injected!
Make sure to view the [Aethcord Wiki](https://github.com/Aetheryx/aethcord/wiki) for information on getting started and how Aethcord works.
6. Start Discord back up and Powercord should be injected!
Make sure to view the [Powercord Wiki](https://github.com/aetheryx/powercord/wiki) for information on getting started and how Powercord works.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"name": "aethcord",
"name": "powercord",
"version": "1.0.0",
"description": "",
"description": "A lightweight @discordapp client mod focused on simplicity and performance",
"main": "index.js",
"scripts": {
"inject": "node injectors/index.js inject",
"uninject": "node injectors/index.js uninject"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aetheryx/aethcord.git"
"url": "git+https://github.com/aetheryx/powercord.git"
},
"keywords": [],
"author": "Aetheryx",
"license": "MIT",
"bugs": {
"url": "https://github.com/aetheryx/aethcord/issues"
"url": "https://github.com/aetheryx/powercord/issues"
},
"homepage": "https://github.com/aetheryx/aethcord#readme",
"homepage": "https://github.com/aetheryx/powercord#readme",
"dependencies": {
"buble": "^0.19.6",
"chokidar": "^2.0.4",
Expand Down
2 changes: 1 addition & 1 deletion src/Aethcord/index.js → src/Powercord/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = class Aethcord {
module.exports = class Powercord {
constructor (config) {
this.config = config;
this.plugins = require('./plugins');
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Plugin = require('ac/Plugin');
const Plugin = require('powercord/Plugin');

module.exports = class StateWatcher extends Plugin {
constructor () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Plugin = require('ac/Plugin');
const { createElement } = require('ac/util');
const Plugin = require('powercord/Plugin');
const { createElement } = require('powercord/util');
const { clipboard } = require('electron');

module.exports = class Codeblocks extends Plugin {
Expand All @@ -11,14 +11,17 @@ module.exports = class Codeblocks extends Plugin {
}

start () {
aethcord
powercord
.plugins
.get('StateWatcher')
.on('codeblock', this.inject);
}

inject (codeblock) {
if (codeblock.querySelector('.aethcord-codeblock-copy-btn') || codeblock.closest('.search-result-message')) {
if (
codeblock.querySelector('.powercord-codeblock-copy-btn') ||
codeblock.closest('.search-result-message')
) {
return;
}

Expand All @@ -33,15 +36,15 @@ module.exports = class Codeblocks extends Plugin {
if (lang.length !== 0) {
codeblock.appendChild(
createElement('div', {
className: 'aethcord-codeblock-lang',
className: 'powercord-codeblock-lang',
innerHTML: lang[0]
})
);
}

codeblock.appendChild(
createElement('button', {
className: 'aethcord-codeblock-copy-btn',
className: 'powercord-codeblock-copy-btn',
innerHTML: 'copy',
onclick: (e) => {
if (e.target.classList.contains('copied')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Plugin = require('ac/Plugin');
const Plugin = require('powercord/Plugin');

const commands = require('./commands');

Expand All @@ -13,7 +13,7 @@ module.exports = class Commands extends Plugin {
}

async start () {
this.prefix = aethcord.config.prefix || '.';
this.prefix = powercord.config.prefix || '.';

const monkeypatchMessages = require('./monkeypatchMessages.js');
const injectAutocomplete = require('./injectAutocomplete.js');
Expand Down
89 changes: 89 additions & 0 deletions src/Powercord/plugins/commands/injectAutocomplete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const { waitFor, getOwnerInstance } = require('powercord/util');
const { sleep } = require('powercord/util');

module.exports = async function injectAutocomplete () {
const _this = this;

const plugins = [ ...powercord.plugins.keys() ];
while (!plugins.every(plugin =>
powercord.plugins.get(plugin).ready
)) {
await sleep(1);
}

const customCommands = [ ...this.commands.values() ]
.map(command => ({
command: command.name,
description: command.description
}));

const inject = (inst) =>
inst.props.autocompleteOptions.POWERCORD_CUSTOM_COMMANDS = {
getText: (index, { commands }) => this.prefix + commands[index].command,
matches: (_, content) => content && content[0] === this.prefix,
queryResults: (content) => ({
commands: customCommands.filter(c => c.command.startsWith(content))
}),
renderResults: (...args) => {
const renderedResults = inst.props.autocompleteOptions.COMMAND.renderResults(...args);
if (!renderedResults) {
return;
}

let [ header, commands ] = renderedResults;

header.type = class PatchedHeaderType extends header.type {
renderContent (...args) {
const rendered = super.renderContent(...args);

if (
Array.isArray(rendered.props.children) &&
rendered.props.children[1]
) {
const commandPreviewChildren = rendered.props.children[1].props.children;
if (commandPreviewChildren[0].startsWith('/')) {
commandPreviewChildren[0] = commandPreviewChildren[0].replace('/', _this.prefix);
}
}

return rendered;
}
};

for (const command of commands) {
command.type = class PatchedCommandType extends command.type {
renderContent (...args) {
const rendered = super.renderContent(...args);

const children = rendered.props.children;
if (children[0].props.name === 'Slash') {
rendered.props.children.shift();
}

const commandName = children[0].props;
if (!commandName.children.startsWith(_this.prefix)) {
commandName.children = _this.prefix + commandName.children;
}

return rendered;
}
}
}

return [ header, commands ];
}
};

await waitFor('.channelTextArea-rNsIhG');

const getInstance = () => getOwnerInstance(document.querySelector('.channelTextArea-rNsIhG'));
const instance = getInstance();
const instancePrototype = Object.getPrototypeOf(instance);

instancePrototype.componentDidMount = (_componentDidMount => function (...args) {
inject(getInstance());
return _componentDidMount.call(this, ...args);;
})(instancePrototype.componentDidMount);

inject(instance);
};
41 changes: 41 additions & 0 deletions src/Powercord/plugins/commands/monkeypatchMessages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const webpack = require('powercord/webpack');
const {
messages: { createBotMessage, receiveMessage },
channels: { getChannelId }
} = webpack;

const messages = webpack.getModule(webpack.moduleFilters.messages[0]);

module.exports = async function monkeypatchMessages () {
messages.sendMessage = (sendMessage => async (id, message, ...params) => {
if (!message.content.startsWith(this.prefix)) {
return sendMessage(id, message, ...params);
}

const [ command, ...args ] = message.content.slice(1).split(' ');
if (!this.commands.has(command)) {
return sendMessage(id, message, ...params);
}

const result = await this.commands.get(command).func(args, this);
if (!result) {
return;
}

if (result.send) {
message.content = result.result;
} else {
const receivedMessage = createBotMessage(getChannelId(), '');

if (typeof result.result === 'string') {
receivedMessage.content = result.result;
} else {
receivedMessage.embeds.push(result.result);
}

return receiveMessage(receivedMessage.channel_id, receivedMessage);
}

return sendMessage(id, message, ...params);
})(this.oldSendMessage = messages.sendMessage);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Plugin = require('ac/Plugin');
const { get, post } = require('ac/http');
const Plugin = require('powercord/Plugin');
const { get, post } = require('powercord/http');
const { clipboard } = require('electron');

module.exports = class Hastebin extends Plugin {
Expand All @@ -13,7 +13,7 @@ module.exports = class Hastebin extends Plugin {
}

start () {
aethcord
powercord
.plugins.get('commands')
.register(
'hastebin',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// idea based on http://heygirl.io/ (+used their images)

const Plugin = require('ac/Plugin');
const Plugin = require('powercord/Plugin');

module.exports = class HeyGirl extends Plugin {
constructor () {
Expand Down Expand Up @@ -38,7 +38,7 @@ module.exports = class HeyGirl extends Plugin {
}

start () {
aethcord
powercord
.plugins
.get('commands')
.register(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { sleep } = require('ac/util');
const { sleep } = require('powercord/util');

const plugins = (() => {
const _plugins = {};
Expand All @@ -20,7 +20,7 @@ const startPlugins = (stage) =>
.filter(plugin => plugin.options.stage === stage)
.map(async (plugin) => {
while (!plugin.options.dependencies.every(pluginName => (
aethcord.plugins.get(pluginName).ready
powercord.plugins.get(pluginName).ready
))) {
await sleep(5);
}
Expand All @@ -31,7 +31,7 @@ const startPlugins = (stage) =>
module.exports = new Map(Object.entries(plugins));

(async () => {
while (!global.aethcord) {
while (!global.powercord) {
await sleep(5);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Plugin = require('ac/Plugin');
const Plugin = require('powercord/Plugin');

const libraries = require('./libraries.json');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { React, contextMenu } = require('ac/webpack');
const { ContextMenu } = require('ac/components');
const { concat } = require('ac/util');
const { React, contextMenu } = require('powercord/webpack');
const { ContextMenu } = require('powercord/components');
const { concat } = require('powercord/util');

const SpotifyPlayer = require('../SpotifyPlayer.js');
const getContextMenuItemGroups = require('./contextMenuGroups');
Expand Down Expand Up @@ -86,15 +86,15 @@ module.exports = class Modal extends React.Component {
const { currentItem, isPlaying, displayState } = this.state;
const artists = concat(currentItem.artists);

let className = 'container-2Thooq aethcord-spotify';
let className = 'container-2Thooq powercord-spotify';
if (this.state.seekBar.showDurations || this.state.seekBar.seeking) {
className += ' expend';
}

return (
<div
className={className}
id='aethcord-spotify-modal'
id='powercord-spotify-modal'
onContextMenu={this.injectContextMenu.bind(this)}
style={displayState === 'hide' ? { display: 'none' } : {}}
>
Expand Down
Loading

0 comments on commit 9c64db3

Please sign in to comment.