Discord Python Change region
sorry if this is such a DUMB question but i'd like to know what's wrong with this command, as i'm getting discord.ext.commands.errors.BadArgument: Converting to "EnumMeta" failed.
as an error. What does the error exactly mean and what would be the correct command?
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, region=discord.ServerRegion):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
await self.bot.edit_server(region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
python-3.x discord discord.py
add a comment |
sorry if this is such a DUMB question but i'd like to know what's wrong with this command, as i'm getting discord.ext.commands.errors.BadArgument: Converting to "EnumMeta" failed.
as an error. What does the error exactly mean and what would be the correct command?
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, region=discord.ServerRegion):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
await self.bot.edit_server(region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
python-3.x discord discord.py
add a comment |
sorry if this is such a DUMB question but i'd like to know what's wrong with this command, as i'm getting discord.ext.commands.errors.BadArgument: Converting to "EnumMeta" failed.
as an error. What does the error exactly mean and what would be the correct command?
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, region=discord.ServerRegion):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
await self.bot.edit_server(region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
python-3.x discord discord.py
sorry if this is such a DUMB question but i'd like to know what's wrong with this command, as i'm getting discord.ext.commands.errors.BadArgument: Converting to "EnumMeta" failed.
as an error. What does the error exactly mean and what would be the correct command?
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, region=discord.ServerRegion):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
await self.bot.edit_server(region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
python-3.x discord discord.py
python-3.x discord discord.py
asked Nov 12 at 23:32
Daniel Casares
376
376
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There's no built in converter for ServerRegion
. Fortunately, we can make one that gets the job done fairly easily by using the fact that ServerRegion('amsterdam')
is equivalent to ServerRegion.amsterdam
:
region_converter = lambda region: discord.ServerRegion('-'.join(region.lower().split()))
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, *, region: region_converter=None):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
return
await self.bot.edit_server(ctx.message.server, region=region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
Thanks for the answer!discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ServerRegion' object has no attribute 'icon'
shows up, however :(
– Daniel Casares
Nov 13 at 3:33
@DanielCasares Try changing youredit_server
line toawait self.bot.edit_server(ctx.message.server, region=region)
. You should also add areturn
in theif
, so you don't try to edit the server ifregion
isn't set.
– Patrick Haugh
Nov 13 at 3:37
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.server' has no attribute 'region'
am i doing something wrong?
– Daniel Casares
Nov 13 at 3:40
@DanielCasares It's working for me. What line is that error on?
– Patrick Haugh
Nov 13 at 3:48
await self.bot.say("Ok! We're now in " + server.region + " :smiley:") AttributeError: module 'discord.server' has no attribute 'region'
This is giving the error, your code works fine though, thank you so much! I've been going crazy because of this
– Daniel Casares
Nov 13 at 3:58
|
show 3 more comments
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271632%2fdiscord-python-change-region%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
There's no built in converter for ServerRegion
. Fortunately, we can make one that gets the job done fairly easily by using the fact that ServerRegion('amsterdam')
is equivalent to ServerRegion.amsterdam
:
region_converter = lambda region: discord.ServerRegion('-'.join(region.lower().split()))
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, *, region: region_converter=None):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
return
await self.bot.edit_server(ctx.message.server, region=region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
Thanks for the answer!discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ServerRegion' object has no attribute 'icon'
shows up, however :(
– Daniel Casares
Nov 13 at 3:33
@DanielCasares Try changing youredit_server
line toawait self.bot.edit_server(ctx.message.server, region=region)
. You should also add areturn
in theif
, so you don't try to edit the server ifregion
isn't set.
– Patrick Haugh
Nov 13 at 3:37
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.server' has no attribute 'region'
am i doing something wrong?
– Daniel Casares
Nov 13 at 3:40
@DanielCasares It's working for me. What line is that error on?
– Patrick Haugh
Nov 13 at 3:48
await self.bot.say("Ok! We're now in " + server.region + " :smiley:") AttributeError: module 'discord.server' has no attribute 'region'
This is giving the error, your code works fine though, thank you so much! I've been going crazy because of this
– Daniel Casares
Nov 13 at 3:58
|
show 3 more comments
There's no built in converter for ServerRegion
. Fortunately, we can make one that gets the job done fairly easily by using the fact that ServerRegion('amsterdam')
is equivalent to ServerRegion.amsterdam
:
region_converter = lambda region: discord.ServerRegion('-'.join(region.lower().split()))
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, *, region: region_converter=None):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
return
await self.bot.edit_server(ctx.message.server, region=region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
Thanks for the answer!discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ServerRegion' object has no attribute 'icon'
shows up, however :(
– Daniel Casares
Nov 13 at 3:33
@DanielCasares Try changing youredit_server
line toawait self.bot.edit_server(ctx.message.server, region=region)
. You should also add areturn
in theif
, so you don't try to edit the server ifregion
isn't set.
– Patrick Haugh
Nov 13 at 3:37
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.server' has no attribute 'region'
am i doing something wrong?
– Daniel Casares
Nov 13 at 3:40
@DanielCasares It's working for me. What line is that error on?
– Patrick Haugh
Nov 13 at 3:48
await self.bot.say("Ok! We're now in " + server.region + " :smiley:") AttributeError: module 'discord.server' has no attribute 'region'
This is giving the error, your code works fine though, thank you so much! I've been going crazy because of this
– Daniel Casares
Nov 13 at 3:58
|
show 3 more comments
There's no built in converter for ServerRegion
. Fortunately, we can make one that gets the job done fairly easily by using the fact that ServerRegion('amsterdam')
is equivalent to ServerRegion.amsterdam
:
region_converter = lambda region: discord.ServerRegion('-'.join(region.lower().split()))
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, *, region: region_converter=None):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
return
await self.bot.edit_server(ctx.message.server, region=region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
There's no built in converter for ServerRegion
. Fortunately, we can make one that gets the job done fairly easily by using the fact that ServerRegion('amsterdam')
is equivalent to ServerRegion.amsterdam
:
region_converter = lambda region: discord.ServerRegion('-'.join(region.lower().split()))
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, *, region: region_converter=None):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
return
await self.bot.edit_server(ctx.message.server, region=region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
edited Nov 13 at 3:47
answered Nov 13 at 2:06
Patrick Haugh
27.1k82546
27.1k82546
Thanks for the answer!discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ServerRegion' object has no attribute 'icon'
shows up, however :(
– Daniel Casares
Nov 13 at 3:33
@DanielCasares Try changing youredit_server
line toawait self.bot.edit_server(ctx.message.server, region=region)
. You should also add areturn
in theif
, so you don't try to edit the server ifregion
isn't set.
– Patrick Haugh
Nov 13 at 3:37
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.server' has no attribute 'region'
am i doing something wrong?
– Daniel Casares
Nov 13 at 3:40
@DanielCasares It's working for me. What line is that error on?
– Patrick Haugh
Nov 13 at 3:48
await self.bot.say("Ok! We're now in " + server.region + " :smiley:") AttributeError: module 'discord.server' has no attribute 'region'
This is giving the error, your code works fine though, thank you so much! I've been going crazy because of this
– Daniel Casares
Nov 13 at 3:58
|
show 3 more comments
Thanks for the answer!discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ServerRegion' object has no attribute 'icon'
shows up, however :(
– Daniel Casares
Nov 13 at 3:33
@DanielCasares Try changing youredit_server
line toawait self.bot.edit_server(ctx.message.server, region=region)
. You should also add areturn
in theif
, so you don't try to edit the server ifregion
isn't set.
– Patrick Haugh
Nov 13 at 3:37
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.server' has no attribute 'region'
am i doing something wrong?
– Daniel Casares
Nov 13 at 3:40
@DanielCasares It's working for me. What line is that error on?
– Patrick Haugh
Nov 13 at 3:48
await self.bot.say("Ok! We're now in " + server.region + " :smiley:") AttributeError: module 'discord.server' has no attribute 'region'
This is giving the error, your code works fine though, thank you so much! I've been going crazy because of this
– Daniel Casares
Nov 13 at 3:58
Thanks for the answer!
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ServerRegion' object has no attribute 'icon'
shows up, however :(– Daniel Casares
Nov 13 at 3:33
Thanks for the answer!
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ServerRegion' object has no attribute 'icon'
shows up, however :(– Daniel Casares
Nov 13 at 3:33
@DanielCasares Try changing your
edit_server
line to await self.bot.edit_server(ctx.message.server, region=region)
. You should also add a return
in the if
, so you don't try to edit the server if region
isn't set.– Patrick Haugh
Nov 13 at 3:37
@DanielCasares Try changing your
edit_server
line to await self.bot.edit_server(ctx.message.server, region=region)
. You should also add a return
in the if
, so you don't try to edit the server if region
isn't set.– Patrick Haugh
Nov 13 at 3:37
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.server' has no attribute 'region'
am i doing something wrong?– Daniel Casares
Nov 13 at 3:40
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.server' has no attribute 'region'
am i doing something wrong?– Daniel Casares
Nov 13 at 3:40
@DanielCasares It's working for me. What line is that error on?
– Patrick Haugh
Nov 13 at 3:48
@DanielCasares It's working for me. What line is that error on?
– Patrick Haugh
Nov 13 at 3:48
await self.bot.say("Ok! We're now in " + server.region + " :smiley:") AttributeError: module 'discord.server' has no attribute 'region'
This is giving the error, your code works fine though, thank you so much! I've been going crazy because of this– Daniel Casares
Nov 13 at 3:58
await self.bot.say("Ok! We're now in " + server.region + " :smiley:") AttributeError: module 'discord.server' has no attribute 'region'
This is giving the error, your code works fine though, thank you so much! I've been going crazy because of this– Daniel Casares
Nov 13 at 3:58
|
show 3 more comments
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271632%2fdiscord-python-change-region%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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