有人帮我解决这个问题吗?我在yt里找不到任何教程;-;
DEFAULT_PREFIX = '$'
async def get_prefix(bot, message):
if not message.guild:
return commands.when_mentioned_or(DEFAULT_PREFIX)(bot, message)
prefix = await bot.db.fetch('SELECT prefix FROM guilds WHERE guild_id = $1', message.guild.id)
if len(prefix) == 0:
await bot.db.execute('INSERT INTO guilds("guild_id", prefix) VALUES ($1, $2)', message.guild.id, DEFAULT_PREFIX)
prefix = DEFAULT_PREFIX
else:
prefix = prefix[0].get("prefix")
return commands.when_mentioned_or(DEFAULT_PREFIX)(bot, message)
bot = commands.Bot(command_prefix= get_prefix)
async def create_db_pool():
bot.db = await asyncpg.create_pool(database= "captain hook", user = "postgres", password = "{password}")
bot.db = await asyncpg.create_pool(dsn='postgres://postgres:{password}@localhost:5432/captain hook')
print("Connection successful")
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Game(' $help! '))
print('Connected to bot: {}'.format(bot.user.name))
print('Bot ID: {}'.format(bot.user.id))
@bot.command(aliases=['setpre'])
@commands.has_permissions(administrator=True)
async def setprefix(ctx, new_prefix):
await bot.db.execute('UPDATE guilds SET prefix = $1 WHERE "guild_id" = $2', new_prefix, ctx.guild.id)
await ctx.send("Prefix was changed")
我得到了这个错误。有人帮我解决这个问题吗?我在yt里找不到任何教程;-;
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 5432), [Errno 99] Cannot assign requested address```
暂无答案!
目前还没有任何答案,快来回答吧!