Example #1
0
    public async ValueTask LogMessage(MessageContext ctx, PKMessage proxiedMessage, Message trigger,
                                      Message hookMessage, string oldContent = null)
    {
        var logChannelId = await GetAndCheckLogChannel(ctx, trigger, proxiedMessage);

        if (logChannelId == null)
        {
            return;
        }

        var triggerChannel = await _cache.GetChannel(proxiedMessage.Channel);

        var system = await _repo.GetSystem(ctx.SystemId.Value);

        var member = await _repo.GetMember(proxiedMessage.Member !.Value);

        // Send embed!
        var embed = _embed.CreateLoggedMessageEmbed(trigger, hookMessage, system.Hid, member, triggerChannel.Name,
                                                    oldContent);
        var url =
            $"https://discord.com/channels/{proxiedMessage.Guild.Value}/{proxiedMessage.Channel}/{proxiedMessage.Mid}";
        await _rest.CreateMessage(logChannelId.Value, new MessageRequest { Content = url, Embeds = new[] { embed } });
    }