public static async void SendMessage(ITextChannel channel, String message) { try { await channel.CreateMessage("🍋 " + message); } catch (DiscordHttpApiException) { } }
public override async void Execute(ITextChannel Channel, MessageEventArgs e, MatchCollection args) { try { await Channel.TriggerTypingIndicator(); await Channel.CreateMessage($"Hello I'm D.va and I'm created by {BotOwner.BotOwnerName + BotOwner.BotOwnerDiscrim}\nOwner ID: {BotOwner.BotOwnerID}\nServerID: {BotOwner.BotOwnerServerID}"); } catch (Exception ex) { Console.WriteLine(ex); } }
private static async void Gateway_OnMessageCreated(object sender, MessageEventArgs e) { Shard shard = e.Shard; DiscordMessage message = e.Message; if (message.Content == "ping") { ITextChannel textChannel = (ITextChannel)shard.Cache.Channels.Get(message.ChannelId); try { await textChannel.CreateMessage($"Pong!"); } catch (Exception) { /* Message failed to send... :( */ } } }
public static void ExecuteCommand(string key, MatchCollection content, MessageEventArgs e) { if (!CommandExists(key)) { return; } Shard shard = e.Shard; ITextChannel Channel = (ITextChannel)shard.Cache.GetChannel(e.Message.ChannelId); if (content.Count < (_commands[key]._args + 1) - (_commands[key]._optionalArgs)) { Channel.CreateMessage("Incorrect number of arguments."); return; } _commands[key].Execute(Channel, e, content); }
private static async Task <bool> send(ITextChannel textChannel, string message) { if (message == "") { return(false); } try { await textChannel.CreateMessage(message); Program.log.Enter($"Succesfully send message: '{message}'"); return(true); } catch (Exception e) { Program.log.Enter(e, $"trying to send message: '{message}'"); return(false); } }
//------------------------------------------------------------------------Gateway messages parsing private static async void Gateway_OnMessageCreated(object sender, MessageEventArgs e) { Shard shard = e.Shard; DiscordMessage message = e.Message; if (message.Author == shard.User) { // Ignore messages created by our bot. return; } if (message.ChannelId.Id.ToString() == ProgHelpers.channelid)//Prevent DM abuse, only react to messages sent on a set channel. { //-----------------------------------------------------------------------------------------INFO - VALMIS V1 if (message.Content == "!sniperiinoinfo" || message.Content == "!si") { ITextChannel textChannel = (ITextChannel)shard.Cache.Channels.Get(message.ChannelId); try { // Reply to the user who posted "!info". await textChannel.CreateMessage(new DiscordMessageDetails() .SetEmbed(new DiscordEmbedBuilder() .SetTitle($"kitsun8's Sniperiino") .SetFooter(ProgHelpers.version) .SetColor(DiscordColor.FromHexadecimal(0xff9933)) .AddField(ProgHelpers.txtdeveloper + " ", "kitsun8#4567", false) .AddField(ProgHelpers.txtpurpose + " ", ProgHelpers.txtpurpose2, false) .AddField(ProgHelpers.txtcommands + " ", "!sniperiinoinfo/si", false) )); Console.WriteLine($"!sniperiinoinfo - " + message.Author.Username + "-" + message.Author.Id + " --- " + DateTime.Now); } catch (Exception) { Console.WriteLine($"!sniperiinoinfo - EX -" + message.Author.Username + "-" + message.Author.Id + " --- " + DateTime.Now); } } } }
public override async void Execute(ITextChannel Channel, MessageEventArgs e, MatchCollection args) { await Channel.TriggerTypingIndicator(); await Channel.CreateMessage("pong"); }
public override async void Execute(ITextChannel Channel, MessageEventArgs e, MatchCollection args) { await Channel.CreateMessage("pong"); }