Giter Club home page Giter Club logo

discord-bot's Introduction

discord-bot

Old bot that we integrated into the Team for the Planet Discord server.

How to run the Bot ?

You must have a Discord account in order to create the application and the bot.

  • Create an application on the Developer portal of Discord (https://discord.com/developers/applications)
  • Create a bot in this application and grab the Token ID. (Settings > Bot > Copy "Token")
  • Since the bot tracks has to download the entire member list, check the option Server Members Intent in the Privileged Gateway Intents section
  • Get Server ID: Server Settings > Widget > Copy "Server ID"
  • Add the bot into the wanted Discord Server (also grab the ID of the server, you must activate Developer mode in order to see it)
  • git clone https://github.com/TeamForThePlanet/discord-bot.git
  • pip install -r requirements.txt
  • Create an .env file with the following information :
TOKEN={Discord Bot Token ID goes here}
TARGET_GUILD_ID={Discord Server ID goes here}
TARGET_ENGLISH_GUILD_ID={English Discord ID goes here}

SHORT_IO_SECRET_KEY={Secret key from Short.io goes here}
SHORT_IO_DOMAIN_ID={Your domain ID from Short.io goes here}

COMMAND_PREFIX={You can change the default command prefix "!"}

CREATOR_ID={Your Discord User ID}
  • Compile translation messages : pybabel compile -d locale
  • Run main.py script

Commands

!alerte-la-planete

This command is useful to notify every member from a planet in the TFTP Discord server. It searches every user that have the planet emoji in their Discord nickname.

For example :

!alerte-la-planete 🔍

This will ping every member from the evaluators.
You can also use the hashtag notation to search the planet channel :

!alerte-la-planete #🔍-évaluateurs-et-évaluatrices

It is also possible to mention multiple planets at the same time :

!alerte-la-planete #🇪🇸-españa #🇮🇹-italia #🇩🇪-deutschland

!quarks-a-accueillir

This command will generate a CSV file containing all server's members that don't have a * in their Discord nickname.

Behaviour

The bot has a chance to react with a random answer when the word "apero" or a beer emoji seems to appear in someone's message.

Translation

In order to extract messages to translate, you can use this command:

pybabel extract . -o locale/base.pot

Then you can update translations for a locale like this:

pybabel update -d locale -l fr_FR -i locale/base.pot

If the locale doesn't exist in the locale directory, you'll want to init that locale with this command (replace it with desired country code):

pybabel init -d locale -l it -i locale/base.pot

Finally, after editing .po files, you can compile translations in a .mo file with this command:

pybabel compile -d locale

discord-bot's People

Contributors

benbb96 avatar kroustille avatar foucaude avatar snyk-bot avatar

Stargazers

Morgan Prieur avatar Enzo Foucaud avatar DarkKnight avatar

Watchers

 avatar

Forkers

marinefou

discord-bot's Issues

New command to ping all planet members

Create a new command !alerte-la-planete #{planet name} in order to get the bot to ping all members of that planet based on the emoji in their Discord username.

Discord command to search among list of useful links related to Time

We're often searching for links about Time for the Planet that we want to provide to someone and that would be cool if would find it really quickly.

First thing to do would be to gather all possible links (website, formation, social networks, videos, ressources, documents, etc.) in a database. Maybe we can add some roles to let users maintain these links.
Anyone could suggest adding a new link and it would need moderation.

Then I believe a Discord command, something like !search-link followed by the terms of search, would be a nice feature to add on the Time's Discord. Then the command would simply do a search query in the database and return it in the channel.

Command to add emoji in server username

Pour contourner le problème du spam du bot lorsqu'il envoie des messages en DM (avec les vidéos de présentations des planètes), on pourrait créer une commande pour ajouter les emojis correspondants à des salons de planètes existants sur le serveur. Le bot mettrait à jour le pseudo de la personne ayant utilisé la commande + lui enverrait un message que lui seul pourrait voir dans le canal actuelle (cf. https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message) avec les liens vers les vidéos disponibles pour les emojis ajoutés.

Inclure de nouvelles phrases pour le bot

__('Le tout venant a été piraté par les momes ! Qu'est ce qu'on fait ? On se risque sur le bizzare ?'),
__('Vous avez sorti le vitriol ?'),
__('Est ce qu'il y aura cette espère de drolerie qu'on buvait dans une petit taule de Biên Hòa, pas tellement loin de Saïgon ?'),
__('J'lui trouve un goût de pomme ? Y'en a !'),
__('Il y a 2 choses qui gagnent à vieillir, le bon vin et les amis.'),
__('La gourmandise est le péché des bonnes âmes'),
__('Quand mes amis me manquent, je fais comme pour les échalotes, je les fais revenir avec du vin blanc'),
__('Ceux qui disent que le petit déjeuner est le repas le plus important de la journée ne connaissent pas l’apéro.'),
__('Quel que soit le problème ou la question, l'apéro est toujours la bonne réponse'),
__('Comme disait Pierre Desproges : Je ne bois jamais à outrance, je ne sais même pas où c'est.'),
__('un mojito, et tout est plus beau!'),
__('Ceux qui cherchent midi à 14h ratent l'heure de l'apéro'),
__('Ne pas confondre : ivre de bonheur et ivre de bonne heure'),
__('Quelqu'un sait à quelle page de la bible on trouve la recette pour changer l'eau en vin ? C'est pour un apéro ce soir!'),

Data persistence thanks to a database

Ajouter une base de données pour avoir de la persistance des données (tels que les compteurs actuellement enregistrés en mémoire)

SQLite semble être le plus simple à intégrer mais cela peut très bien être du MySQL ou PostGreSQL.

Send weekly mass mail to shareholders with @everyone or @here messages

An idea that showed up on Discord is to offer the option to send recap mail to shareholders containing all the messages that pinged @everyone or @here in the Time for the Planet Discord.
Thus even people that are not in the Discord could be informed to what's going on over there.

This requires to have a small database to store emails of shareholders who are willing to receive this newsletter.

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.