Python
2
Вклад в тег
def get_prefix(client, message):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
client = commands.Bot(command_prefix = get_prefix, intents = discord.Intents.all())
client.remove_command('help')
@client.event
async def on_guild_join(guild):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = 't.'
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
@client.event
async def on_guild_remove(guild):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
prefixes.pop[str(guild.id)] = 't.'
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
@client.command(aliases = ['prefix', 'refix'])
async def setprefix(ctx, prefixset):
if (not ctx.author.guild_permissions.manage_guild):
await ctx.send('Для этой команды требуются права **Управление сервером**')
return
if (prefixset == None):
prefixset = 't.'
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
prefixes[str(ctx.guild.id)] = prefixset
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
prefix = discord.Embed(description = f'Вы изменили префикс бота на `{prefixset}`', color = discord.Colour.random())
await ctx.send(embed = prefix)
@client.event
async def on_member_join(member):
print(f'{member.mention} has joined the server.')
channel = client.get_channel(919319558202998855)
join = discord.Embed(description=f"{member.mention} Welcome To The Club Buddy!", color=discord.Colour.random())
join.set_image(url="https://tenor.com/beeFU.gif")
await channel.send(embed=join)