adding test cog for new slash commands

This commit is contained in:
Mylloon 2021-05-28 14:03:34 +02:00
parent 7caa860753
commit b1f2e3ad39
3 changed files with 21 additions and 0 deletions

View file

@ -4,3 +4,4 @@ asyncpraw==7.2.0 # reddit
youtube-dl==2021.4.26 # music youtube-dl==2021.4.26 # music
lyricsgenius==3.0.1 # lyrics lyricsgenius==3.0.1 # lyrics
feedparser==6.0.2 # rss feed (news) feedparser==6.0.2 # rss feed (news)
discord-py-slash-command==1.2.0 # slash commands

17
src/cogs/slash.py Normal file
View file

@ -0,0 +1,17 @@
import discord
from discord.ext import commands
from discord_slash import cog_ext, SlashContext
def setup(client):
client.add_cog(Slash(client))
class Slash(commands.Cog):
"""Slash commands test."""
def __init__(self, client):
self.client = client
@cog_ext.cog_slash(name="test")
async def _test(self, ctx: SlashContext):
embed = discord.Embed(title="embed test")
await ctx.send(content="test", embeds=[embed])

View file

@ -1,6 +1,7 @@
print("Chargement des extensions & librairie...", end = " ") print("Chargement des extensions & librairie...", end = " ")
import discord, re, pytz, os import discord, re, pytz, os
from discord_slash import SlashCommand
from discord.ext import commands from discord.ext import commands
from random import choice from random import choice
from datetime import datetime from datetime import datetime
@ -9,6 +10,7 @@ customPrefix = os.environ['PREFIX']
customTimezone = os.environ['TIMEZONE'] customTimezone = os.environ['TIMEZONE']
client = commands.Bot(command_prefix = customPrefix, case_insensitive = True, intents = discord.Intents.all()) client = commands.Bot(command_prefix = customPrefix, case_insensitive = True, intents = discord.Intents.all())
slash = SlashCommand(client, sync_commands = True, sync_on_cog_reload = True)
client.load_extension("cogs.help") client.load_extension("cogs.help")
client.load_extension("cogs.utils") client.load_extension("cogs.utils")
@ -18,6 +20,7 @@ client.load_extension("cogs.games")
client.load_extension("cogs.fun") client.load_extension("cogs.fun")
client.load_extension("cogs.autopublish") client.load_extension("cogs.autopublish")
client.load_extension("cogs.school") client.load_extension("cogs.school")
client.load_extension("cogs.slash")
print("Terminé !") print("Terminé !")
@client.event @client.event