Giter Club home page Giter Club logo

discord-spoiler-bot's Introduction

Discord Spoiler Bot

npm npm npm dependencies

A Discord bot that replaces spoiler messages with GIFs that reveal content on hover.

Demo

Single line

Discord Spoiler Bot in action

Multi-line

Discord Spoiler Bot with multi-line comments

Marking someone else's message as a spoiler

Discord Spoiler Bot marking other messages as spoilers

Documentation

Check Discord Spoiler Bot Wiki on GitHub for full documentation. See section below for the quick start guide.

Quick start

If you know what you're doing, you can jump right in. First, make sure you have all prerequisites for node-canvas installed. Then add Discord Spoiler Bot to your npm project:

$ npm install discord-spoiler-bot --save

Now get a secret token for your bot and make sure the bot has permission to read, write and delete messages as well as upload files. Create a file called index.js and put the following inside:

'use strict';

const SpoilerBot = require('discord-spoiler-bot');

let config = {
    token: 'you_secret_token_here',
};

let bot = new SpoilerBot(config);
bot.connect();

Launch your bot using Node.js:

$ node index.js

And you're done! Write messages of format <topic>:spoiler:<content> to mark your own messages as spoilers, e.g.:

FMA:spoiler:Elric brothers are alchemists!

To mark someone else's messages, use <message-id>:spoils:<topic>, but you will have to configure permissions first. See Configuration section.

Already have a bot running on discord.js or discord.io? You can supply an instance of Client instead of a token, see Usage section for examples.

Reporting bugs

Please create an issue thread here. I will try to reply and resolve issues to the best of my ability.

Known issues

  • It's been reported that GIFs play continuously on mobile devices instead of stopping after revealing the spoiler. Sadly this is a limitation of the mobile Discord app and I can't do anything about it.
  • On Windows, node-canvas library does not support true type fonts so Discord Spoiler Bot uses the default node-canvas font instead of Source Sans Pro Regular.

Contributing

I believe this bot is feature-complete, and from now on will most likely only fix bugs. Before adding a new feature to this bot and creating a pull request, make sure said feature makes sense in the context of Discord Spoiler Bot.

Make sure npm test and npm run lint return no errors before making a pull request, otherwise I might reject it. npm run test-no-delete is available for your convenience, running this command will make sure that GIFs produced during testing are not removed so you can inspect them for any artifacts.

discord-spoiler-bot's People

Contributors

aeryax avatar l11k avatar timbokz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord-spoiler-bot's Issues

Bot no longer required.

This bot is no longer required as Discord has now added a spoiler feature that works as follows:

||This is a spoiler and will be hidden||

Error: Can't find Python executable

Yes I did install everything in that requires.

Ξ» npm install discord-spoiler-bot --save

[email protected] install C:\Users\hp\Desktop\Bots\test\node_modules\canvas
node-gyp rebuild

C:\Users\hp\Desktop\Bots\test\node_modules\canvas>if not defined npm_config_node_gyp (node "C:\Users\hp\AppData\Roami
e_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\hp\AppData\Local\Programs\Python\Python35-32\python.EXE"
gyp ERR! stack at PythonFinder.failNoPython (C:\Users\hp\AppData\Roaming\npm\node_modules\npm\node_modules\node-g
gyp ERR! stack at PythonFinder. (C:\Users\hp\AppData\Roaming\npm\node_modules\npm\node_modules\node-gy
gyp ERR! stack at C:\Users\hp\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\hp\AppData\Roaming\npm\node_modules\npm\node
gyp ERR! cwd C:\Users\hp\Desktop\Bots\test\node_modules\canvas
gyp ERR! node -v v8.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] requires a peer of bufferutil@^3.0.0 but none was installed.
npm WARN [email protected] requires a peer of erlpack@hammerandchisel/erlpack but none was installed.
npm WARN [email protected] requires a peer of node-opus@^0.2.5 but none was installed.
npm WARN [email protected] requires a peer of opusscript@^0.0.3 but none was installed.
npm WARN [email protected] requires a peer of sodium@^2.0.1 but none was installed.
npm WARN [email protected] requires a peer of libsodium-wrappers@^0.5.1 but none was installed.
npm WARN [email protected] requires a peer of uws@^0.14.1 but none was installed.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hp\AppData\Roaming\npm-cache_logs\2017-09-02T08_37_52_575Z-debug.log

Bot won't start on Ubuntu 16.10 64 bit

Trying to host this via Digital Ocean but I keep getting this error whenever I try to start the bot:

root@Discord:~#`` node index.js
/root/node_modules/discord-spoiler-bot/index.js:9
let bot = new SpoilerBot(config);
^

TypeError: SpoilerBot is not a constructor
at Object. (/root/node_modules/discord-spoiler-bot/index.js:9:11)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/root/index.js:3:20)
at Module._compile `(module.js:570:32)

I've got node at v6.10.0 but I've tried other versions and nothing seems to fix it.

[Suggestion] Set bot presence/game as spoiler syntax

In the config allow for the end user to supply a "game" for discord to play. This will allow it to show underneath the Name in the member's list of the server.

For Example:
Spoiler Bot
Playing [TOPIC]:spoiler:[TEXT]

No text above spoilers

Unable to figure out this one. Using node 7.10.0 NPM 4.5.0
What it looks like here
)```
user@user:~/discord$ node index.js --trace-warnings
Discord Spoiler Bot is running...
(node:90827) DeprecationWarning: TextChannel#sendFile: use TextChannel#send instead
(node:90827) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): DiscordAPIError: Unknown Message
(node:90827) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Bot frequently stops due to unhandled error event

The stacktrace contains:

events.js:188
      throw err;
      ^

Error: Unhandled "error" event. ([object Object])
    at Client.emit (events.js:186:19)
    at WebSocketConnection.onError (/home/yokuyuki/spoilerbot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
    at WebSocket.onError (/home/yokuyuki/spoilerbot/node_modules/discord.js/node_modules/ws/lib/event-target.js:128:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at WebSocket.finalize (/home/yokuyuki/spoilerbot/node_modules/discord.js/node_modules/ws/lib/websocket.js:185:12)
    at ClientRequest._req.on (/home/yokuyuki/spoilerbot/node_modules/discord.js/node_modules/ws/lib/websocket.js:641:12)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:551:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:115:23)
    at TLSSocket.socketOnData (_http_client.js:440:20)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)

Support external bot instances

If there's anyone out there like me, they are using this bot as a sort of addon to their existing bot. But since this bot spawns its own discord.js session, my bot now has 2 sessions going.

I know I could just require your GifGenerator module and write my own version of SpoilerBot.js, but that feels redundant and a waste of some finely written code. My idea is that you could include an existing bot object as an optional config parameter, and that would be used to perform its functions instead of a new instance.

The rub is that my bot uses a different node bot library, discord.io, so I couldn't expect you to include support for injecting a discord.io instance as well as a discord.js instance.

So: I'm asking for your permission to create and publish my own fork of this package on npm, a fork that uses discord.io and supports loading an external instance of it.

'CGFontGetGlyphPath' Error

Hello o/

I'm getting an error that's keeping the bot from functioning properly where 1) the "spoiler" term isn't being retracted upon spoiler command 2) gifs aren't being implemented and 3) hover functionality isn't working - instead if the window is up and the spoiler is viewable, the content is automatically revealed.
Here's a screenshot of the issue (content is hidden due to use of Grab app to screenshot):
spoiler bot error

Here's the code block of error text:

Mar 13 14:52:33  node[4057] <Error>: The function β€˜CGFontGetGlyphPaths’ is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.
(node:4057) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
    at item.request.gen.end (/Users/brendenhurley/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:71:65)
    at then (/Users/brendenhurley/node_modules/snekfetch/src/index.js:215:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)
(node:4057) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:4057) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

##Apologies if this error has less to do with your code specifically - relatively new to js and discord bots so struggling my way through. I'm running macOS High Sierra (Version 10.12.6). lmk if you need anymore information!

Works swimmingly on Windows but some errors on ubuntu

I was able to get your bot running on windows but for some reason I get this error message when I try installing it on Ubuntu. I followed all of the prerequisate steps (for some reason on that page the command they give does not install npm or node, that has to be done seperately). Running the code does succesfully create a discord-spoiler bot folder as well. Running the index.js gives me another error message different from what you see here but it also includes a lack of package.json. Which package.json is it asking for?

ownagecat@ownagecat-desktop:~/node_modules$ npm install discord-spoiler-bot --save

loadDep:gifencoder β†’ reso β–„ β•’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β•Ÿ
WARN engine [email protected]: wanted: {"node":">=6.0.0"} (current: {"node":"4.2npm WARN saveError ENOENT: no such file or directory, open '/home/ownagecat/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/ownagecat/package.json'
npm WARN [email protected] requires a peer of erlpack@hammerandchisel/erlpack#master but none was installed.
npm WARN [email protected] requires a peer of node-opus@^0.2.0 but none was installed.
npm WARN [email protected] requires a peer of opusscript@^0.0.1 but none was installed.
npm WARN [email protected] requires a peer of uws@^0.12.0 but none was installed.
npm WARN ownagecat No description
npm WARN ownagecat No repository field.
npm WARN ownagecat No README data
npm WARN ownagecat No license field.
ownagecat@ownagecat-desktop:~/node_modules$

[Suggestion] Put pictures under spoiler

Hi :)

I just installed the bot, and it's working really great, that's a fantastic bot.
I just wanted to know if you're planning to add spoilers for images ? I think that would be a really great feature.

Thanks again

Canvas.Font error on startup

Using the example script, upon initializing this error comes up:

C:\d-bot\node_modules\discord-spoiler-bot\src\GifGenerator.js:28
const SOURCE_SANS_PRO = new Canvas.Font('SourceSansPro', path.join(FONT_PATH, 'SourceSansPro-Regular.ttf'));
                        ^
TypeError: Canvas.Font is not a constructor

Error

if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.  [C:\Users\GangGamerAK\Pictures\Botspoiler\node_modules\canvas\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\GangGamerAK\Pictures\Botspoiler\node_modules\canvas
gyp ERR! node -v v8.1.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] requires a peer of bufferutil@^3.0.2 but none was installed.
npm WARN [email protected] requires a peer of erlpack@hammerandchisel/erlpack but none was installed.
npm WARN [email protected] requires a peer of node-opus@^0.2.6 but none was installed.
npm WARN [email protected] requires a peer of opusscript@^0.0.3 but none was installed.
npm WARN [email protected] requires a peer of sodium@^2.0.1 but none was installed.
npm WARN [email protected] requires a peer of libsodium-wrappers@^0.5.4 but none was installed.
npm WARN [email protected] requires a peer of uws@^0.14.5 but none was installed.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\GangGamerAK\AppData\Roaming\npm-cache\_logs\2017-10-11T17_14_25_266Z-debug.log

I am having this error help please

Impossible to build

note: I'm fairly new to Node.JS but I'm an experienced Linuxian, bash, C++ and C# programmer.
After a full hour trying different things, I find myself unable to build and run my own copy of this bot.
I have failed compiling the various dependencies on both Windows 10 x86_64 and Dockerized Ubuntu.

The main culprint appears to be libsodium and opus which won't work by using the Ubuntu's package, and I cannot manage to build it at all, despite following various instructions from other bug trackers and projects with the same error message I am getting.

And I'm not even going to go into the incredible amount of warnings while compiling the dependencies.

How am I supposed to run this?

Can't put emoji/images/gifs in spoiler

Everything is in the title, emoji are replaced by encoding errors (I think), and images and gifs just don't work. I believe it should be possible to have an image or a gif marked as spoiler because of obvious reasons so yeah... I believe theses could be enhancement for your bot.

Discord now autoplays gifs by default

This was an issue on mobile already, but Discords latest update auto plays gifs when Discord is focused.
This can be opted out on a per-user basis but really hurts the functionality of this bot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.