Skip to content

Commit

Permalink
This is V2.0.3.
Browse files Browse the repository at this point in the history
all commands updated. fixes #17
Welcome system should have less inconsistencies.
  • Loading branch information
GreemDev committed Feb 5, 2019
1 parent c24601b commit d4e852f
Show file tree
Hide file tree
Showing 55 changed files with 237 additions and 228 deletions.
12 changes: 7 additions & 5 deletions Volte/Core/Commands/Modules/Admin/AddRoleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Discord.Commands;
using Discord.WebSocket;
using Volte.Core.Commands.Preconditions;
using Volte.Core.Extensions;
using Volte.Helpers;

namespace Volte.Core.Commands.Modules.Admin {
Expand All @@ -14,16 +15,17 @@ public partial class AdminModule : VolteModule {
[Remarks("Usage: |prefix|addrole {@user} {roleName}")]
[RequireGuildAdmin]
public async Task AddRole(SocketGuildUser user, [Remainder] string role) {
var targetRole = Context.Guild.Roles.FirstOrDefault(r => string.Equals(r.Name, role, StringComparison.CurrentCultureIgnoreCase));
var targetRole = Context.Guild.Roles.FirstOrDefault(r =>
string.Equals(r.Name, role, StringComparison.CurrentCultureIgnoreCase));
if (targetRole != null) {
await user.AddRoleAsync(targetRole);
await Reply(Context.Channel,
CreateEmbed(Context, $"Added the role **{role}** to {user.Mention}!"));
await Context.CreateEmbed($"Added the role **{role}** to {user.Mention}!")
.SendTo(Context.Channel);
return;
}

await Reply(Context.Channel,
CreateEmbed(Context, $"**{role}** doesn't exist on this server!"));
await Context.CreateEmbed($"**{role}** doesn't exist on this server!")
.SendTo(Context.Channel);
}
}
}
2 changes: 1 addition & 1 deletion Volte/Core/Commands/Modules/Admin/AdminRoleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class AdminModule : VolteModule {
[Remarks("Usage: |prefix|adminrole {roleName}")]
[RequireGuildAdmin]
public async Task AdminRole([Remainder] string roleName) {
var embed = CreateEmbed(Context, string.Empty).ToEmbedBuilder();
var embed = Context.CreateEmbed(string.Empty).ToEmbedBuilder();
var config = Db.GetConfig(Context.Guild);
if (Context.Guild.Roles.Any(r => r.Name.ToLower().Equals(roleName.ToLower()))) {
var role = Context.Guild.Roles.First(r => r.Name == roleName);
Expand Down
10 changes: 6 additions & 4 deletions Volte/Core/Commands/Modules/Admin/AntilinkCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Discord.Commands;
using Volte.Core.Commands.Preconditions;
using Volte.Core.Data;
using Volte.Core.Extensions;
using Volte.Helpers;

namespace Volte.Core.Commands.Modules.Admin {
Expand All @@ -11,11 +12,12 @@ public partial class AdminModule : VolteModule {
[Summary("Enable/Disable Antilink for the current guild.")]
[Remarks("Usage: |prefix|antilink {true|false}")]
[RequireGuildAdmin]
public async Task Antilink(bool alIsEnabled) {
public async Task Antilink(bool arg) {
var config = Db.GetConfig(Context.Guild);
config.Antilink = alIsEnabled;
var isEnabled = alIsEnabled ? "Antilink has been enabled." : "Antilink has been disabled.";
await Reply(Context.Channel, CreateEmbed(Context, isEnabled));
config.Antilink = arg;
Db.UpdateConfig(config);
await Context.CreateEmbed(arg ? "Antilink has been enabled." : "Antilink has been disabled.")
.SendTo(Context.Channel);
}
}
}
10 changes: 5 additions & 5 deletions Volte/Core/Commands/Modules/Admin/AutoroleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ public partial class AdminModule : VolteModule {
[Summary("Sets the role to be used for Autorole.")]
[Remarks("Usage: |prefix|autorole {roleName}")]
[RequireGuildAdmin]
public async Task Autorole([Remainder]string role) {
public async Task Autorole([Remainder] string role) {
var config = Db.GetConfig(Context.Guild);
var roleToApply = Context.Guild.Roles
.FirstOrDefault(r => r.Name.EqualsIgnoreCase(role));
if (roleToApply is null) {
await Reply(Context.Channel,
CreateEmbed(Context, $"The specified role, **{role}**, doesn't exist on this guild."));
await Context.CreateEmbed($"The specified role, **{role}**, doesn't exist on this guild.")
.SendTo(Context.Channel);
return;
}

config.Autorole = roleToApply.Name;
Db.UpdateConfig(config);
await Reply(Context.Channel, CreateEmbed(Context,
$"Successfully set **{roleToApply.Name}** as the Autorole for this server."));
await Context.CreateEmbed($"Successfully set **{roleToApply.Name}** as the Autorole for this server.")
.SendTo(Context.Channel);
}
}
}
12 changes: 5 additions & 7 deletions Volte/Core/Commands/Modules/Admin/BlacklistCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task BlacklistAdd([Remainder] string arg) {
var config = Db.GetConfig(Context.Guild);
config.Blacklist.Add(arg);
Db.UpdateConfig(config);
await Reply(Context.Channel, CreateEmbed(Context, $"Added **{arg}** to the blacklist."));
await Context.CreateEmbed($"Added **{arg}** to the blacklist.").SendTo(Context.Channel);
}

[Command("BlacklistRemove"), Alias("BlRem")]
Expand All @@ -28,13 +28,11 @@ public async Task BlacklistRemove([Remainder] string arg) {
var config = Db.GetConfig(Context.Guild);
if (config.Blacklist.Any(p => p.EqualsIgnoreCase(arg))) {
config.Blacklist.RemoveAt(config.Blacklist.FindIndex(p => p.EqualsIgnoreCase(arg)));
await Context.Channel.SendMessageAsync(string.Empty, false,
CreateEmbed(Context, $"Removed **{arg}** from the word blacklist."));
await Context.CreateEmbed($"Removed **{arg}** from the word blacklist.").SendTo(Context.Channel);
Db.UpdateConfig(config);
}
else {
await Context.Channel.SendMessageAsync(string.Empty, false,
CreateEmbed(Context, $"**{arg}** doesn't exist in the blacklist."));
await Context.CreateEmbed($"**{arg}** doesn't exist in the blacklist.").SendTo(Context.Channel);
}
}

Expand All @@ -44,8 +42,8 @@ await Context.Channel.SendMessageAsync(string.Empty, false,
[RequireGuildAdmin]
public async Task BlacklistClear() {
var config = Db.GetConfig(Context.Guild);
await Reply(Context.Channel,
CreateEmbed(Context, $"Cleared the custom commands, containing **{config.Blacklist.Count}** words."));
await Context.CreateEmbed($"Cleared the custom commands, containing **{config.Blacklist.Count}** words.")
.SendTo(Context.Channel);
config.Blacklist.Clear();
Db.UpdateConfig(config);
}
Expand Down
27 changes: 13 additions & 14 deletions Volte/Core/Commands/Modules/Admin/CustomCommandCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Discord.Commands;
using Volte.Core.Commands.Preconditions;
using Volte.Core.Data;
using Volte.Core.Extensions;
using Volte.Helpers;

namespace Volte.Core.Commands.Modules.Admin {
Expand All @@ -16,24 +17,22 @@ public async Task CustomCommandAdd(string name, [Remainder] string response) {
var config = Db.GetConfig(Context.Guild);
config.CustomCommands.Add(name, response);
Db.UpdateConfig(config);
await Context.Channel.SendMessageAsync(string.Empty, false,
CreateEmbed(Context, string.Empty)
.ToEmbedBuilder()
.AddField("Command Name", name)
.AddField("Command Response", response)
.Build()
);
await Context.CreateEmbed(string.Empty)
.ToEmbedBuilder()
.AddField("Command Name", name)
.AddField("Command Response", response)
.SendTo(Context.Channel);
}

[Command("CustomCommandRem"), Alias("Ccr")]
[Summary("Remove a custom command from this guild.")]
[Remarks("Usage: |prefix|customcommandrem {cmdName}")]
[RequireGuildAdmin]
public async Task CustomCommandRem(string cmdName) {
var config = Db.GetConfig(Context.Guild);
var embed = CreateEmbed(Context, string.Empty).ToEmbedBuilder()
var embed = Context.CreateEmbed(string.Empty).ToEmbedBuilder()
.WithAuthor(Context.User);

if (config.CustomCommands.Keys.Contains(cmdName)) {
config.CustomCommands.Remove(cmdName);
Db.UpdateConfig(config);
Expand All @@ -43,7 +42,7 @@ public async Task CustomCommandRem(string cmdName) {
embed.WithDescription($"**{cmdName}** is not a command on this server.");
}

await Context.Channel.SendMessageAsync(string.Empty, false, embed.Build());
await embed.SendTo(Context.Channel);
}

[Command("CustomCommandClear"), Alias("Ccc")]
Expand All @@ -52,9 +51,9 @@ public async Task CustomCommandRem(string cmdName) {
[RequireGuildAdmin]
public async Task CustomCommandClear() {
var config = Db.GetConfig(Context.Guild);
await Context.Channel.SendMessageAsync(string.Empty, false,
CreateEmbed(Context,
$"Cleared the custom commands, containing **{config.CustomCommands.Count}** words."));
await Context
.CreateEmbed($"Cleared the custom commands, containing **{config.CustomCommands.Count}** words.")
.SendTo(Context.Channel);
config.CustomCommands.Clear();
Db.UpdateConfig(config);
}
Expand Down
7 changes: 4 additions & 3 deletions Volte/Core/Commands/Modules/Admin/DebugCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Discord.Commands;
using Newtonsoft.Json;
using Volte.Core.Commands.Preconditions;
using Volte.Core.Extensions;
using Volte.Core.Services;
using Volte.Helpers;

Expand All @@ -15,10 +16,10 @@ public partial class AdminModule : VolteModule {
[Remarks("Usage: |prefix|debug")]
[RequireGuildAdmin]
public async Task Debug() {
await Reply(Context.Channel,
CreateEmbed(Context,
await Context.CreateEmbed(
$"{DebugService.Execute(JsonConvert.SerializeObject(Db.GetConfig(Context.Guild), Formatting.Indented))}" +
"\n\nTake this to the Volte guild for support. Join the guild [here](https://greemdev.net/discord)."));
"\n\nTake this to the Volte guild for support. Join the guild [here](https://greemdev.net/discord).")
.SendTo(Context.Channel);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Volte.Core.Commands.Preconditions;
using Volte.Helpers;
using Volte.Core.Data;
using Volte.Core.Extensions;

namespace Volte.Core.Commands.Modules.Admin {
public partial class AdminModule : VolteModule {
Expand All @@ -15,8 +16,7 @@ public async Task DeleteMessageOnCommand(bool arg) {
var config = Db.GetConfig(Context.Guild);
config.DeleteMessageOnCommand = arg;
Db.UpdateConfig(config);
await Context.Channel.SendMessageAsync(string.Empty, false,
CreateEmbed(Context, $"Set the DeleteMessageOnCommand setting to **{arg}**."));
await Context.CreateEmbed(arg ? "Enabled DeleteMessageOnCommand in this server." : "").SendTo(Context.Channel);
}
}
}
10 changes: 5 additions & 5 deletions Volte/Core/Commands/Modules/Admin/LevelsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Discord.Commands;
using Volte.Core.Commands.Preconditions;
using Volte.Core.Data;
using Volte.Core.Extensions;
using Volte.Helpers;

namespace Volte.Core.Commands.Modules.Admin {
Expand All @@ -11,13 +12,12 @@ public partial class AdminModule : VolteModule {
[Summary("Enables/Disables level gaining for this guild.")]
[Remarks("Usage: $levels {true|false}")]
[RequireGuildAdmin]
public async Task Levels(bool enabled) {
public async Task Levels(bool arg) {
var config = Db.GetConfig(Context.Guild);
config.Leveling = enabled;
config.Leveling = arg;
Db.UpdateConfig(config);
await Context.Channel.SendMessageAsync(string.Empty, false,
CreateEmbed(Context,
enabled ? "Enabled Leveling for this server." : "Disabled Leveling for this server."));
await Context.CreateEmbed(arg ? "Leveling has been enabled." : "Leveling has been disabled.")
.SendTo(Context.Channel);

}
}
Expand Down
9 changes: 5 additions & 4 deletions Volte/Core/Commands/Modules/Admin/ModRoleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Discord.Commands;
using Volte.Core.Commands.Preconditions;
using Volte.Core.Data;
using Volte.Core.Extensions;
using Volte.Helpers;

namespace Volte.Core.Commands.Modules.Admin {
Expand All @@ -14,10 +15,10 @@ public partial class AdminModule : VolteModule {
[RequireGuildAdmin]
public async Task ModRole([Remainder] string roleName) {
var config = Db.GetConfig(Context.Guild);
var embed = CreateEmbed(Context, string.Empty).ToEmbedBuilder();
var embed = Context.CreateEmbed(string.Empty).ToEmbedBuilder();

if (Context.Guild.Roles.Any(r => r.Name.ToLower() == roleName.ToLower())) {
var role = Context.Guild.Roles.First(r => r.Name.ToLower() == roleName.ToLower());
if (Context.Guild.Roles.Any(r => r.Name.EqualsIgnoreCase(roleName))) {
var role = Context.Guild.Roles.First(r => r.Name.EqualsIgnoreCase(roleName));
config.ModRole = role.Id;
Db.UpdateConfig(config);
embed.WithDescription($"Set **{role.Name}** as the Moderator role for this server.");
Expand All @@ -26,7 +27,7 @@ public async Task ModRole([Remainder] string roleName) {
embed.WithDescription($"{roleName} doesn't exist in this server.");
}

await Context.Channel.SendMessageAsync(string.Empty, false, embed.Build());
await embed.SendTo(Context.Channel);
}
}
}
10 changes: 5 additions & 5 deletions Volte/Core/Commands/Modules/Admin/PingChecksCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Discord.Commands;
using Volte.Core.Commands.Preconditions;
using Volte.Core.Data;
using Volte.Core.Extensions;
using Volte.Helpers;

namespace Volte.Core.Commands.Modules.Admin {
Expand All @@ -11,13 +12,12 @@ public partial class AdminModule : VolteModule {
[Summary("Enable/Disable checking for @everyone and @here for this guild.")]
[Remarks("Usage: |prefix|pingchecks {true|false}")]
[RequireGuildAdmin]
public async Task PingChecks(bool isEnabled) {
public async Task PingChecks(bool arg) {
var config = Db.GetConfig(Context.Guild);
config.MassPingChecks = true;
config.MassPingChecks = arg;
Db.UpdateConfig(config);

var pcIsEnabled = isEnabled ? "Enabled mass ping checks." : "Disabled mass ping checks.";
await Reply(Context.Channel, CreateEmbed(Context, pcIsEnabled));
await Context.CreateEmbed(arg ? "MassPingChecks has been enabled." : "MassPingChecks has been disabled.")
.SendTo(Context.Channel);
}
}
}
10 changes: 4 additions & 6 deletions Volte/Core/Commands/Modules/Admin/RemRoleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Discord.Commands;
using Discord.WebSocket;
using Volte.Core.Commands.Preconditions;
using Volte.Core.Extensions;
using Volte.Helpers;

namespace Volte.Core.Commands.Modules.Admin {
Expand All @@ -13,16 +14,13 @@ public partial class AdminModule : VolteModule {
[Remarks("Usage: |prefix|remrole {@user} {roleName}")]
[RequireGuildAdmin]
public async Task RemRole(SocketGuildUser user, [Remainder] string role) {
var targetRole = Context.Guild.Roles.FirstOrDefault(r => r.Name.ToLower() == role.ToLower());
var targetRole = Context.Guild.Roles.FirstOrDefault(r => r.Name.EqualsIgnoreCase(role));
if (targetRole != null) {
await user.RemoveRoleAsync(targetRole);
await Context.Channel.SendMessageAsync(string.Empty, false,
CreateEmbed(Context, $"Removed the role **{role}** from {user.Mention}!"));
await Context.CreateEmbed($"Removed the role **{role}** from {user.Mention}!").SendTo(Context.Channel);
return;
}

await Context.Channel.SendMessageAsync(string.Empty, false,
CreateEmbed(Context, $"**{role}** doesn't exist on this server!"));
await Context.CreateEmbed($"**{role}** doesn't exist on this server!").SendTo(Context.Channel);
}
}
}
17 changes: 8 additions & 9 deletions Volte/Core/Commands/Modules/Admin/SelfRoleCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public partial class AdminModule : VolteModule {
[RequireGuildAdmin]
public async Task SelfRoleAdd(string roleName) {
if (Context.Guild.Roles.FirstOrDefault(x => x.Name.EqualsIgnoreCase(roleName)) is null) {
await Reply(Context.Channel, CreateEmbed(Context, "That role doesn't exist in this guild."));
await Context.CreateEmbed("That role doesn't exist in this guild.").SendTo(Context.Channel);
return;
}
var config = Db.GetConfig(Context.Guild);
config.SelfRoles.Add(roleName);
Db.UpdateConfig(config);
await Reply(Context.Channel,
CreateEmbed(Context, $"Successfully added **{roleName}** to the Self Roles for this guild."));
await Context.CreateEmbed($"Successfully added **{roleName}** to the Self Roles for this guild.")
.SendTo(Context.Channel);
}

[Command("SelfRoleRem"), Alias("Srr")]
Expand All @@ -38,13 +38,13 @@ public async Task SelfRoleRem(string roleName) {

if (config.SelfRoles.Any(x => x.EqualsIgnoreCase(roleName))) {
config.SelfRoles.Remove(roleName);
await Reply(Context.Channel,
CreateEmbed(Context, $"Removed **{roleName}** from the Self Roles list on this guild."));
await Context.CreateEmbed($"Removed **{roleName}** from the Self Roles list on this guild.")
.SendTo(Context.Channel);
Db.UpdateConfig(config);
}
else {
await Reply(Context.Channel,
CreateEmbed(Context, $"The Self Roles list for this guild doesn't contain **{roleName}**."));
await Context.CreateEmbed($"The Self Roles list for this guild doesn't contain **{roleName}**.")
.SendTo(Context.Channel);
}
}

Expand All @@ -60,8 +60,7 @@ public async Task SelfRoleClear() {
var config = Db.GetConfig(Context.Guild);
config.SelfRoles.Clear();
Db.UpdateConfig(config);
await Reply(Context.Channel,
CreateEmbed(Context, "Successfully cleared all Self Roles for this server."));
await Context.CreateEmbed("Successfully cleared all Self Roles for this server.").SendTo(Context.Channel);
}
}
}
Loading

0 comments on commit d4e852f

Please sign in to comment.