|
@ -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) |
|
|
|
|
|
|
|
|