mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
25 lines
747 B
C#
25 lines
747 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using DSharpPlus.Entities;
|
|
|
|
namespace CompatBot.Utils
|
|
{
|
|
public static class DiscordMessageExtensions
|
|
{
|
|
public static Task<DiscordMessage> UpdateOrCreateMessageAsync(this DiscordMessage message, DiscordChannel channel, string content = null, bool tts = false, DiscordEmbed embed = null)
|
|
{
|
|
try
|
|
{
|
|
if (message == null)
|
|
return channel.SendMessageAsync(content, tts, embed);
|
|
return message.ModifyAsync(content, embed);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Config.Log.Error(e);
|
|
}
|
|
return Task.FromResult((DiscordMessage)null);
|
|
}
|
|
}
|
|
}
|