Giter Club home page Giter Club logo

discordcrossposting's Introduction

Node CI Docker Build CI Automerge

Discord Cross Poster

Purpose

Bot to cross-post messages between servers, similar to what the announcement channels do, but without having to be a Discord partner and with more control over what is published automatically.

Setup

This bot is written in Typescript, running as a Node.js package. To set it up, first install the dependencies and compile to vanilla Javascript, running

npm i && npm run build

from the root directory.

Copy the config.json.example to data/config.json and adjust to your liking. Tokens can be acquired from the Developer Portal when creating a new application.

Note that the Message Content Intent needs to be enabled for your bot application on the developer portal!

When starting for the first time, you need to first register all commands with the app. To do so, you can run

node built/src/index.js --register

Running

After setting up, you can run the bot using

node built/index.js

or

npm run run

From the root directory. You may want to put a service in place to automatically run the bot, as usual.

Usage

The crossposter features the following commands, all of them only available to the owner of the bot, as defined within the configuration file.

listservers

Lists all servers the bot instance is running on. No parameters.

listbridges

Lists all active bridges. No parameters.

removebridge

Removes a bridge by its ID. The only parameter is a numerical ID, which can be acquired from the listbridges command.

createbridge

Creates a new bridge from one server + channel to another. The parameters are as following:

  1. Name of the server from which the messages should be read. A list of servers the bot has access to can be acquired from listservers.
  2. Name of the channel on the source server from which messages should be read. The channel must exist and the bot must be able to read from it, or the command will.
  3. Name of the server to which the messages should be forwarded.
  4. Name of the channel on the destination server where the messages should be written to. Again, that channel must exist.
  5. A descrimniator to determine whether a message will be forwarded over the bridge. Available discriminators are:
    1. uid the user ID of the user who posted the message. Use if you want to only forward messages from certain users.
    2. uname the display name of the user who posted the message. Use if you want to only forward messages when their poster has a certain name. See below for RegEx usage.
    3. text the text of the message. Useful if you only want to forward messages when they feature certain content. See below for RegEx usage.
  6. The regular expression which the descriminator must match. If anything should match, just pass ..
  7. Mentions that should be preserved. These can be users, roles, or everyone. That means for example, if you preserve roles on a bridge, the bot will attempt to actually mention role in their forwarded post. Elsewise, roles will just appear as plain text without causing a notification for users. Note that everyone will preserve both @everyone and @here. You can combine these mentions by passing multiple values with a comma separator. I.e. passing users,everyone for this parameter will preserve mentions for users and @everyone, but not for roles.

If any of the parameters in a command contains whitespace, you need to put qutoes around them.

RegEx

Messages are only forwarded, if their discriminator matches a regular expression. The most simple case would be to have all messages from server A in channel foo forwarded to channel bar on server B:

createbridge A foo B bar text:.*

But it could also be used to only forward messages that start with a trigger word, like "ATTENTION":

createbridge A foo B bar text "^ATTENTION.*"  

Or players whose display name indicate they belong to a certain guild (be aware that on most servers users can freely change their display name):

createbridge A foo B bar uname "\[EPIC\]"

would only forward messages from players with the tag "[EPIC]" in their display name.

Docker

You can mount a volume on /app/data which should contain your config.json and your database.db file.

discordcrossposting's People

Contributors

dependabot[bot] avatar ogrady avatar xyaren avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

discordcrossposting's Issues

Build is failing

#13 5.254 > tsc
#13 5.254
#13 35.77 src/BotClient.ts(46,17): error TS2820: Type '"GUILD_MESSAGES"' is not assignable to type 'number | `${bigint}` | "Guilds" | "GuildMembers" | "GuildBans" | "GuildEmojisAndStickers" | "GuildIntegrations" | "GuildWebhooks" | "GuildInvites" | "GuildVoiceStates" | "GuildPresences" | ... 9 more ... | RecursiveReadonlyArray<...>'. Did you mean '"GuildMessages"'?
#13 35.78 src/BotClient.ts(47,17): error TS2820: Type '"GUILDS"' is not assignable to type 'number | `${bigint}` | "Guilds" | "GuildMembers" | "GuildBans" | "GuildEmojisAndStickers" | "GuildIntegrations" | "GuildWebhooks" | "GuildInvites" | "GuildVoiceStates" | "GuildPresences" | ... 9 more ... | RecursiveReadonlyArray<...>'. Did you mean '"Guilds"'?
#13 35.78 src/BotClient.ts(70,21): error TS2322: Type 'string' is not assignable to type 'ActivityType.Playing | ActivityType.Streaming | ActivityType.Listening | ActivityType.Watching | ActivityType.Competing | undefined'.
#13 35.78 src/BotClient.ts(208,26): error TS2339: Property 'isText' does not exist on type 'GuildBasedChannel'.
#13 35.78   Property 'isText' does not exist on type 'TextChannel'.
#13 35.78 src/BotClient.ts(209,17): error TS2322: Type 'TextChannel | NewsChannel | CategoryChannel | StageChannel | VoiceChannel' is not assignable to type 'TextChannel | NewsChannel | null'.
#13 35.78   Type 'CategoryChannel' is not assignable to type 'TextChannel | NewsChannel | null'.
#13 35.78     Type 'CategoryChannel' is missing the following properties from type 'NewsChannel': threads, addFollower, rateLimitPerUser, nsfw, and 22 more.
#13 35.78 src/commands/ListBridges.ts(2,10): error TS2305: Module '"discord.js"' has no exported member 'MessageEmbed'.

Error when launching

Hello,
I get an error when I try to launch your bot. Here is the log file.
I hope you can help me and find the issues.

Thanks, and congrats for your work !

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'run'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prerun', 'run', 'postrun' ]
5 info lifecycle [email protected]prerun: [email protected]
6 info lifecycle [email protected]
run: [email protected]
7 verbose lifecycle [email protected]run: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
run: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\User\Desktop\DiscordCrossPosting-master\DiscordCrossPosting-master\node_modules.bin;C:\Program Files (x86)\VMware\VMware Workstation\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files\AdoptOpenJDK\jre-8.0.292.10-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\PuTTY;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet;C:\Program Files\WireGuard;C:\Program Files\nodejs;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Users\User\AppData\Local\Programs\Python\Python39\Scripts;C:\Users\User\AppData\Local\Programs\Python\Python39;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Roaming\npm;C:\Users\User.dotnet\tools
9 verbose lifecycle [email protected]run: CWD: C:\Users\User\Desktop\DiscordCrossPosting-master\DiscordCrossPosting-master
10 silly lifecycle [email protected]
run: Args: [ '/d /s /c', 'node ./built/index.js' ]
11 silly lifecycle [email protected]run: Returned: code: 1 signal: null
12 info lifecycle [email protected]
run: Failed to exec run script
13 verbose stack Error: [email protected] run: node ./built/index.js
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:400:28)
13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:400:28)
13 verbose stack at maybeClose (internal/child_process.js:1055:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\User\Desktop\DiscordCrossPosting-master\DiscordCrossPosting-master
16 verbose Windows_NT 10.0.19043
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "run"
18 verbose node v14.17.6
19 verbose npm v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] run: node ./built/index.js
22 error Exit status 1
23 error Failed at the [email protected] run script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

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.