forked from viveksantayana/geas-bot
25 lines
962 B
Python
25 lines
962 B
Python
|
import yaml # YAML parser for Bot config files
|
||
|
import asyncio # Discord Py Dependency
|
||
|
import discord # Main Lib
|
||
|
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 # Slash Command features
|
||
|
import logging
|
||
|
# logger and handler
|
||
|
from dev import configFile, yaml_load, yaml_dump
|
||
|
|
||
|
##### Actions for the bot to take whenever the guild info or ownership are updated.
|
||
|
class on_guild_update(commands.Cog):
|
||
|
def __init__(self, client):
|
||
|
self.client = client
|
||
|
|
||
|
@commands.Cog.listener()
|
||
|
async def on_guild_update(self, before, after):
|
||
|
conf = yaml_load(configFile)
|
||
|
conf[str(after.id)]['name'] = after.name
|
||
|
conf[str(after.id)]['owner'] = after.owner_id
|
||
|
# Updates guild name and channel
|
||
|
yaml_dump(conf,configFile)
|
||
|
|
||
|
def setup(client):
|
||
|
client.add_cog(on_guild_update(client))
|