GithubHelp home page GithubHelp logo

gamemann / discord-global-chat Goto Github PK

View Code? Open in Web Editor NEW
23.0 2.0 3.0 95 KB

Discord bot that syncs global chats.

Home Page: https://moddingcommunity.com/forums/topic/42-discord-global-chat-channels

License: MIT License

Makefile 0.80% Python 99.20%
discord python discordpy bot discord-bot discord-bots discord-py discordbot examples sqlite

discord-global-chat's Introduction

Discord Global Chat

Description

A Discord bot that allows for global chat between Discord servers in certain channels. Used for the Unnamed Discord community brand.

Requirements

The Discord.py package is required in order to use this bot. You may install this via the following command.

python3 -m pip install -U discord.py

Enable Intents

You must enable intents within the Discord Developers portal under your project's "Bot" tab. You should only need "Server Members Intent", but I've enabled all three just in-case.

Intents Image

Command Line Usage

You may specify the settings JSON (used for the bot token, etc) and the SQLite DB location within the command line. The default settings location is /etc/dgc/settings.json and the default SQLite DB location is /etc/dgc/dgc.db.

The following are examples of how to set these in the program.

python3 src/main.py cfg=/home/cdeacon/settings.json sqlite=/home/cdeacon/dgc.db

Config

The config file is in JSON format and the following keys are supported.

  • BotToken - The Discord bot token. Please retrieve this from the Discord Developers page for your bot.
  • BotMsgStayTime - When the bot replies to a command in a text channel, delete the bot message this many seconds after (default - 10.0 seconds).
  • UpdateTime - How often to update the channel and web hook URL cache in seconds (default - 60.0 seconds).

Bot Commands

The command prefix is !. You must execute these commands inside of a text channel of the guild you want to modify. You must also be an administrator in order to use these commands.

dgc_linkchannel

!dgc_linkchannel <channel ID>

Adds a channel to the linked global chat. If the channel ID is left blank, it will choose the channel the message was sent in.

dgc_unlinkchannel

!dgc_unlinkchannel <channel ID>

Unlinks a channel to the linked global chat.

dgc_updatehook

!dgc_updatehook <webhook URL>

Updates the web hook that messages send to within the current guild. This must be pointed towards the correct channel ID set with dgc_linkchannel.

Installing

You may use make install within this directory to create the /etc/dgc/ directory and copy settings.json.example to /etc/dgc/settings.json. Please configure the settings.json file to your needs.

Other than that, the needed SQLite tables are created if they don't exist when the Python program is started. However, if need to be, here is the current table structure.

CREATE TABLE IF NOT EXISTS `channels` (guildid integer PRIMARY KEY, channelid integer, webhookurl text)

Starting

As of right now, you'll want to use python3 against the src/main.py file. Something like the following should work.

python3 src/main.py

If there's a better way to handle this, please let me know.

Credits

discord-global-chat's People

Contributors

gamemann 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

Watchers

 avatar  avatar

discord-global-chat's Issues

Upstream changes to discord webhook V2

Changes to Discord API and webhook (moving to version 2.0) breaks the AsyncWebhookAdapter

https://discordpy.readthedocs.io/en/latest/migrating.html?highlight=asyncwebhookadapter

when trying to launch, the following error:

/etc/dgc/Discord-Global-Chat/src# python3 main.py Traceback (most recent call last): File "/etc/dgc/Discord-Global-Chat/src/main.py", line 4, in <module> import discordbot File "/etc/dgc/Discord-Global-Chat/src/discordbot/__init__.py", line 4, in <module> from .discordbot import connect File "/etc/dgc/Discord-Global-Chat/src/discordbot/discordbot.py", line 10, in <module> from discord import Webhook, AsyncWebhookAdapter ImportError: cannot import name 'AsyncWebhookAdapter' from 'discord' (/usr/local/lib/python3.9/dist-packages/discord/__init__.py)

discordbot.py will have to be updated

(will have a go and see if i can fix it)

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.