-
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.
This reverts commit 32b1de6.
- Loading branch information
Showing
1 changed file
with
20 additions
and
47 deletions.
There are no files selected for viewing
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,88 +1,61 @@ | ||
import discord | ||
from dotenv import load_dotenv | ||
import DebugBot | ||
import os | ||
import discord | ||
from discord.ext import commands | ||
import os | ||
|
||
load_dotenv() | ||
TOKEN = os.getenv('TOKEN') | ||
|
||
|
||
class UrBot(commands.Bot): | ||
""" | ||
Classe initialisée à chaque lancement du BOT. | ||
""" | ||
class UR_BOT(commands.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) | ||
return await bot.process_commands(message) | ||
|
||
|
||
intent = discord.Intents.default() | ||
intent.members = True | ||
intent.messages = True | ||
|
||
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 = UR_BOT(command_prefix=DebugBot.event.BOT_PREFIX, intents=intent) | ||
bot.remove_command('help') | ||
|
||
|
||
@BOT.command() | ||
@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) | ||
latency = round(bot.latency * 1000) | ||
await ctx.send(f"Pong ! {latency}ms") | ||
|
||
|
||
@BOT.command(name="help") | ||
@bot.command(name="help") | ||
async def help(ctx): | ||
""" | ||
Appel d'une méthode quand la commande est reçue. | ||
""" | ||
await DebugBot.debug_on_help(ctx) | ||
|
||
|
||
@BOT.command(name="prez") | ||
@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. | ||
""" | ||
async def reload_module(): | ||
return 0 | ||
|
||
|
||
# Commande Discord pour recharger les modules | ||
@BOT.command(aliases=['reload', 'rld']) | ||
@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.") | ||
await reload_module() | ||
await ctx.channel.send("The scripts has been reloaded.") | ||
return 0 | ||
|
||
BOT.run(TOKEN) | ||
|
||
bot.run(TOKEN) |