亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 DIscord.py 取消邀請鏈接

如何使用 DIscord.py 取消邀請鏈接

慕森卡 2023-01-04 11:14:18
有沒有一種方法可以使用 Discord.PY 創建邀請鏈接?我的代碼如下/import discordfrom discord.ext import commandsimport pickleclient = commands.Bot("-")@client.eventasync def on_message(message):    message.content.lower()    if message.author == client.user:        return#checks if the bot it running.    if message.content.startswith("message"):        await message.channel.send("hello there")#tells the user where they are.    if message.content.startswith("whereami"):        await message.channel.send(f"You are in {message.guild.name} " + \            f"in the {message.channel.mention} channel!")    ##Creates Instant Invite    if message.content.startswith("createinvite"):        await create_invite(*, reason=None, **fields)        await message.channel.send("Here is an instant invite to your server: " + link)client.run('token')如果需要,讓我知道您需要什么其他信息,如果我需要編輯它以使其更清楚。如果我需要導入其他任何東西,請告知我需要哪些庫。
查看完整描述

2 回答

?
繁華開滿天機

TA貢獻1816條經驗 獲得超4個贊

@client.event

async def on_message(message):

    if message.content.lower().startswith("createinvite"):

        invite = await message.channel.create_invite()

        await message.channel.send(f"Here's your invite: {invite}")

并使用命令裝飾器:


@client.command()

async def createinvite(ctx):

    invite = await ctx.channel.create_invite()

    await ctx.send(f"Here's your invite: {invite}")

參考:


查看完整回答
反對 回復 2023-01-04
?
GCT1015

TA貢獻1827條經驗 獲得超4個贊

有沒有辦法創建一個,但只能使用一次?我有一個 on_message 事件:如果有人輸入 xy,機器人就會踢他。在踢球之后我想給他發一條 xy 消息。(準備好了)然后我想給他發一個邀請



查看完整回答
反對 回復 2023-01-04
  • 2 回答
  • 0 關注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號