Answer the question
In order to leave comments, you need to log in
How to simplify code in Embed?
I tried to write a code so that when the >usercheck command is given, the bot would display a message where it shows information about the user (not through mentions, but through NickName) through the embed. Is it possible to somehow simplify and make it so that the bot finds a recorded nickname somewhere and gives information on it recorded in the code.
client.command(pass_context = True)
@commands.has_permissions(administrator = True)
async def checkuser_user(ctx):
await ctx.channel.send('Please, wait')
PREFIX = '>'
emb = discord.Embed(title = 'User info')
emb.add_field(name = '{}Bans'.format(PREFIX),value = '0')
emb.add_field(name = '{}Kicks'.format(PREFIX),value = '0')
emb.add_field(name = '{}Warns'.format(PREFIX),value = '1/3')
emb.add_field(name = '{}Ban reason: '.format(PREFIX),value = 'None')
emb.add_field(name = '{}Role history'.format(PREFIX),value = 'Verify.')
await ctx.send(embed = emb)
Answer the question
In order to leave comments, you need to log in
I made such a solution for you, but this is not a panacea and it will not find
nicknames like: "Nick Name" .
But for that it will work fine for nicknames like: "Nickname" .
@bot.command(pass_context = True)
@commands.has_permissions(administrator = True)
async def checkuser_user(ctx, arg):
await ctx.channel.send('Please, wait')
# Пребираем все пользователей на сервере.
for guild in bot.guilds:
for member in guild.members:
# Сравниваем введенный ник и ники тех кто есть на сервере, убирая идентификатор из ника "#9999"
if arg == str(member)[0:-5]:
PREFIX = '>'
emb = discord.Embed(title = 'User info')
emb.add_field(name = '{}Bans'.format(PREFIX),value = '0')
emb.add_field(name = '{}Kicks'.format(PREFIX),value = '0')
emb.add_field(name = '{}Warns'.format(PREFIX),value = '1/3')
emb.add_field(name = '{}Ban reason: '.format(PREFIX),value = 'None')
emb.add_field(name = '{}Role history'.format(PREFIX),value = 'Verify.')
await ctx.send(embed = emb)
from fuzzywuzzy import fuzz
@bot.command(pass_context = True)
@commands.has_permissions(administrator = True)
async def checkuser_user(ctx, arg):
await ctx.channel.send('Please, wait')
# Пребираем все пользователей на сервере.
for guild in bot.guilds:
for member in guild.members:
# Сравниваем введенный ник и ники полученные из списка.
if fuzz.partial_ratio(arg, str(member)[0:-5]) > 95: # <- Процент при котором совпадение "успешно".
PREFIX = '>'
emb = discord.Embed(title = 'User info')
emb.add_field(name = '{}Bans'.format(PREFIX),value = '0')
emb.add_field(name = '{}Kicks'.format(PREFIX),value = '0')
emb.add_field(name = '{}Warns'.format(PREFIX),value = '1/3')
emb.add_field(name = '{}Ban reason: '.format(PREFIX),value = 'None')
emb.add_field(name = '{}Role history'.format(PREFIX),value = 'Verify.')
await ctx.send(embed = emb)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question