Skip to content

Commit

Permalink
Auto stash before merge of "main" and "origin/main"
Browse files Browse the repository at this point in the history
  • Loading branch information
PSMGoossens committed Jun 16, 2021
1 parent 6ba89f8 commit 8314a6e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
7 changes: 3 additions & 4 deletions ISurvivalBot/Commands/AudioModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ public async Task JoinCmd()
{
var result = await _service.JoinAudio(Context.Guild, (Context.User as IVoiceState).VoiceChannel);
await Context.Message.AddReactionAsync(result == AudioServiceStatus.Succes ? CommonEmoij.OK : CommonEmoij.NOK);

/*Emoji custom = null;
foreach(var emoij in Context.Guild.Emotes)

foreach (var emoij in Context.Guild.Emotes)
{
Console.WriteLine($"Name: {emoij.Name} Url: {emoij.Url}, Id: {emoij.Id}");
}*/
}
await Context.Message.AddReactionAsync(CommonEmoij.BEREND);
}

Expand Down
23 changes: 23 additions & 0 deletions ISurvivalBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Discord.WebSocket;
using ISurvivalBot.Models;
using ISurvivalBot.Services;
using ISurvivalBot.Utils;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
Expand Down Expand Up @@ -60,6 +61,7 @@ public async Task MainAsync()
client.MessageReceived += Client_MessageReceived;
client.GuildMemberUpdated += Client_GuildMemberUpdated;
client.UserUpdated += Client_UserUpdated;
client.ReactionAdded += Client_ReactionAdded;
services.GetRequiredService<CommandService>().Log += LogAsync;

// this is where we get the Token value from the configuration file, and start the bot
Expand Down Expand Up @@ -87,6 +89,11 @@ public async Task MainAsync()
}
}

private async Task Client_ReactionAdded(Cacheable<IUserMessage, ulong> messageFromUser, ISocketMessageChannel message, SocketReaction argument)
{
//throw new NotImplementedException();
}

private async Task Client_GuildMembersDownloaded(SocketGuild guild)
{
_logger.LogInformation($"Downloaded Guild {guild.Name} becomes available, with id: {guild.Id}");
Expand Down Expand Up @@ -159,6 +166,22 @@ private async Task Client_MessageReceived(SocketMessage message)
var counter = await commandCountService.CountAndIncrementCommandByUser("meh", (long)message.Author.Id, wordCount);
await message.Channel.SendMessageAsync($"{message.Author.Username} heeft {counter} schaapjes geteld!");
}
else if (messageText.Contains("sad") || messageText.Contains("verdrietig"))
{
await message.AddReactionAsync(CommonEmoij.PANDA_CRY);
}
else if (messageText.Contains("boos") || messageText.Contains("angry"))
{
await message.AddReactionAsync(CommonEmoij.PANDA_ANGRY);
}
else if (messageText.Contains("slapen") || messageText.Contains("slaap"))
{
await message.AddReactionAsync(CommonEmoij.PANDA_SLEEP);
}
else if (messageText.Contains("autisme") || messageText.Contains("autism"))
{
await message.AddReactionAsync(CommonEmoij.AUTISM);
}
}

private int wordDuplication(string text, string word)
Expand Down
7 changes: 5 additions & 2 deletions ISurvivalBot/Services/CommandHandlingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -16,11 +17,13 @@ public class CommandHandlingService
private readonly CommandService _commands;
private readonly DiscordSocketClient _discord;
private readonly IServiceProvider _services;
private readonly ILogger<CommandHandlingService> _logger;

public CommandHandlingService(IServiceProvider services)
public CommandHandlingService(IServiceProvider services, ILogger<CommandHandlingService> logger)
{
_commands = services.GetRequiredService<CommandService>();
_discord = services.GetRequiredService<DiscordSocketClient>();
_logger = logger;
_services = services;

// Hook CommandExecuted to handle post-command-execution logic.
Expand Down Expand Up @@ -49,7 +52,7 @@ public async Task MessageReceivedAsync(SocketMessage rawMessage)
// for a more traditional command format like !help.
//if (!message.HasMentionPrefix(_discord.CurrentUser, ref argPos)) return;
if (!message.HasCharPrefix('!', ref argPos)) return;

_logger.LogInformation($"From: {rawMessage.Author.Username} on channel: {rawMessage.Channel.Name}, message: {rawMessage.Content}.");
var context = new SocketCommandContext(_discord, message);
// Perform the execution of the command. In this method,
// the command service will perform precondition and parsing check
Expand Down
11 changes: 9 additions & 2 deletions ISurvivalBot/Utils/CommonEmoij.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ public static class CommonEmoij
public static Emoji NOK = new Emoji("❌");

public static Emote BEREND = Emote.Parse("<:berend:821110556667936838>");


public static Emote KING = Emote.Parse("<:king:821350847211896903>");
public static Emote AUTISM = Emote.Parse("<:autism:828935267976216577>");
public static Emote PANDA_CRY = Emote.Parse("<:panda_cry:829681153317011487>");
public static Emote PANDA_ANGRY = Emote.Parse("<:panda_angry:829681335601594389>");
public static Emote PANDA_SLEEP = Emote.Parse("<:panda_sleep:829681500029976576>");
public static Emote NEGATIVE = Emote.Parse("<:negative:829681658583842817>");
public static Emote OBEY = Emote.Parse("<:obey:829682075601862676>");
public static Emote SARCASM = Emote.Parse("<:sarcasm:829682227621003264>");
public static Emote LAME = Emote.Parse("<:lame:828935234045083680>");
}
}

0 comments on commit 8314a6e

Please sign in to comment.