Improve Brother messages

This commit is contained in:
Yohann D'ANELLO 2021-11-08 14:01:43 +01:00
parent 0699c0f474
commit a072ea3dd0
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 33 additions and 12 deletions

View File

@ -1 +1,2 @@
discord_token: insert_token_here
guild: insert_guild_id_here

View File

@ -251,25 +251,36 @@ async def on_ready():
philia, overwrite=PermissionOverwrite(read_message_history=True, read_messages=True)
)
if not config.left_channel:
channel: TextChannel = await secret_category.create_text_channel("left")
config.left_channel = channel.id
if not config.brother_channel:
channel: TextChannel = await secret_category.create_text_channel("doliprane")
config.brother_channel = channel.id
config.save()
left_channel: TextChannel = await guild.fetch_channel(config.left_channel)
if not left_channel:
config.left_channel = None
brother_channel: TextChannel = await guild.fetch_channel(config.brother_channel)
if not brother_channel:
config.brother_channel = None
return await on_ready()
await left_channel.edit(name="left", category=secret_category, position=1,
await brother_channel.edit(name="doliprane", category=secret_category, position=1,
topic="Des voix dans la tête ...")
await left_channel.set_permissions(
await brother_channel.set_permissions(
guild.default_role, overwrite=PermissionOverwrite(read_message_history=False, read_messages=False)
)
await left_channel.set_permissions(
await brother_channel.set_permissions(
philia, overwrite=PermissionOverwrite(read_message_history=True, read_messages=True)
)
brother_channel_webhook = None
if config.brother_channel_webhook is not None:
try:
brother_channel_webhook = await bot.fetch_webhook(config.brother_channel_webhook)
except disnake.HTTPException | disnake.NotFound | disnake.Forbidden:
pass
if brother_channel_webhook is None:
brother_channel_webhook = await brother_channel.create_webhook(name="???")
config.brother_channel_webhook = brother_channel_webhook.id
config.save()
if not config.backdoor_channel:
channel: TextChannel = await secret_category.create_text_channel("backdoor")
config.backdoor_channel = channel.id
@ -293,13 +304,21 @@ async def on_ready():
config.save()
@bot.command()
@bot.command(help="Envoyer un message en tant qu'Orochi.")
@commands.has_permissions(administrator=True)
async def send(ctx: commands.Context, *, message: str):
await ctx.message.delete()
await ctx.send(message)
@bot.command(help="Envoyer un message à Philia par la pensée en tant que Brother.")
@commands.has_permissions(administrator=True)
async def brother(ctx: commands.Context, *, message: str):
webhook = await bot.fetch_webhook(bot.config.brother_channel_webhook)
await webhook.send(message)
await ctx.message.reply("Message envoyé.")
@bot.command()
async def vote(ctx: commands.Context):
view = Confirm()

View File

@ -25,7 +25,8 @@ class Config:
vote_channels: dict[str, int] = field(default_factory=dict)
backdoor_channel: int = None
telepathy_channel: int = None
left_channel: int = None
brother_channel: int = None
brother_channel_webhook: int = None
player_roles: dict[str, int] = field(default_factory=dict)
@classmethod