Discord python unban member










2















Ok, my ban command works ban(member), however when doing the same except using unban(member) the output is always that the user wasn't found.
Here's the code of the ban command, what's the correct usage of the unban command?



@commands.command(pass_context = True)
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member:discord.Member=None):
"""Bans a member."""
if not member:
await self.bot.say("Who would you like me to ban, 0.mention?".format(ctx.message.author))
pass
await self.bot.ban(member)
await self.bot.say(f"member.mention got banned, what a shame...")
print(colored('moderation.clf: ', 'blue'), colored('Banned member', 'white'))









share|improve this question






















  • unban takes a User, not a Member. This is because when you ban someone from the server, they aren't a Member anymore. You need to get their User object instead.

    – Patrick Haugh
    Nov 13 '18 at 23:51











  • Ok! does the same happen with await server_voice_state(user=member, deafen=True) and await server_voice_state(user=member, mute=True)?

    – Daniel Casares
    Nov 14 '18 at 0:15











  • server_voice_state has no user parameter. It has a member parameter

    – Patrick Haugh
    Nov 14 '18 at 0:24















2















Ok, my ban command works ban(member), however when doing the same except using unban(member) the output is always that the user wasn't found.
Here's the code of the ban command, what's the correct usage of the unban command?



@commands.command(pass_context = True)
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member:discord.Member=None):
"""Bans a member."""
if not member:
await self.bot.say("Who would you like me to ban, 0.mention?".format(ctx.message.author))
pass
await self.bot.ban(member)
await self.bot.say(f"member.mention got banned, what a shame...")
print(colored('moderation.clf: ', 'blue'), colored('Banned member', 'white'))









share|improve this question






















  • unban takes a User, not a Member. This is because when you ban someone from the server, they aren't a Member anymore. You need to get their User object instead.

    – Patrick Haugh
    Nov 13 '18 at 23:51











  • Ok! does the same happen with await server_voice_state(user=member, deafen=True) and await server_voice_state(user=member, mute=True)?

    – Daniel Casares
    Nov 14 '18 at 0:15











  • server_voice_state has no user parameter. It has a member parameter

    – Patrick Haugh
    Nov 14 '18 at 0:24













2












2








2








Ok, my ban command works ban(member), however when doing the same except using unban(member) the output is always that the user wasn't found.
Here's the code of the ban command, what's the correct usage of the unban command?



@commands.command(pass_context = True)
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member:discord.Member=None):
"""Bans a member."""
if not member:
await self.bot.say("Who would you like me to ban, 0.mention?".format(ctx.message.author))
pass
await self.bot.ban(member)
await self.bot.say(f"member.mention got banned, what a shame...")
print(colored('moderation.clf: ', 'blue'), colored('Banned member', 'white'))









share|improve this question














Ok, my ban command works ban(member), however when doing the same except using unban(member) the output is always that the user wasn't found.
Here's the code of the ban command, what's the correct usage of the unban command?



@commands.command(pass_context = True)
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member:discord.Member=None):
"""Bans a member."""
if not member:
await self.bot.say("Who would you like me to ban, 0.mention?".format(ctx.message.author))
pass
await self.bot.ban(member)
await self.bot.say(f"member.mention got banned, what a shame...")
print(colored('moderation.clf: ', 'blue'), colored('Banned member', 'white'))






python python-3.x discord discord.py






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 23:05









Daniel CasaresDaniel Casares

497




497












  • unban takes a User, not a Member. This is because when you ban someone from the server, they aren't a Member anymore. You need to get their User object instead.

    – Patrick Haugh
    Nov 13 '18 at 23:51











  • Ok! does the same happen with await server_voice_state(user=member, deafen=True) and await server_voice_state(user=member, mute=True)?

    – Daniel Casares
    Nov 14 '18 at 0:15











  • server_voice_state has no user parameter. It has a member parameter

    – Patrick Haugh
    Nov 14 '18 at 0:24

















  • unban takes a User, not a Member. This is because when you ban someone from the server, they aren't a Member anymore. You need to get their User object instead.

    – Patrick Haugh
    Nov 13 '18 at 23:51











  • Ok! does the same happen with await server_voice_state(user=member, deafen=True) and await server_voice_state(user=member, mute=True)?

    – Daniel Casares
    Nov 14 '18 at 0:15











  • server_voice_state has no user parameter. It has a member parameter

    – Patrick Haugh
    Nov 14 '18 at 0:24
















unban takes a User, not a Member. This is because when you ban someone from the server, they aren't a Member anymore. You need to get their User object instead.

– Patrick Haugh
Nov 13 '18 at 23:51





unban takes a User, not a Member. This is because when you ban someone from the server, they aren't a Member anymore. You need to get their User object instead.

– Patrick Haugh
Nov 13 '18 at 23:51













Ok! does the same happen with await server_voice_state(user=member, deafen=True) and await server_voice_state(user=member, mute=True)?

– Daniel Casares
Nov 14 '18 at 0:15





Ok! does the same happen with await server_voice_state(user=member, deafen=True) and await server_voice_state(user=member, mute=True)?

– Daniel Casares
Nov 14 '18 at 0:15













server_voice_state has no user parameter. It has a member parameter

– Patrick Haugh
Nov 14 '18 at 0:24





server_voice_state has no user parameter. It has a member parameter

– Patrick Haugh
Nov 14 '18 at 0:24












1 Answer
1






active

oldest

votes


















1














Since members represent users inside a server you can't have a member instance for a user that is currently banned. You have to use the User instance which is not server-specific to unban, for example await self.bot.unban(server, user) where server is of type discord.Server and user of type discord.User.






share|improve this answer























  • I've already done this, but i still appreciate this ^^

    – Daniel Casares
    Nov 18 '18 at 21:02










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290828%2fdiscord-python-unban-member%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Since members represent users inside a server you can't have a member instance for a user that is currently banned. You have to use the User instance which is not server-specific to unban, for example await self.bot.unban(server, user) where server is of type discord.Server and user of type discord.User.






share|improve this answer























  • I've already done this, but i still appreciate this ^^

    – Daniel Casares
    Nov 18 '18 at 21:02















1














Since members represent users inside a server you can't have a member instance for a user that is currently banned. You have to use the User instance which is not server-specific to unban, for example await self.bot.unban(server, user) where server is of type discord.Server and user of type discord.User.






share|improve this answer























  • I've already done this, but i still appreciate this ^^

    – Daniel Casares
    Nov 18 '18 at 21:02













1












1








1







Since members represent users inside a server you can't have a member instance for a user that is currently banned. You have to use the User instance which is not server-specific to unban, for example await self.bot.unban(server, user) where server is of type discord.Server and user of type discord.User.






share|improve this answer













Since members represent users inside a server you can't have a member instance for a user that is currently banned. You have to use the User instance which is not server-specific to unban, for example await self.bot.unban(server, user) where server is of type discord.Server and user of type discord.User.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 18 '18 at 17:53









MinnMinn

676115




676115












  • I've already done this, but i still appreciate this ^^

    – Daniel Casares
    Nov 18 '18 at 21:02

















  • I've already done this, but i still appreciate this ^^

    – Daniel Casares
    Nov 18 '18 at 21:02
















I've already done this, but i still appreciate this ^^

– Daniel Casares
Nov 18 '18 at 21:02





I've already done this, but i still appreciate this ^^

– Daniel Casares
Nov 18 '18 at 21:02

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290828%2fdiscord-python-unban-member%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党