Search code examples
c#dsharp+

DSharpPlus edit channel topic


I'm trying to edit a text channel's topic. I tried using DiscordChannel.ModifyAsync but I have no idea what an Action<ChannelEditModel> is. How can I use it?


Solution

  • You can use a Lambda expression:

        public async Task ModifyChannel(CommandContext ctx, ulong id, [RemainingText] string topic)
        {
            var chn = await ctx.Client.GetChannelAsync(id);
            Action<ChannelEditModel> action = new(x => x.Topic = topic);
            await chn.ModifyAsync(action);
    
        }