Skip to content

Commit

Permalink
Summary added
Browse files Browse the repository at this point in the history
  • Loading branch information
PSMGoossens committed Jun 17, 2021
1 parent fb42000 commit 9642f4d
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 82 deletions.
10 changes: 8 additions & 2 deletions ISurvivalBot/Commands/AudioModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public AudioModule(AudioService service)
// You *MUST* mark these commands with 'RunMode.Async'
// otherwise the bot will not respond until the Task times out.
[Command("joins", RunMode = RunMode.Async)]
[Summary("Joins your current Voice Chat Channel")]
[RequireContext(ContextType.Guild, ErrorMessage = "This command is only possible via a public channel.")]
//[RequireBotPermission(ChannelPermission.Speak, ErrorMessage = "I don't have permissions to join a voice chat")]
public async Task JoinCmd()
Expand All @@ -45,6 +46,7 @@ public async Task JoinCmd()
// this is merely the minimal amount necessary.
// Adding more commands of your own is also encouraged.
[Command("leaves", RunMode = RunMode.Async)]
[Summary("Leaves your current Voice Chat Channel")]
[RequireContext(ContextType.Guild, ErrorMessage = "This command is only possible via a public channel.")]
public async Task LeaveCmd()
{
Expand All @@ -54,14 +56,16 @@ public async Task LeaveCmd()

[Command("plays", RunMode = RunMode.Async)]
[RequireContext(ContextType.Guild, ErrorMessage = "This command is only possible via a public channel.")]
public async Task PlayCmd([Remainder] string song)
[Summary("Plays a specific song from the harddrive")]
public async Task PlayCmd([Summary("Song location")]string song)
{
var result = await _service.PlaySound(Context.Guild, Context.Channel, (Context.User as IVoiceState).VoiceChannel, song);
await Context.Message.AddReactionAsync(result == AudioServiceStatus.Succes ? CommonEmoij.OK : CommonEmoij.NOK);
}

[Command("stops", RunMode = RunMode.Async)]
[RequireContext(ContextType.Guild, ErrorMessage = "This command is only possible via a public channel.")]
[Summary("Stops playing the current song")]
public async Task StopCmd()
{
var result = await _service.StopPlaying(Context.Guild, (Context.User as IVoiceState).VoiceChannel);
Expand All @@ -70,13 +74,15 @@ public async Task StopCmd()

[Command("say", RunMode = RunMode.Async)]
[RequireContext(ContextType.Guild, ErrorMessage = "This command is only possible via a public channel.")]
public async Task SayText([Remainder] string text)
[Summary("Says a specific text inside a voice channel")]
public async Task SayText([Remainder] [Summary("Text to speak")] string text)
{
var result = await _service.SayText(Context.Guild, (Context.User as IVoiceState).VoiceChannel, Context.Channel, text);
await Context.Message.AddReactionAsync(result == AudioServiceStatus.Succes ? CommonEmoij.OK : CommonEmoij.NOK);
}

[Command("listaudio", RunMode = RunMode.Async)]
[Summary("List all available audio files")]
public async Task ListAudioFiles()
{
var result = await _service.ListAudio(Context);
Expand Down
1 change: 1 addition & 0 deletions ISurvivalBot/Commands/JamaarCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public class JamaarCommand : ModuleBase<SocketCommandContext>


[Command("jamaar")]
[Summary("Stel een dilemma voor aan de bot. Dit geef je achter !jamaar in de tekst aan")]
public async Task Jamaar([Remainder] string text)
{
int answer = random.Next(this.cards.Count);
Expand Down
39 changes: 36 additions & 3 deletions ISurvivalBot/Commands/MaintenanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace ISurvivalBot.Commands
{


[Summary("Admin mode")]
[Group("maintenance")]
public class MaintenanceCommand : ModuleBase<SocketCommandContext>
{
Expand All @@ -29,6 +30,11 @@ public MaintenanceCommand(MaintenanceService maintenanceservice, UserService use
}


/// <summary>
/// __TODO__ is this smart? Or juist update anything
/// </summary>
/// <returns></returns>
[Summary("Update current user")]
[Command("update", RunMode = RunMode.Async)]
public async Task UpdateCommand()
{
Expand Down Expand Up @@ -56,7 +62,8 @@ public async Task CreateAdminCommand(string username, bool admin)


[Command("isadmin", RunMode = RunMode.Async)]
public async Task IsAdminCommand(string username)
[Summary("Checks if the specific user is.")]
public async Task IsAdminCommand([Summary("Username")] string username)
{
var mentionUser = Context.Message.MentionedUsers.FirstOrDefault();
bool result = await _userService.IsAdmin(mentionUser == null ? username : mentionUser.Username);
Expand All @@ -65,7 +72,8 @@ public async Task IsAdminCommand(string username)
}

[Command("sayprivate", RunMode = RunMode.Async)]
public async Task SayPrivate(ulong userId, string text)
[Summary("Sends a private message to a specific user.")]
public async Task SayPrivate([Summary("UserId")] ulong userId, [Summary("Text to send to the user")] string text)
{
bool isRequesterAdmin = await _userService.IsAdmin(Context.Message.Author.Username);
if (!isRequesterAdmin)
Expand All @@ -89,7 +97,8 @@ public async Task SayPrivate(ulong userId, string text)
}

[Command("sayprivate", RunMode = RunMode.Async)]
public async Task SayPrivate(string userName, string text)
[Summary("Sends a private message to a specific user.")]
public async Task SayPrivate([Summary("Username")] string userName, [Summary("Text to send to the user")] string text)
{
bool isRequesterAdmin = await _userService.IsAdmin(Context.Message.Author.Username);
if (!isRequesterAdmin)
Expand All @@ -112,6 +121,30 @@ public async Task SayPrivate(string userName, string text)
}
}

//[Command("saychannel", RunMode = RunMode.Async)]
//[Summary("Sends a private message to a specific channel.")]
//public async Task SayPrivate(ulong channelId, [Summary("Text to send to the user")] string text)
//{
// bool isRequesterAdmin = await _userService.IsAdmin(Context.Message.Author.Username);
// if (!isRequesterAdmin)
// {
// await Context.Message.AddReactionAsync(CommonEmoij.NOK);
// return;
// }
// var channelSend = _discordSocketClient.GetGuild(channelId);
// if (channelSend == null)
// {
// await Context.Message.AddReactionAsync(CommonEmoij.NOK);
// return;
// }
// else
// {
// await channelSend.(text);
// await Context.Message.AddReactionAsync(CommonEmoij.OK);
// return;
// }
//}


}
}
29 changes: 20 additions & 9 deletions ISurvivalBot/Commands/PublicModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class PublicModule : ModuleBase<SocketCommandContext>
{
// Dependency Injection will fill this value in for us
public PictureService PictureService { get; set; }
private readonly static Random random = new Random();

[Command("ping")]
[Alias("pong", "hello")]
Expand All @@ -25,8 +26,16 @@ public async Task PingAsync()
await Context.Message.ReplyAsync("pong!");
}

[Command("help")]
[Summary("Help command")]
public async Task HelpCommand()
{
await Context.Message.ReplyAsync("Even geduld a.u.b. de bot met een helpfunctie is ook binnenkort op uw discord server beschikbaar!");
}


[Command("cat")]
[Summary("Shows a picture of a random cat.")]
public async Task CatAsync()
{
// Get a stream containing an image of a cat
Expand All @@ -37,6 +46,7 @@ public async Task CatAsync()
}

[Command("catfact")]
[Summary("Reacts with a random cat fact.")]
public async Task CatFactAsync()
{
// Get random cat fact
Expand All @@ -45,6 +55,7 @@ public async Task CatFactAsync()
}

[Command("terry")]
[Summary("TempleOS")]
public async Task TerryCommand()
{
Emoji custom = null;
Expand All @@ -57,6 +68,7 @@ public async Task TerryCommand()


[Command("dog")]
[Summary("Shows a picture of a random dog.")]
public async Task DogAsync()
{
// Get a stream containing an image of a dog
Expand All @@ -67,6 +79,7 @@ public async Task DogAsync()
}

[Command("fox")]
[Summary("Shows a picture of a random fox.")]
public async Task FoxAsync()
{
// Get a stream containing an image of a dog
Expand All @@ -77,6 +90,7 @@ public async Task FoxAsync()
}

[Command("panda")]
[Summary("Shows a picture of a random panda.")]
public async Task PandaAsync()
{
// Get a stream containing an image of a dog
Expand All @@ -86,15 +100,6 @@ public async Task PandaAsync()
await Context.Channel.SendFileAsync(stream, "panda.png");
}

// Get info on a user, or the user who invoked the command if one is not specified
[Command("userinfo")]
public async Task UserInfoAsync(IUser user = null)
{
user ??= Context.User;

await ReplyAsync(user.ToString());
}


[Command("howto")]
public async Task HowTocommand(string question)
Expand All @@ -109,6 +114,12 @@ public async Task BerendCommand()
await Context.Message.AddReactionAsync(CommonEmoij.BEREND);
}

[Command("kopmunt")]
public async Task KopMuntCommand()
{
await ReplyAsync(random.Next(0, 1) == 1 ? "Kop" : "Munt");
}

// Ban a user
[Command("ban")]
[RequireContext(ContextType.Guild)]
Expand Down
64 changes: 0 additions & 64 deletions ISurvivalBot/Commands/SheepCommand.cs

This file was deleted.

3 changes: 2 additions & 1 deletion ISurvivalBot/Commands/ToevalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ISurvivalBot.Commands
public class ToevalCommand : ModuleBase<SocketCommandContext>
{
public static Random random = new Random();
public List<String> cards = new List<string>()
private List<String> cards = new List<string>()
{
"Kun jij ook hinken op twee gedachten?",
"Kiezen voor liefde is soms loslaten.",
Expand Down Expand Up @@ -149,6 +149,7 @@ public class ToevalCommand : ModuleBase<SocketCommandContext>


[Command("spreuk")]
[Summary("Random spreuk van de dag")]
public async Task Jamaar(/*[Remainder] string text*/)
{
int answer = random.Next(this.cards.Count);
Expand Down
2 changes: 2 additions & 0 deletions ISurvivalBot/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class User

public bool IsAdmin { get; set; }

public string Discriminator { get; set; }


}
}
2 changes: 1 addition & 1 deletion ISurvivalBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private async Task Client_MessageReceived(SocketMessage message)
if (sum != null && !sum.Author.IsBot)
{
var debugUser = _client.GetUser(438976181237448705);
await debugUser.SendMessageAsync($"Author {sum.Author.Username} said in a private message: {sum.Content}.");
await debugUser.SendMessageAsync($"Author {sum.Author.Username} said in channel: {sum.Channel.Name} message: {sum.Content}.");
}

string messageText = message.Content.ToLowerInvariant();
Expand Down
5 changes: 3 additions & 2 deletions ISurvivalBot/Services/AudioService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task<AudioServiceStatus> LeaveAudio(IGuild guild, IVoiceChannel voi
AudioServiceState audioState = await getAudioState(guild);
if (audioState == null)
{
Console.WriteLine("Not connected");
_logger.LogInformation("Not connected");
return AudioServiceStatus.Failure;
}
if (audioState.IsPlaying)
Expand Down Expand Up @@ -126,6 +126,7 @@ public async Task<AudioServiceStatus> PlaySound(IGuild guild, IMessageChannel ch
if (!File.Exists(path))
{
await channel.SendMessageAsync("File does not exist.");
_logger.LogInformation("Not connected");
return AudioServiceStatus.Failure;
}

Expand All @@ -139,7 +140,7 @@ public async Task<AudioServiceStatus> PlaySound(IGuild guild, IMessageChannel ch
var psi = new ProcessStartInfo
{
FileName = "ffmpeg",
Arguments = $@"-hide_banner -loglevel panic -i ""{path}"" -ac 2 -f s16le -ar 48000 pipe:1",
Arguments = $"-hide_banner -loglevel panic -i \"{path}\" -ac 2 -f s16le -ar 48000 pipe:1",
RedirectStandardOutput = true,
UseShellExecute = false
};
Expand Down

0 comments on commit 9642f4d

Please sign in to comment.