-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
202 additions
and
146 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import DebugBot | ||
import os | ||
import discord | ||
from discord.ext import commands | ||
|
||
TOKEN = os.getenv('TOKEN') | ||
|
||
|
||
class UrBot(commands.Bot): | ||
""" | ||
Classe initialisée à chaque lancement du BOT. | ||
""" | ||
async def on_ready(self): | ||
""" | ||
Éxécution d'une action au lancement du BOT. | ||
""" | ||
print('--- We have successfully logged in as {0.user}'.format(self)) | ||
|
||
async def on_message(self, message): | ||
""" | ||
Est une méthode qui permet : | ||
- d'ignorer les messages envoyés par le BOT lui-même ; | ||
- d'appeler une fonction de débogage pour chaque message entrant ; | ||
- de traiter et d'exécuter les commandes des utilisateurs. | ||
""" | ||
if message.author == self.user: | ||
return | ||
|
||
await DebugBot.debug_on_message(message) | ||
|
||
return await BOT.process_commands(message) | ||
|
||
|
||
INTENT = discord.Intents.default() | ||
INTENT.members = True | ||
INTENT.messages = True | ||
BOT = UrBot(command_prefix=DebugBot.event.BOT_PREFIX, intents=INTENT) | ||
BOT.remove_command('help') | ||
|
||
|
||
@BOT.command() | ||
@commands.guild_only() | ||
async def ping(ctx): | ||
""" | ||
Calcul de la latence de l'utilisateur (additionnée à celle des serveurs discord) et renvoie de cette dernière. | ||
""" | ||
latency = round(BOT.latency * 1000) | ||
await ctx.send(f"Pong ! {latency}ms") | ||
|
||
|
||
@BOT.command(name="help") | ||
async def _help(ctx): # Ajouter un underscore évite l'erreur "Shadows built-in name 'help'", sans changer la commande. | ||
""" | ||
Appel d'une méthode quand la commande est reçue. | ||
""" | ||
await DebugBot.debug_on_help(ctx) | ||
|
||
|
||
@BOT.command(name="prez") | ||
async def prez(ctx): | ||
""" | ||
Appel d'une méthode quand la commande est reçue. | ||
""" | ||
await DebugBot.debug_on_prez(ctx) | ||
|
||
|
||
# Fonction utilisée dans "reload_module". | ||
@DebugBot.update_all_modules | ||
async def reload_all_modules(): | ||
""" | ||
Retourne 0. | ||
""" | ||
return 0 | ||
|
||
|
||
# Commande Discord pour recharger les modules | ||
@BOT.command(aliases=['reload', 'rld']) | ||
async def reload_module(ctx): | ||
""" | ||
Appel d'une méthode quand la commande est reçue. | ||
""" | ||
await reload_all_modules() | ||
await ctx.channel.send("The scripts have been reloaded.") | ||
return 0 | ||
|
||
BOT.run(TOKEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
from discord.ext import commands | ||
from bot import templates | ||
from bot import _, strings | ||
import urpy | ||
from urpy.utils import * | ||
from Bot_Base.src.bot import templates | ||
from Bot_Base.src.urpy.my_commands import MyBot, MyCog | ||
from Bot_Base.src.urpy.utils import * | ||
import strings | ||
|
||
#UR_Bot © 2020 by "Association Union des Rôlistes & co" is licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA) | ||
#To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ | ||
#Ask a derogation at [email protected] | ||
|
||
# UR_Bot © 2020 by "Association Union des Rôlistes & co" is licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA) | ||
# To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ | ||
# Ask a derogation at [email protected] | ||
|
||
class About(commands.Cog): | ||
""" This cog contains commands used to get general information about the bot. """ | ||
__doc__ = strings.About_descr | ||
__doc__ = strings.ABOUT_DESCR | ||
|
||
def __init__(self, owner: urpy.MyBot): | ||
""" Creates an about cog. """ | ||
def __init__(self, owner: MyBot): | ||
""" Creates an 'about cog'. """ | ||
super(About, self).__init__() | ||
self.bot = owner | ||
|
||
@commands.command(brief=strings.version_brief, help=strings.version_help) | ||
@commands.command(brief=strings.VERSION_BRIEF, help=strings.VERSION_HELP) | ||
async def version(self, ctx: commands.Context): | ||
""" Displays the version numbers. """ | ||
await self.send_info_msg(ctx) | ||
|
||
@commands.command(brief=strings.credit_brief, help=strings.credit_help) | ||
@commands.command(brief=strings.CREDIT_BRIEF, help=strings.CREDIT_HELP) | ||
async def credit(self, ctx: commands.Context): | ||
""" Displays the credits. """ | ||
await self.send_info_msg(ctx, with_credits=True) | ||
|
@@ -36,7 +37,7 @@ async def send_info_msg(self, ctx, with_credits=False): | |
version=cog.get_version(), | ||
credits=cog.get_credits() if with_credits else "") | ||
|
||
for name, cog in self.bot.cogs.items() if isinstance(cog, urpy.MyCog) | ||
for name, cog in self.bot.cogs.items() if isinstance(cog, MyCog) | ||
) | ||
|
||
# sends the message | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.