1
0
mirror of https://gitlab.com/ddorn/tfjm-discord-bot.git synced 2024-12-25 06:22:21 +00:00

add teams voice channels

This commit is contained in:
ddorn 2020-04-28 21:03:35 +02:00
parent 63deb17723
commit d84586b1e9
3 changed files with 65 additions and 2 deletions

View File

@ -1,11 +1,15 @@
import random
import discord
from discord.ext.commands import Cog, command, Context, Bot
from src.constants import *
class MiscCog(Cog, name="Divers"):
def __init__(self, bot: Bot):
self.bot = bot
@command(
name="choose",
usage='choix1 choix2 "choix 3"...',
@ -24,12 +28,36 @@ class MiscCog(Cog, name="Divers"):
@command(name="joke", aliases=["blague"], hidden=True)
async def joke_cmd(self, ctx):
await ctx.message.delete()
with open(JOKES_FILE) as f:
jokes = f.read().split("\n\n\n")
msg = random.choice(jokes)
await ctx.send(msg)
@command(
name="help-test", hidden=True,
)
async def help_test(self, ctx: Context, *args):
if not args:
await self.send_bot_help(ctx)
else:
pass
embed = discord.Embed(
title="Help for `!draw`",
description="Groupe qui continent des commande pour les tirages",
color=0xFFA500,
)
# embed.set_author(name="*oooo*")
embed.add_field(name="zoulou", value="okokok", inline=True)
embed.add_field(name="lklk", value="mnmn", inline=True)
embed.set_footer(text="thankss!")
await ctx.send(embed=embed)
async def send_bot_help(self, ctx: Context):
embed = discord.Embed(title="Aide pour le bot du TFJM²",)
def setup(bot: Bot):
bot.add_cog(MiscCog())
bot.add_cog(MiscCog(bot))

View File

@ -197,6 +197,41 @@ class TeamsCog(Cog, name="Teams"):
reason=f"{ctx.author.name} à demandé une channel pour son équipe.",
)
@team.command(name="voice", usage="Nom du salon")
@commands.has_role(Role.CAPTAIN)
async def team_channel(self, ctx, *channel_name):
"""
(cap) Crée une channel vocale privée pour l'équipe
Crée un endroit de discussion privé seulement pour l'équipe
personne d'autre n'y aura accès.
Exemple:
`!team voice un-nom-sympa`
"""
if not channel_name:
await ctx.send(
"Tu dois mettre un nom d'équipe, par exemple "
"`!team channel un-super-nom`"
)
return
channel_name = " ".join(channel_name)
guild: discord.Guild = ctx.guild
team_role = self.teams_for(ctx.author)[0][1]
team_channel_category = get(guild.categories, name=TEAMS_CHANNEL_CATEGORY)
await guild.create_voice_channel(
channel_name,
overwrites={
guild.default_role: discord.PermissionOverwrite(read_messages=False),
team_role: discord.PermissionOverwrite(read_messages=True),
},
category=team_channel_category,
reason=f"{ctx.author.name} à demandé une channel vocale pour son équipe.",
)
def setup(bot: Bot):
bot.add_cog(TeamsCog())

View File

@ -63,4 +63,4 @@ JOKES_FILE = TOP_LEVEL_DIR / "data" / "jokes"
with open(TOP_LEVEL_DIR / "data" / "problems") as f:
PROBLEMS = f.read().splitlines()
MAX_REFUSE = len(PROBLEMS) - 5
MAX_REFUSE = len(PROBLEMS) - 4 # -5 usually but not in 2020 because of covid-19