better import

This commit is contained in:
Mylloon 2021-06-07 23:55:19 +02:00
parent 016727a36a
commit ce855a0b98
6 changed files with 16 additions and 17 deletions

View file

@ -1,5 +1,5 @@
import discord
import re
from re import findall
from discord.ext import commands
from utils.core import userOrNick
from utils.time import timestampScreen
@ -14,7 +14,7 @@ class Citation(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message):
urls = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', message.content)
urls = findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', message.content)
httpsString = "https://"
channelsString = "discord.com/channels/"
for i in range(len(urls)):

View file

@ -2,9 +2,9 @@ import discord
from re import findall
from discord.ext import commands
from random import randint, choice
from datetime import timedelta
from discord_slash import cog_ext
from utils.core import retirerDoublons
from utils.time import intToDatetime
def setup(client):
client.add_cog(Fun(client))
@ -142,7 +142,7 @@ class Fun(commands.Cog):
"""Se moque du message précédent. - Slash command not available"""
first = 0
suite_auteur = None
temps_limite = (await ctx.message.channel.history(limit = 2).flatten())[1].created_at - timedelta(minutes = 5)
temps_limite = intToDatetime((await ctx.message.channel.history(limit = 2).flatten())[1].created_at.timestamp() - 300) # on retire 5 minutes (5 x 60 secondes)
final_message = ""
async for message in ctx.message.channel.history(limit = 20, after = temps_limite, oldest_first = False):
if first == 0:

View file

@ -1,7 +1,7 @@
import discord
import asyncio
from discord.ext import commands
from random import randint, choice
import asyncio
from discord_slash import cog_ext
def setup(client):

View file

@ -1,5 +1,5 @@
import discord
import feedparser
from feedparser import parse
from os import environ
from discord.ext import commands
from random import choice
@ -193,7 +193,7 @@ class Internet(commands.Cog):
embed = discord.Embed(title = "Liste des sources", color = discord.Colour.random(), description = ", ".join([key.capitalize() for key in rss_website.keys()]))
return await ctx.send(embed = embed)
newsfeed = feedparser.parse(rss_website[choix_site])
newsfeed = parse(rss_website[choix_site])
info = choice([newsfeed.entries[i] for i in range(0, 10 if len(newsfeed.entries) > 10 else len(newsfeed.entries))])
desc = "Pas de description trouvée." if "<p>" in info.description or "</a>" in info.description else info.description

View file

@ -18,11 +18,11 @@ from async_timeout import timeout
from discord.ext import commands
# Genius API
import lyricsgenius
import time
import os
genius = lyricsgenius.Genius(os.environ['TOKEN_GENIUS'])
from lyricsgenius import Genius
from os import environ
from utils.core import ligneFormatage, userOrNick
from utils.time import nowCustom
genius = Genius(environ['TOKEN_GENIUS'])
# Silence useless bug reports messages
youtube_dl.utils.bug_reports_message = lambda: ''
@ -498,7 +498,7 @@ class Music(commands.Cog):
message = await ctx.send(f":mag: **Cherche les paroles romanisées de ** `{song.replace(' romanized', '')}`")
else:
message = await ctx.send(f":mag: **Cherche les paroles de ** `{song}`")
temps_requete = int(round(time.time() * 1000))
temps_requete = int(round(nowCustom() * 1000))
song_genius = genius.search_song(song)
couleur_embed = discord.Colour.random()
try:
@ -531,7 +531,7 @@ class Music(commands.Cog):
await ctx.send(embed = embed)
lignetotal = f"{ligneFormatage(ligne)}"
temps_requete = int(round(time.time() * 1000)) - temps_requete
temps_requete = int(round(nowCustom() * 1000)) - temps_requete
footer_embed = f"Pour {userOrNick(ctx.author)} par Genius en {round(temps_requete / 1000, 2)} s."
await ctx.message.add_reaction(emoji = '')
if premierembed == True:

View file

@ -1,12 +1,11 @@
print("Chargement des extensions & librairie...", end = " ")
import discord
import os
from os import environ
from discord_slash import SlashCommand
from discord.ext import commands
from utils.reminder import Reminder
customPrefix = os.environ['PREFIX']
customTimezone = os.environ['TIMEZONE']
customPrefix = environ['PREFIX']
client = commands.Bot(command_prefix = customPrefix, case_insensitive = True, intents = discord.Intents.all())
slash = SlashCommand(client, sync_commands = True)
@ -53,4 +52,4 @@ async def on_message(message):
await ctx.send(f">>> Coucou !\nMon préfix est `{prefix}` et ma commande d'aide est `{prefix}help`")
print("Connexion à Discord...", end = " ")
client.run(os.environ['TOKEN_DISCORD'])
client.run(environ['TOKEN_DISCORD'])