Я использую python, чтобы мой бот генерировал мгновенное приглашение.
Однако у меня проблемы с поиском и созданием мгновенного приглашения.
Вот мой код:
from progress.bar import Bar # Only to show a loading bar, all imports are successful.
print("Loading...")
imports = [
'import os',
'import sys',
'import asyncio',
'import discord',
'import random',
'import functools',
'import time as tm',
'from discord.ext import commands',
'from discord.ext.commands import when_mentioned'
]
bar = Bar('', max=len(imports))
for i in range(0, len(imports)):
exec(str(imports[i]))
bar.next()
bar.finish()
BOT_PREFIX = "!"
BOT_TOKEN = 'token'
OWNER_ID = int("owner's user id for support")
class Stuff(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def create_invite(self, ctx):
"""- Create instant invite"""
link = await discord.abc.GuildChannel.create_invite(self, max_age='300')
await ctx.send("Here is an instant invite to your server: "+link)
Когда команда выполняется в разногласии, я получаю эту ошибку:
discord.ext.commands.errors.CommandInvokeError: Команда вызвала исключение: AttributeError: У объекта 'Stuff' нет атрибута '_state'
Как правильно создать мгновенное приглашение?