forked from viveksantayana/geas-bot
Updated bot.
Bugfix: player count on GM leaving Added /tcard command with audio Updated debug commands
This commit is contained in:
@ -345,7 +345,7 @@ class GameManagement(commands.Cog, name='Game Management'):
|
||||
|
||||
result = ''.join(['```',result,f"The game has been configured with space for {max_players} players (with {current_players if current_players else '0'} currently occupied).",'```'])
|
||||
|
||||
output = f'```Hello {gm.display_name}! Your game channels for `{game_title}` has been updated.\nYou can ping your players or edit the game settings by interacting with the game role through the Bot commands. Have fun!```\n'
|
||||
output = f'```Hello {gm.display_name}! Your game channels for `{game_title}` have been updated.\nYou can ping your players or edit the game settings by interacting with the game role through the Bot commands. Have fun!```\n'
|
||||
output = ''.join([output,f'```Game Title: {game_title}\n'])
|
||||
output = ''.join([output,f'GM: {gm.display_name}\n'])
|
||||
output = ''.join([output,f'Time: {conf[guildStr]["timeslots"][time]}\n'])
|
||||
|
@ -200,6 +200,9 @@ class PlayerCommands(commands.Cog, name='Player Commands'):
|
||||
if game not in player.roles:
|
||||
await ctx.send(f'```Error: You are not in the game {lookup[guildStr][rStr]["game_title"]}.```',hidden=True)
|
||||
return
|
||||
if player.id == lookup[guildStr][rStr]['gm']:
|
||||
await ctx.send(f'```Error: You are the GM of the game {lookup[guildStr][rStr]["game_title"]} and cannot leave until a new GM is assigned.```',hidden=True)
|
||||
return
|
||||
await player.remove_roles(game, reason=f'`/player leave` command issued by {ctx.author.display_name}`.')
|
||||
t = lookup[guildStr][rStr]['time']
|
||||
if data[guildStr][t][rStr]['current_players'] <= 1: data[guildStr][t][rStr]['current_players'] = None
|
||||
|
84
app/cogs/slashcommands/secondary/tcard.py
Normal file
84
app/cogs/slashcommands/secondary/tcard.py
Normal file
@ -0,0 +1,84 @@
|
||||
import os # OS Locations
|
||||
import yaml # YAML parser for Bot config files
|
||||
import asyncio # Discord Py Dependency
|
||||
import discord # Main Lib
|
||||
from datetime import datetime
|
||||
import time
|
||||
from discord.ext import commands # Commands module
|
||||
from discord_slash import SlashCommand, SlashContext, cog_ext, utils # Slash Command Library
|
||||
from discord_slash.utils.manage_commands import create_choice, create_option, create_permission # Slash Command features
|
||||
from discord_slash.model import SlashCommandPermissionType
|
||||
|
||||
from bot import configFile, yaml_load, yaml_dump, lookupFile, dataFile, gmFile, categoriesFile
|
||||
|
||||
#### T Card Command
|
||||
|
||||
class TCardCommand(commands.Cog, name='T-Card Command'):
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
|
||||
conf = yaml_load(configFile)
|
||||
lookup = yaml_load(lookupFile)
|
||||
data = yaml_load(dataFile)
|
||||
gms = yaml_load(gmFile)
|
||||
categories = yaml_load(categoriesFile)
|
||||
guild_ids= [ int(x) for x in list(lookup)]
|
||||
|
||||
@cog_ext.cog_slash(
|
||||
name='tcard',
|
||||
description='Invokes a T-Card in the current game.',
|
||||
default_permission=True,
|
||||
guild_ids=guild_ids,
|
||||
)
|
||||
async def _tcard(self, ctx:SlashContext):
|
||||
conf = yaml_load(configFile)
|
||||
lookup = yaml_load(lookupFile)
|
||||
data = yaml_load(dataFile)
|
||||
gms = yaml_load(gmFile)
|
||||
categories = yaml_load(categoriesFile)
|
||||
guildStr = str(ctx.guild.id)
|
||||
# rStr = str(game.id)
|
||||
embed = discord.Embed(
|
||||
title='T-Card',
|
||||
description='A T-Card Has Been Played',
|
||||
colour=discord.Color.dark_red,
|
||||
)
|
||||
embed.set_footer(text=datetime.now().strftime('%a %-d %b %y, %-I:%M %p'))
|
||||
embed.set_image(url='http://geas.org.uk/wp-content/uploads/2020/08/tcard-1-e1597167776966.png')
|
||||
|
||||
"""If this was called in a game channel"""
|
||||
if str(ctx.channel.category.id) in categories[guildStr]:
|
||||
|
||||
"""Send a T-Card graphic to the channel, tagging the role."""
|
||||
role = ctx.guild.get_role(categories[guildStr][str(ctx.channel.category.id)])
|
||||
await ctx.channel.send(f'{role.mention}', embed=embed)
|
||||
|
||||
if ctx.author_id == lookup[guildStr][str(role.id)]["gm"]:
|
||||
|
||||
"""Behaviour for when the GM issues T-Card command."""
|
||||
await ctx.send(content=f'```You have invoked the T-Card in the game {lookup[guildStr][str(role.id)]["game_title"]} as the GM.```', hidden=True)
|
||||
else:
|
||||
"""Default behaviour for when someone who is not the GM issues the command."""
|
||||
|
||||
"""Privately message the GM."""
|
||||
gm = await ctx.guild.fetch_member(lookup[guildStr][str(role.id)]["gm"])
|
||||
await gm.send(f'**Important**\n```Player {ctx.author.display_name} has invoked a T-Card in your game {lookup[guildStr][str(role.id)]["game_title"]}. Please check in with them and make sure everything is okay. If you need any further help, please feel free to contact a member of the Committee.```')
|
||||
|
||||
"""Notify the issuer of the command privately via hidden reply."""
|
||||
await ctx.send(content=f'```You have invoked the T-Card in the game {lookup[guildStr][str(role.id)]["game_title"]}. The GM has been notified privately.```', hidden=True)
|
||||
|
||||
"""Do the audio thing."""
|
||||
for vc in ctx.channel.category.voice_channels:
|
||||
v = await vc.connect()
|
||||
tcardaudio = discord.PCMAudio(open("./assets/tcard.wav", "rb"))
|
||||
v.play(tcardaudio)
|
||||
while v.is_playing():
|
||||
time.sleep(1)
|
||||
await v.disconnect()
|
||||
else:
|
||||
"""Send a T-Card to the immediate channel if this is a generic channel."""
|
||||
await ctx.channel.send(embed=embed)
|
||||
await ctx.send(content=f'```You have invoked the T-Card in the channel {ctx.channel.name}.```', hidden=True)
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(TCardCommand(client))
|
Reference in New Issue
Block a user