如何返回haste()的值:返回?

时间:2020-04-07 20:37:41

标签: python discord.py

我需要找到如何在discord.py机器人中将return await response.text()返回到控制台。 感谢您的帮助!我需要它来获取hastebin的链接,然后可以在不和谐的频道中发送它。

代码:

警戒线:


async def main():
    url = "https://www.hastebin.com/documents"
    async with aiohttp.ClientSession() as session:
        async with session.post(url, data="bruhmoment") as response:
            return await response.text()

主文件:

from discord.ext import commands
import haste

token = ""
bot = commands.Bot(command_prefix="+", status=discord.Status.do_not_disturb)

@bot.event
async def on_ready():
    print('Logged in as {0.user}'.format(bot))

@bot.event
async def on_guild_join(guild):
    print("Joined guild: ", guild)

@bot.event
async def on_guild_remove(guild):
    print("Removed from guild: ", guild)


@bot.command()
async def presence(ctx):

    content_presence = ctx.message.content[9:]
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=content_presence))

@bot.command()
async def hasteit(ctx):
    await haste.main()



bot.run(token)

0 个答案:

没有答案