Adding new Discord Feature: Party Games
This commit is contained in:
parent
7d547ede67
commit
8496b23cf9
2 changed files with 95 additions and 1 deletions
|
@ -7,3 +7,4 @@ feedparser==6.0.8 # rss feed (news)
|
||||||
discord-py-slash-command==3.0.1 # slash commands
|
discord-py-slash-command==3.0.1 # slash commands
|
||||||
python_dotenv==0.19.0 # using .env file
|
python_dotenv==0.19.0 # using .env file
|
||||||
wavelink==0.9.10 # music | to know the version of lavalink used, see the repo
|
wavelink==0.9.10 # music | to know the version of lavalink used, see the repo
|
||||||
|
discord-together==1.1.1 # for the party games
|
||||||
|
|
93
src/cogs/partygames.py
Normal file
93
src/cogs/partygames.py
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
import discordTogether
|
||||||
|
from discord_slash import cog_ext
|
||||||
|
from discordTogether import DiscordTogether
|
||||||
|
from utils.core import mySendHidden
|
||||||
|
|
||||||
|
def setup(client):
|
||||||
|
"""Adding Cog to bot"""
|
||||||
|
client.add_cog(PartyGames(client))
|
||||||
|
|
||||||
|
class PartyGames(commands.Cog, name="Partygames"):
|
||||||
|
"""Discord beta "party games" dispo uniquement sur PC."""
|
||||||
|
def __init__(self, client):
|
||||||
|
self.client = client
|
||||||
|
self.togetherControl = DiscordTogether(client)
|
||||||
|
self.appList = { # appNameForDiscord - (AppNameForConsumer, AppImage)
|
||||||
|
"youtube": ("Youtube Together", "https://logo-logos.com/wp-content/uploads/2016/11/YouTube_icon_logo.png"),
|
||||||
|
"poker": ("Poker Night", None),
|
||||||
|
"chess": ("Chess in the Park", None),
|
||||||
|
"betrayal": ("Betrayal.io", None),
|
||||||
|
"fishing": ("Fishington.io", None)
|
||||||
|
}
|
||||||
|
|
||||||
|
@commands.command(name='app', hidden = True)
|
||||||
|
async def linkCreator(self, ctx, app: str = None, fromSlash = None):
|
||||||
|
"""Renvoie l'embed de l'app selectionée\n ➡ Syntaxe: {PREFIX}app <appName>"""
|
||||||
|
if app == None:
|
||||||
|
return await mySendHidden(ctx, fromSlash, f"Aucune application renseignée, merci d'en renseigner une (`{ctx.prefix}app <appName>`).")
|
||||||
|
appName = app
|
||||||
|
appImage = None
|
||||||
|
try:
|
||||||
|
appName = self.appList[app][0]
|
||||||
|
appImage = self.appList[app][1]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
link = await self.togetherControl.create_link(ctx.author.voice.channel.id, app)
|
||||||
|
except AttributeError:
|
||||||
|
return await mySendHidden(ctx, fromSlash, "Vous devez d'abord être dans un salon vocal avant de faire cette commande.")
|
||||||
|
except discordTogether.errors.InvalidActivityChoice:
|
||||||
|
return await mySendHidden(ctx, fromSlash, "Cette application n'est pas reconnu par Discord.")
|
||||||
|
embed = discord.Embed(title = "Party Games", description = f"[Lancer *{appName}*]({link})")
|
||||||
|
if appImage:
|
||||||
|
embed.set_thumbnail(url = appImage)
|
||||||
|
embed.set_footer(text = "Ne fonctionne que sur PC pour le moment.")
|
||||||
|
return await ctx.send(embed = embed)
|
||||||
|
|
||||||
|
|
||||||
|
@commands.command(name='youtube')
|
||||||
|
async def _youtube(self, ctx, fromSlash = None):
|
||||||
|
"""Créer une instance "Youtube Together"."""
|
||||||
|
return await ctx.invoke(self.client.get_command("app"), "youtube", fromSlash)
|
||||||
|
@cog_ext.cog_slash(name="youtube", description = "Créer une instance \"Youtube Together\".")
|
||||||
|
async def __youtube(self, ctx):
|
||||||
|
"""Slash command"""
|
||||||
|
return await self._youtube(ctx, True)
|
||||||
|
|
||||||
|
@commands.command(name='poker')
|
||||||
|
async def _poker(self, ctx, fromSlash = None):
|
||||||
|
"""Créer une instance "Poker Night"."""
|
||||||
|
return await ctx.invoke(self.client.get_command("app"), "poker", fromSlash)
|
||||||
|
@cog_ext.cog_slash(name="poker", description = "Créer une instance \"Poker Night\".")
|
||||||
|
async def __poker(self, ctx):
|
||||||
|
"""Slash command"""
|
||||||
|
return await self._poker(ctx, True)
|
||||||
|
|
||||||
|
@commands.command(name='chess')
|
||||||
|
async def _chess(self, ctx, fromSlash = None):
|
||||||
|
"""Créer une instance "Chess in the Park"."""
|
||||||
|
return await ctx.invoke(self.client.get_command("app"), "chess", fromSlash)
|
||||||
|
@cog_ext.cog_slash(name="chess", description = "Créer une instance \"Chess in the Park\".")
|
||||||
|
async def __chess(self, ctx):
|
||||||
|
"""Slash command"""
|
||||||
|
return await self._chess(ctx, True)
|
||||||
|
|
||||||
|
@commands.command(name='betrayal')
|
||||||
|
async def _betrayal(self, ctx, fromSlash = None):
|
||||||
|
"""Créer une instance "Betrayal.io"."""
|
||||||
|
return await ctx.invoke(self.client.get_command("app"), "betrayal", fromSlash)
|
||||||
|
@cog_ext.cog_slash(name="betrayal", description = "Créer une instance \"Betrayal.io\".")
|
||||||
|
async def __betrayal(self, ctx):
|
||||||
|
"""Slash command"""
|
||||||
|
return await self._betrayal(ctx, True)
|
||||||
|
|
||||||
|
@commands.command(name='fishing')
|
||||||
|
async def _fishing(self, ctx, fromSlash = None):
|
||||||
|
"""Créer une instance "Fishington.io"."""
|
||||||
|
return await ctx.invoke(self.client.get_command("app"), "fishing", fromSlash)
|
||||||
|
@cog_ext.cog_slash(name="fishing", description = "Créer une instance \"Fishington.io\".")
|
||||||
|
async def __fishing(self, ctx):
|
||||||
|
"""Slash command"""
|
||||||
|
return await self._fishing(ctx, True)
|
Reference in a new issue