Browse Source

News: Pass chanel by string id

Uh discord why? Apparently you can't pass announcements channel as arg
mail
Daniel Skýpala 1 year ago
parent
commit
7cbdafe88c
  1. 14
      hrochobot/cogs/news.py

14
hrochobot/cogs/news.py

@ -76,10 +76,18 @@ class News(commands.Cog):
)
@news.command(description="Adds a new secret role.")
@discord.option("channel", discord.TextChannel, description="Channel for sending news.")
async def set_channel(self, ctx, channel: discord.TextChannel):
@discord.option("channel_id", str, description="Id of the channel for sending news.")
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["news_channel"] = channel.id
news_json["news_channel"] = channel_id
data.dump_guild_data(ctx.guild.id, NEWS_JSON, news_json)
return await ctx.respond(f"News channel set to {channel.mention}.", ephemeral=True)

Loading…
Cancel
Save