29 lines
935 B
Python
29 lines
935 B
Python
import nextcord
|
|
from nextcord.ext import commands
|
|
|
|
from userinfo import parsedinfo
|
|
|
|
class LogCommands(commands.Cog):
|
|
def __init__(self, bot):
|
|
self.client = bot
|
|
|
|
@commands.command(description="Set a log channel for this server.", usage={"#channel"})
|
|
@commands.has_permissions(administrator = True)
|
|
async def setlogchannel(self, ctx: nextcord.Message, channel: nextcord.TextChannel):
|
|
print(ctx.author, channel)
|
|
|
|
guildInfo = await parsedinfo.find("guild", "id", ctx.guild.id)
|
|
|
|
if not guildInfo:
|
|
info = await parsedinfo.get("guild")
|
|
info.append({"id": ctx.guild.id, "log-channel": 0})
|
|
guildInfo = await parsedinfo.find("guild", "id", ctx.guild.id)
|
|
|
|
guildInfo["log-channel"] = channel.id
|
|
|
|
await parsedinfo.flush() # Yes
|
|
|
|
await ctx.reply(f"Changed log channel to {channel.mention}")
|
|
|
|
def setup(bot):
|
|
bot.add_cog(LogCommands(bot)) |