News: Pass chanel by string id
Uh discord why? Apparently you can't pass announcements channel as arg
This commit is contained in:
parent
885c397a16
commit
7cbdafe88c
1 changed files with 11 additions and 3 deletions
|
@ -76,10 +76,18 @@ class News(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
@news.command(description="Adds a new secret role.")
|
@news.command(description="Adds a new secret role.")
|
||||||
@discord.option("channel", discord.TextChannel, description="Channel for sending news.")
|
@discord.option("channel_id", str, description="Id of the channel for sending news.")
|
||||||
async def set_channel(self, ctx, channel: discord.TextChannel):
|
async def set_channel(self, ctx, channel_id: str):
|
||||||
|
try:
|
||||||
|
channel_id = int(channel_id)
|
||||||
|
except ValueError:
|
||||||
|
return await ctx.respond(f"Channel id must be int.", ephemeral=True)
|
||||||
|
|
||||||
|
if not (channel := get(ctx.guild.channels, id=channel_id)):
|
||||||
|
return await ctx.respond(f"No channel with id ``{channel_id}``.", ephemeral=True)
|
||||||
|
|
||||||
news_json = data.load_guild_data(ctx.guild.id, NEWS_JSON)
|
news_json = data.load_guild_data(ctx.guild.id, NEWS_JSON)
|
||||||
news_json["news_channel"] = channel.id
|
news_json["news_channel"] = channel_id
|
||||||
data.dump_guild_data(ctx.guild.id, NEWS_JSON, news_json)
|
data.dump_guild_data(ctx.guild.id, NEWS_JSON, news_json)
|
||||||
return await ctx.respond(f"News channel set to {channel.mention}.", ephemeral=True)
|
return await ctx.respond(f"News channel set to {channel.mention}.", ephemeral=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue