我想制作一个不和谐的机器人,它可以让我粘贴链接,然后它会返回包含在 linkvertise 下的链接。例如,在不和谐中,我会输入 *linkvertise https://google.com,它会向我发送一个 linkvertise 链接,让您完成所有 linkvertise 步骤,然后将您重定向到 https://google.com。基本上是一个linkvertise api?我没有包含任何代码,因为我真的不知道从哪里开始。因为我对API一无所知。
[Linkvertise website](https://linkvertise.net/dashboard)
[Discord.js](https://discord.js.org/#/)
[Discord.py](https://discordpy.readthedocs.io/en/latest/)
抱歉回复晚了,我正在处理这个问题,您需要生成一个密钥然后上传到他们的 api。
我一直在研究这个,而且很简单。您可以使用 Linkvertise API,该 API 位于“https://pypi.org/project/linkvertise/”。要使其正常工作,您需要访问他们的 GitHub 并下载他们的自定义库。
这是代码示例:
from linkvertise import LinkvertiseClient
# Defining the client
client = LinkvertiseClient()
# Creating a linkvertise url, and printing it
# 25565 is your linkvertise account id, and,
# google.com is link to monetize.
link = client.linkvertise(25565, "google.com")
print(link)
# Returns https://link-to.net/25565/832.3652483894998/dynamic?r=Z29vZ2xlLmNvbQ==
只需将“google.com”替换为您的首选链接,然后输入您的 Linkvertise 用户链接即可。
Discord 机器人模板
import discord
from discord.ext import commands
from linkvertise import LinkvertiseClient
bot = commands.Bot(command_prefix='!')
client = LinkvertiseClient()
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
@bot.command()
async def linkvertise(ctx, account_id: int, link: str):
generated_link = client.linkvertise(25565, "google.com")
await ctx.send(f"Generated Linkvertise link: {generated_link}")
bot.run(TOKEN')