Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the command call #6

Open
wants to merge 7 commits into
base: working
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions OmniMistressBot/DiceRolls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace OmniMistressBot
public class DiceRolls
{
[Command("roll"), Aliases("r"), Description("Rolls any size die a given number of times")]
public async Task Roll(CommandContext context, string dice)
public async Task DiceRoll(CommandContext context, string dice)
{
await context.TriggerTypingAsync();

Expand All @@ -40,7 +40,7 @@ public async Task Roll(CommandContext context, string dice)
}

[Command("rolloff"), Aliases("rc", "ro"), Description("Challenge another user to a roll off (ex. !rolloff @username)")]
public async Task RoleRoll(CommandContext context, DiscordUser user)
public async Task RollOff(CommandContext context, DiscordUser user)
{
InteractivityModule interactivity = context.Client.GetInteractivityModule();
await context.TriggerTypingAsync();
Expand All @@ -62,7 +62,7 @@ public async Task RoleRoll(CommandContext context, DiscordUser user)
};

//Starts the roll off and announces the victor unless there is a tie
//Refactor soon
//Maybe... Refactor
var emote = await interactivity.WaitForReactionAsync(e => e == e.Name, user, TimeSpan.FromSeconds(30));
if (emote.Emoji.Name == yes)
{
Expand Down
5 changes: 3 additions & 2 deletions OmniMistressBot/InteractiveCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public async Task CodeRace(CommandContext context)
InteractivityModule interactivity = context.Client.GetInteractivityModule();

await context.RespondAsync("First to type the code within 30 seconds wins! Ready?");

//Count down from 3
for (int i = 3; i >= 0; i--)
{
await Task.Delay(TimeSpan.FromSeconds(1));
Expand All @@ -37,8 +39,7 @@ public async Task CodeRace(CommandContext context)

var message = await interactivity.WaitForMessageAsync(c => c.Content.Contains(code), TimeSpan.FromSeconds(30));

//Below prevents bot from accepting itself stating the code as a response,
//but may still accept code from self and go to 'else'
//Prevent bot from accepting itself stating the code as a response, but may still accept code from self and go to 'else'
if (message != null && message.User.IsBot == false)
{
await context.RespondAsync($"The winner is: {message.User.Mention}");
Expand Down
34 changes: 0 additions & 34 deletions OmniMistressBot/RactionRoles.cs

This file was deleted.

66 changes: 59 additions & 7 deletions OmniMistressBot/RoleCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,43 @@

namespace OmniMistressBot
{
[RequireUserPermissions(Permissions.Administrator)]
class RoleCommands
{
[RequireOwner]
[Command("upgraderole"), Aliases("ur"), Description("Upgrade a user to any role [!ur @{user} {role}]")]
[Hidden]
//Create a new role
[Command("newroll"), Aliases("nr"), Description("Create a new roll. [!newrole {RoleName} {Color (hex code without the #)} {Mentionable (can be left blank)}]")]
public async Task CreateRoll(CommandContext context, string roleName, string color, bool mentionable = true)
{
var discordColor = new DiscordColor(color);

await context.Guild.CreateRoleAsync(roleName, null, discordColor, null,mentionable, null);

await context.RespondAsync($"Role {roleName} has been created. Color = {color} | Mentionable = {mentionable}");
}

//Delete an existing role
[Command("deleterole"), Aliases("dr"), Description("Delete a specified role. [!deleterole {RoleName}]")]
public async Task DeleteRole(CommandContext context, string roleName)
{
//ReadOnlyList of roles in Guild to string list of names
var guildRoles = context.Guild.Roles;
List<string> guildRoleList = guildRoles.Select(item => item.Name).ToList();

//Check if role exists in server, respond with error if not
if (guildRoleList.Exists(r => r == roleName))
{
var discordRole = context.Guild.Roles.FirstOrDefault(x => x.Name == roleName);
await context.Guild.DeleteRoleAsync(discordRole);
await context.RespondAsync($"{discordRole.Name} has been deleted.");
}
else
{
await context.RespondAsync($"Could not complete deletion. Either the {roleName} role does not exist in this server or role was misspelled. Roles are case sensitive.");
}
}

//Assign a role to a member
[Command("giverole"), Aliases("gr"), Description("Owner can assign a user to any role [!ur @{user} {role}]")]
public async Task UpgradeRole(CommandContext context, DiscordMember member, string role)
{
//ReadOnlyList of roles in Guild to string list of names
Expand All @@ -36,16 +68,16 @@ public async Task UpgradeRole(CommandContext context, DiscordMember member, stri
{
var upgradeRole = context.Guild.Roles.FirstOrDefault(x => x.Name == role);
await member.GrantRoleAsync(upgradeRole);
await context.RespondAsync($"Updated to {upgradeRole.Name}");
await context.RespondAsync($"{member.Username} has been the role {upgradeRole.Name}");
}
else
{
await context.RespondAsync($"Couldn't complete. Either the {role} role does not exist in this server and bot's aren't people or {member.Username} is already part of that role.");
}
}
[RequireOwner]
[Command("downgraderole"), Aliases("dr", "downgrade"), Description("Take away a role from a user [!dr @{user} {role}]")]
[Hidden]

//Remove role from member
[Command("takerole"), Aliases("tr", "removerole"), Description("Take away a role from a user [!dr @{user} {role}]")]
public async Task DowngradeRole(CommandContext context, DiscordMember member, string role)
{
//ReadOnlyList of roles in Guild to string list of names
Expand Down Expand Up @@ -76,5 +108,25 @@ public async Task DowngradeRole(CommandContext context, DiscordMember member, st
await context.RespondAsync($"Couldn't complete. Either the {role} role does not exist in this server and bot's aren't people or {member.Username} doesn't belong to that role.");
}
}


public async Task ListRoles(CommandContext context)
{
List<string> guildRoleList = new List<string>();
var guildRoles = context.Guild.Roles;
foreach (var item in guildRoles)
{
guildRoleList.Add(item.Name);
}

var embed = new DiscordEmbedBuilder
{
Title = $"Available roles on {context.Guild.Name}",
Description = ""
};
await context.RespondAsync(embed: embed);

await context.RespondAsync();
}
}
}