Answer the question
In order to leave comments, you need to log in
Add the server ID and default prefix to the database - discord.py rewrite, PostgreSQL?
And an owl good day to all <з !!!
There is such a code, when the bot enters the server, the server ID and the default prefix should be entered in the database.
import discord
from discord.ext import commands
import os
import asyncpg, asyncio
PREFIX=str('.')
class prefix(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.Cog.listener()
async def on_guild_join(self, guild):
guildid= str(guild.id)
await self.bot.execute(f'INSERN INTO prefixDB (guild_id, prefix) VALUES ({guildid},{PREFIX})')
@commands.Cog.listener()
async def on_guild_remove(self):
pass
@commands.command()
@commands.has_permissions(administrator=True)
async def prefix(self, ctx, prefix):
pass
def setup(bot):
bot.add_cog(prefix(bot))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question