Added general bot commands NewStatus, and NewName, both RequireOwner to evoke.

This commit is contained in:
Chris Darnell committed 2021-05-04 05:05:59 -07:00
1 parent 147c165e62
commit afca839596
7 files changed
+241 -110

No files matched your search

+62 -10
View File
@@ -18,8 +18,8 @@ namespace StarsiegeBot
class BotSettings : BaseCommandModule
{
public static Dictionary<string, GuildSettings> GuildSettings;
private readonly string fileName = "guildSettings.json";
private CancellationToken cancelToken;
private readonly string fileName = "guildsettings.json";
private readonly CancellationTokenSource cancelToken;
public BotSettings()
{
Console.WriteLine("Bot Setting Commands Loaded");
@@ -44,7 +44,7 @@ namespace StarsiegeBot
AllowRolesPurchase = false
};
item.UseAutoRoles = false;
item.LevelRoles = new Dictionary<int, List<DiscordRole>>();
item.LevelRoles = new Dictionary<int, List<string>>();
item.Prefixes = new List<string>();
item.SelfRoles = new Dictionary<string, Dictionary<string, int>>();
item.Prefixes.Add(">");
@@ -70,15 +70,56 @@ namespace StarsiegeBot
json = sr.ReadToEnd();
GuildSettings = JsonConvert.DeserializeObject<Dictionary<string, GuildSettings>>(json);
}
_ = StartTimer(cancelToken);
cancelToken = new CancellationTokenSource();
_ = StartTimer(cancelToken.Token);
}
[GroupCommand]
[Description("Work in progress. Does nothing yet.")]
[Description("Reports simplified data about the server settings.")]
public async Task BaseItem(CommandContext ctx)
{
await ctx.TriggerTypingAsync();
var guild = GuildSettings[ctx.Guild.Id.ToString()];
DiscordEmbedBuilder embed = StartEmbed(ctx.Guild.Name + " Server settings.");
embed.AddField("On/Off Items", "_ _");
embed.AddField("Global Prefix", (guild.UseGlobalPrefix ? "On" : "Off"), true);
embed.AddField("Self Roles", (guild.UseSelfRoles ? "On" : "Off"), true);
embed.AddField("Level Roles", (guild.UseLevelRoles ? "On" : "Off"), true);
embed.AddField("Auto Roles", (guild.UseAutoRoles ? "On" : "Off"), true);
embed.AddField("Levels", (guild.UseLevels ? "On" : "Off"), true);
embed.AddField("Welcome Msg", (guild.UseWelcome ? "On" : "Off"), true);
embed.AddField("Counts", "_ _");
embed.AddField("Prefixes", guild.Prefixes.Count.ToString(), true);
embed.AddField("Self Groups", guild.SelfRoles.Count.ToString(), true);
embed.AddField("Levels", guild.LevelRoles.Count.ToString(), true);
await ctx.RespondAsync(embed);
}
[Command("status"), RequireOwner]
[Description("Sets the bot's nickname on this server.")]
public async Task SetStatus (CommandContext ctx, string type, [RemainingText] string newStatus = null)
{
await ctx.TriggerTypingAsync();
var aType = type.ToLower() switch
{
"competing" => ActivityType.Competing,
"listening" => ActivityType.ListeningTo,
"playing" => ActivityType.Playing,
"streaming" => ActivityType.Streaming,
"watching" => ActivityType.Watching,
_ => ActivityType.Custom,
};
DiscordActivity act = new DiscordActivity(newStatus, aType);
await ctx.Client.UpdateStatusAsync(act);
await ctx.RespondAsync("Test.");
}
[Command("username"), RequireOwner]
public async Task SetUsername (CommandContext ctx, [RemainingText] string newName)
{
await ctx.TriggerTypingAsync();
await ctx.Client.UpdateCurrentUserAsync(newName);
await ctx.RespondAsync("How's my name name?");
}
private async Task StartTimer(CancellationToken cancellationToken)
{
@@ -97,7 +138,15 @@ namespace StarsiegeBot
}
});
}
private DiscordEmbedBuilder StartEmbed(string desc)
{
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = desc,
Color = Program.colours[^2]
};
return embed;
}
}
public class GuildSettings
@@ -108,13 +157,16 @@ namespace StarsiegeBot
public bool UseLevels { get; set; }
public bool AllowRolesPurchase { get; set; }
public bool UseAutoRoles { get; set; }
public List<String> Prefixes { get; set; }
public List<string> Prefixes { get; set; }
// List<"Prefix">
public List<string> HiddenRolesList { get; set; }
// List<"RoleId">
public Dictionary<string, Dictionary<string, int>> SelfRoles { get; set; }
public Dictionary<int, List<DiscordRole>> LevelRoles { get; set; }
public List<DiscordRole> HiddenRolesList { get; set; }
// Dict < "GroupName", Dict<"RoleID", Price>>
public Dictionary<int, List<string>> LevelRoles { get; set; }
// Dict< Level, List<"RoleID">>
public DiscordChannel WelcomeChannel { get; set; }
public bool UseWelcome { get; set; }
public string WelcomeMessage { get; set; }
}
}
+88 -62
View File
@@ -1,6 +1,7 @@
#pragma warning disable IDE0060 // Remove unused parameter
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Exceptions;
using DSharpPlus.Entities;
using DSharpPlus.EventArgs;
using Microsoft.Extensions.Logging;
@@ -15,20 +16,15 @@ namespace StarsiegeBot
{
public readonly EventId BotEventId;
public static DiscordMember notify;
protected string BotName { get; set; }
// protected string BotName { get; set; }
private readonly BotSettings Guilds = new BotSettings();
public Triggers(EventId botEventId)
{
BotEventId = botEventId;
}
public Triggers(EventId botEventId) => BotEventId = botEventId;
public Task CommandExecuted(CommandsNextExtension ext, CommandExecutionEventArgs e)
{
if (e.Context.Client.Guilds.Count > 75)
e.Context.Client.Logger.LogCritical(BotEventId, $"Client is in {e.Context.Client.Guilds.Count}");
// e.Context.Client.Logger.LogCritical(BotEventId, $"Client is in {e.Context.Client.Guilds.Count}");
// let's log the name of the command and user
e.Context.Client.Logger.LogInformation(BotEventId, $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'");
// e.Context.Client.Logger.LogInformation(BotEventId, $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'");
// since this method is not async, let's return
// a completed task, so that no additional work
@@ -37,7 +33,7 @@ namespace StarsiegeBot
}
public Task MessageCreated(DiscordClient d, MessageCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageCreated.");
// d.Logger.LogDebug(BotEventId, "MessageCreated.");
// Ignore all bots. We don't care.
if (e.Author.IsBot)
@@ -97,47 +93,57 @@ namespace StarsiegeBot
public Task CommandErrored(CommandsNextExtension ext, CommandErrorEventArgs e)
{
e.Context.Client.Logger.LogError(BotEventId, $"{e.Context.User.Username} tried executing '{e.Command?.QualifiedName ?? "<unknown command>"}' but it errored: {e.Exception.GetType()}: {e.Exception.Message ?? "<no message>"}", DateTime.Now);
if (e.Exception is ChecksFailedException ex)
{
string output = "---\r\n";
foreach (var item in ex.FailedChecks)
{
output += item.ToString() + "\r\n";
}
Console.WriteLine(output);
}
return Task.CompletedTask;
}
public Task InteractionCreated(DiscordClient d, InteractionCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, $"{e.Interaction.User.Username} started an interaction. {e.Interaction.Data.Name}");
// d.Logger.LogDebug(BotEventId, $"{e.Interaction.User.Username} started an interaction. {e.Interaction.Data.Name}");
return Task.CompletedTask;
}
public Task ChannelCreated(DiscordClient d, ChannelCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, $"{e.Channel.Name} was created on {e.Guild.Name}. Type: {e.Channel.Type}");
// d.Logger.LogDebug(BotEventId, $"{e.Channel.Name} was created on {e.Guild.Name}. Type: {e.Channel.Type}");
return Task.CompletedTask;
}
public Task ChannelDeleted(DiscordClient d, ChannelDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ChannelDeleted.");
// d.Logger.LogDebug(BotEventId, "ChannelDeleted.");
return Task.CompletedTask;
}
public Task ApplicationCommandCreated(DiscordClient d, ApplicationCommandEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ApplicationCommandCreated.");
// d.Logger.LogDebug(BotEventId, "ApplicationCommandCreated.");
return Task.CompletedTask;
}
public Task ApplicationCommandDeleted(DiscordClient d, ApplicationCommandEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ApplicationCommandDeleted.");
// d.Logger.LogDebug(BotEventId, "ApplicationCommandDeleted.");
return Task.CompletedTask;
}
public Task ApplicationCommandUpdated(DiscordClient d, ApplicationCommandEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ApplicationCommandUpdated.");
// d.Logger.LogDebug(BotEventId, "ApplicationCommandUpdated.");
return Task.CompletedTask;
}
public Task ChannelPinsUpdated(DiscordClient d, ChannelPinsUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ChannelPinsUpdated.");
// d.Logger.LogDebug(BotEventId, "ChannelPinsUpdated.");
return Task.CompletedTask;
}
public Task ChannelUpdated(DiscordClient d, ChannelUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ChannelUpdated.");
// d.Logger.LogDebug(BotEventId, "ChannelUpdated.");
return Task.CompletedTask;
}
public Task ClientErrored(DiscordClient d, ClientErrorEventArgs e)
@@ -153,7 +159,7 @@ namespace StarsiegeBot
}
public Task DmChannelDeleted(DiscordClient d, DmChannelDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ClientErrored.");
// d.Logger.LogDebug(BotEventId, "ClientErrored.");
return Task.CompletedTask;
}
public Task GuildAvailable(DiscordClient d, GuildCreateEventArgs e)
@@ -174,12 +180,14 @@ namespace StarsiegeBot
UseLevelRoles = false,
UseLevels = false,
UseSelfRoles = false,
AllowRolesPurchase = false
AllowRolesPurchase = false,
UseWelcome = false,
WelcomeChannel = null,
WelcomeMessage = "",
SelfRoles = new Dictionary<string, Dictionary<string, int>>(),
LevelRoles = new Dictionary<int, List<string>>(),
Prefixes = new List<string>()
};
item.UseAutoRoles = false;
item.LevelRoles = new Dictionary<int, List<DiscordRole>>();
item.Prefixes = new List<string>();
item.SelfRoles = new Dictionary<string, Dictionary<string, int>>();
// this line... is a test line.
BotSettings.GuildSettings.Add(gId, item);
}
@@ -188,6 +196,10 @@ namespace StarsiegeBot
// let's log the name of the guild that was just
// sent to our client
d.Logger.LogInformation(BotEventId, $"Guild available: {e.Guild.Name}");
if (!(notify is null))
// notify the *primary bot owner if the Guild count is above 75. So we can start bot verification process.
if (d.Guilds.Count > 75 && !(notify is null))
notify.SendMessageAsync("**__WARNING__: BOT IS IN OVER 75 SERVERS.");
// since this method is not async, let's return
// a completed task, so that no additional work
@@ -196,45 +208,59 @@ namespace StarsiegeBot
}
public Task GuildBanAdded(DiscordClient d, GuildBanAddEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildBanAdded.");
// d.Logger.LogDebug(BotEventId, "GuildBanAdded.");
return Task.CompletedTask;
}
public Task GuildBanRemoved(DiscordClient d, GuildBanRemoveEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildBanRemoved.");
// d.Logger.LogDebug(BotEventId, "GuildBanRemoved.");
return Task.CompletedTask;
}
public Task GuildCreated(DiscordClient d, GuildCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildCreated.");
// d.Logger.LogDebug(BotEventId, "GuildCreated.");
return Task.CompletedTask;
}
public Task GuildDeleted(DiscordClient d, GuildDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildDeleted.");
// d.Logger.LogDebug(BotEventId, "GuildDeleted.");
return Task.CompletedTask;
}
public Task GuildDownloadCompleted(DiscordClient d, GuildDownloadCompletedEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildDownloadCompleted.");
// d.Logger.LogDebug(BotEventId, "GuildDownloadCompleted.");
//if(e.Guilds[376937422010974209].Members.ContainsKey(139548200099905536))
//notify = e.Guilds[376937422010974209].Members[139548200099905536];
ulong desiredKey = 139548200099905536;
foreach (KeyValuePair<ulong,DiscordGuild> item in e.Guilds)
{
DiscordGuild curr = item.Value;
if(curr.Members.ContainsKey(desiredKey))
{
notify = curr.Members[desiredKey];
break;
}
}
notify.SendMessageAsync("Bot has started up");
// notify the *primary bot owner if the Guild count is above 75. So we can start bot verification process.
if (e.Guilds.Count > 75)
notify.SendMessageAsync("**__WARNING__: BOT IS IN OVER 75 SERVERS.");
return Task.CompletedTask;
}
public Task GuildEmojisUpdated(DiscordClient d, GuildEmojisUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildEmojisUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildEmojisUpdated.");
return Task.CompletedTask;
}
public Task GuildIntegrationsUpdated(DiscordClient d, GuildIntegrationsUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildIntegrationsUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildIntegrationsUpdated.");
return Task.CompletedTask;
}
public Task GuildMemberAdded(DiscordClient d, GuildMemberAddEventArgs e)
{
d.Logger.LogDebug(BotEventId, $"GuildMemberAdded.");
// d.Logger.LogDebug(BotEventId, $"GuildMemberAdded.");
if (e.Member.IsBot)
{
return Task.CompletedTask;
@@ -253,102 +279,102 @@ namespace StarsiegeBot
}
public Task GuildMemberRemoved(DiscordClient d, GuildMemberRemoveEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildMemberRemoved.");
// d.Logger.LogDebug(BotEventId, "GuildMemberRemoved.");
return Task.CompletedTask;
}
public Task GuildMembersChunked(DiscordClient d, GuildMembersChunkEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildMembersChunked.");
// d.Logger.LogDebug(BotEventId, "GuildMembersChunked.");
return Task.CompletedTask;
}
public Task GuildMemberUpdated(DiscordClient d, GuildMemberUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildMemberUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildMemberUpdated.");
return Task.CompletedTask;
}
public Task GuildRoleCreated(DiscordClient d, GuildRoleCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildRoleCreated.");
// d.Logger.LogDebug(BotEventId, "GuildRoleCreated.");
return Task.CompletedTask;
}
public Task GuildRoleDeleted(DiscordClient d, GuildRoleDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildRoleDeleted.");
// d.Logger.LogDebug(BotEventId, "GuildRoleDeleted.");
return Task.CompletedTask;
}
public Task GuildRoleUpdated(DiscordClient d, GuildRoleUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildRoleUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildRoleUpdated.");
return Task.CompletedTask;
}
public Task GuildUnavailable(DiscordClient d, GuildDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildUnavailable.");
// d.Logger.LogDebug(BotEventId, "GuildUnavailable.");
return Task.CompletedTask;
}
public Task GuildUpdated(DiscordClient d, GuildUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildUpdated.");
return Task.CompletedTask;
}
public Task Heartbeated(DiscordClient d, HeartbeatEventArgs e)
{
d.Logger.LogDebug(BotEventId, "Heartbeated.");
// d.Logger.LogDebug(BotEventId, "Heartbeated.");
return Task.CompletedTask;
}
public Task InviteCreated(DiscordClient d, InviteCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "InviteCreated.");
// d.Logger.LogDebug(BotEventId, "InviteCreated.");
return Task.CompletedTask;
}
public Task InviteDeleted(DiscordClient d, InviteDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "InviteDeleted.");
// d.Logger.LogDebug(BotEventId, "InviteDeleted.");
return Task.CompletedTask;
}
public Task MessageAcknowledged(DiscordClient d, MessageAcknowledgeEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageAcknowledged.");
// d.Logger.LogDebug(BotEventId, "MessageAcknowledged.");
return Task.CompletedTask;
}
public Task MessageDeleted(DiscordClient d, MessageDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageDeleted.");
// d.Logger.LogDebug(BotEventId, "MessageDeleted.");
return Task.CompletedTask;
}
public Task MessageReactionAdded(DiscordClient d, MessageReactionAddEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageReactionAdded.");
// d.Logger.LogDebug(BotEventId, "MessageReactionAdded.");
return Task.CompletedTask;
}
public Task MessageReactionRemoved(DiscordClient d, MessageReactionRemoveEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageReactionRemoved.");
// d.Logger.LogDebug(BotEventId, "MessageReactionRemoved.");
return Task.CompletedTask;
}
public Task MessageReactionRemovedEmoji(DiscordClient d, MessageReactionRemoveEmojiEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageReactionRemovedEmoji.");
// d.Logger.LogDebug(BotEventId, "MessageReactionRemovedEmoji.");
return Task.CompletedTask;
}
public Task MessageReactionsCleared(DiscordClient d, MessageReactionsClearEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageReactionsCleared.");
// d.Logger.LogDebug(BotEventId, "MessageReactionsCleared.");
return Task.CompletedTask;
}
public Task MessagesBulkDeleted(DiscordClient d, MessageBulkDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessagesBulkDeleted.");
// d.Logger.LogDebug(BotEventId, "MessagesBulkDeleted.");
return Task.CompletedTask;
}
public Task MessageUpdated(DiscordClient d, MessageUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageUpdated.");
// d.Logger.LogDebug(BotEventId, "MessageUpdated.");
return Task.CompletedTask;
}
public Task PresenceUpdated(DiscordClient d, PresenceUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "PresenceUpdated.");
// d.Logger.LogDebug(BotEventId, "PresenceUpdated.");
return Task.CompletedTask;
}
public Task Ready(DiscordClient d, ReadyEventArgs e)
@@ -363,7 +389,7 @@ namespace StarsiegeBot
}
public Task Resumed(DiscordClient d, ReadyEventArgs e)
{
d.Logger.LogDebug(BotEventId, "Resumed.");
// d.Logger.LogDebug(BotEventId, "Resumed.");
return Task.CompletedTask;
}
public Task SocketClosed(DiscordClient d, SocketCloseEventArgs e)
@@ -378,42 +404,42 @@ namespace StarsiegeBot
}
public Task SocketOpened(DiscordClient d, SocketEventArgs e)
{
d.Logger.LogDebug(BotEventId, "SocketOpened.");
// d.Logger.LogDebug(BotEventId, "SocketOpened.");
return Task.CompletedTask;
}
public Task TypingStarted(DiscordClient d, TypingStartEventArgs e)
{
d.Logger.LogDebug(BotEventId, "TypingStarted.");
// d.Logger.LogDebug(BotEventId, "TypingStarted.");
return Task.CompletedTask;
}
public Task UnknownEvent(DiscordClient d, UnknownEventArgs e)
{
d.Logger.LogDebug(BotEventId, "UnknownEvent.");
// d.Logger.LogDebug(BotEventId, "UnknownEvent.");
return Task.CompletedTask;
}
public Task UserSettingsUpdated(DiscordClient d, UserSettingsUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "UserSettingsUpdated.");
// d.Logger.LogDebug(BotEventId, "UserSettingsUpdated.");
return Task.CompletedTask;
}
public Task UserUpdated(DiscordClient d, UserUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "UserUpdated.");
// d.Logger.LogDebug(BotEventId, "UserUpdated.");
return Task.CompletedTask;
}
public Task VoiceServerUpdated(DiscordClient d, VoiceServerUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "VoiceServerUpdated.");
// d.Logger.LogDebug(BotEventId, "VoiceServerUpdated.");
return Task.CompletedTask;
}
public Task VoiceStateUpdated(DiscordClient d, VoiceStateUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "VoiceStateUpdated.");
// d.Logger.LogDebug(BotEventId, "VoiceStateUpdated.");
return Task.CompletedTask;
}
public Task WebhooksUpdated(DiscordClient d, WebhooksUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "WebhooksUpdated.");
// d.Logger.LogDebug(BotEventId, "WebhooksUpdated.");
return Task.CompletedTask;
}
}
+8 -8
View File
@@ -19,7 +19,7 @@ namespace StarsiegeBot
Console.WriteLine("Group Management Loaded.");
}
[GroupCommand]
[GroupCommand, Aliases("view")]
public async Task ListGroups(CommandContext ctx)
{
await ctx.TriggerTypingAsync();
@@ -69,13 +69,13 @@ namespace StarsiegeBot
}
}
[Command("edit")]
[Description("This is under construction. Does nothing yet.")]
public async Task EditGroup(CommandContext ctx, [RemainingText] string groupInfo)
{
await ctx.TriggerTypingAsync();
// string gId = ctx.Guild.Id.ToString();
//[Command("edit")]
//[Description("This is under construction. Does nothing yet.")]
//public async Task EditGroup(CommandContext ctx, [RemainingText] string groupInfo)
//{
// await ctx.TriggerTypingAsync();
// // string gId = ctx.Guild.Id.ToString();
}
//}
}
}
+39 -5
View File
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace StarsiegeBot
{
[Group("GroupRole")]
[Group("GroupRole"), Aliases("gr")]
[Description("Work in progress. Does nothing yet.")]
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
class GroupRoleManagement : BotSettings
@@ -27,20 +27,43 @@ namespace StarsiegeBot
[Command("add")]
[Description("Work in progress. Does nothing yet.")]
public async Task AddSelfRole(CommandContext ctx, [Description("The role to add.")] DiscordRole role, [Description("The price of the role for buyable roles. 0 for no cost. Free free to leave blank if not using Buyable roles.")] int price = 0, [Description("What group to put the role in. If not using groups, you can leave blank.")] string group = null)
public async Task AddSelfRole(CommandContext ctx,
[Description("The role to add.")] DiscordRole role,
[Description("The price of the role for buyable roles. 0 for no cost. Free free to leave blank if not using Buyable roles.")] int price = 0,
[Description("What group to put the role in. If not using groups, you can leave blank."), RemainingText] string groupName = null)
{
await ctx.TriggerTypingAsync();
if (price == -1)
price = Math.Abs(price);
// Fix price.
// Verify group exists.
// Since we allow roles to be in several groups, dont have to verify that.
//
string gId = ctx.Guild.Id.ToString();
if (GuildSettings[gId].SelfRoles.ContainsKey(groupName))
{
return;
GuildSettings[gId].SelfRoles[groupName].Add(role.Id.ToString(), price);
await ctx.RespondAsync(StartEmbed($"{role.Mention} added to the group `{groupName}` with the price of {price}"));
}
else
{
// group not found, `Create it?` or `Cancel`?
}
}
[Command("delete")]
[Description("Work in progress. Does nothing yet.")]
public async Task DeleteSelfRole(CommandContext ctx, [Description("The role to delete.")] DiscordRole role, [Description("The group to remove the role from. If left blank, will remove from all groups.")] string group = null)
public async Task DeleteSelfRole(CommandContext ctx,
[Description("The role to delete.")] DiscordRole role,
[Description("The group to remove the role from. If left blank, will remove from all groups."), RemainingText] string group = null)
{
await ctx.TriggerTypingAsync();
// Verify role is in a group.
// Verify group selected exists.
// If group null, remove from all groups?
}
[Command("Edit")]
@@ -49,5 +72,16 @@ namespace StarsiegeBot
{
await ctx.TriggerTypingAsync();
}
private DiscordEmbedBuilder StartEmbed(string desc)
{
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = desc,
Color = Program.colours[3]
};
return embed;
}
}
}
-1
View File
@@ -178,7 +178,6 @@ namespace StarsiegeBot
class MasterServer
{
[JsonProperty("address")]
public string Address { get; private set; }
[JsonProperty("CommonName")]
public string CommonName { get; private set; }
+9 -23
View File
@@ -66,12 +66,7 @@ namespace StarsiegeBot
{
output = "Loading Quick Chats failed. File does not exist.";
}
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = output,
Color = Program.colours[Program.rnd.Next(0, Program.colours.Length)]
};
await ctx.RespondAsync(embed);
await ctx.RespondAsync(StartEmbed(output));
}
[Command("script")]
@@ -106,13 +101,12 @@ namespace StarsiegeBot
[Description("Runs a check to see how many WAV files are missing from all QC's.")]
public async Task QuickChatCheck(CommandContext ctx)
{
await ctx.TriggerTypingAsync();
// If we're disabled, let them know. And exit out.
if (!IsEnabled)
{
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
return;
}
await ctx.TriggerTypingAsync();
// Start a count
int missingFiles = 0;
@@ -127,28 +121,21 @@ namespace StarsiegeBot
}
// Reply to the message and let the user know we're missing X files.
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = $"Missing files: {missingFiles}",
Color = Program.colours[Program.rnd.Next(0, Program.colours.Length)]
};
await ctx.RespondAsync(embed);
await ctx.RespondAsync(StartEmbed($"Missing files: {missingFiles}"));
}
[GroupCommand]
[Description("Gives a specific or random Quickchat. If that QC has a sound file that the bot knows, uploads the sound file too.")]
public async Task QuickChat(CommandContext ctx, [Description("The ID of the quick Chat.")] int id = -1)
{
await ctx.TriggerTypingAsync();
string output;
// If we're disabled, let them know. And exit out.
if (!IsEnabled)
{
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
return;
}
await ctx.TriggerTypingAsync();
string output;
// Start a new Message Build.
DiscordMessageBuilder msg = new DiscordMessageBuilder();
@@ -184,6 +171,7 @@ namespace StarsiegeBot
}
// If the sound file to the select QC exists, upload it as well.
msg.Embed = StartEmbed(output);
if (File.Exists($"./qc/{chat.soundFile}"))
{
// Open the file.
@@ -194,7 +182,7 @@ namespace StarsiegeBot
}
// Send either the text QC or sound file if we have it
msg.Content = output;
// msg.Content = output;
await ctx.RespondAsync(msg);
}
@@ -282,7 +270,7 @@ namespace StarsiegeBot
IsEnabled = false;
output = $"{fileName} file is missing, and it can not be enabled.";
}
await ctx.RespondAsync(output);
await ctx.RespondAsync(StartEmbed(output));
}
private DiscordEmbedBuilder StartEmbed(string description)
@@ -296,8 +284,6 @@ namespace StarsiegeBot
}
}
public class Quickchat
{
public string text;
+35 -1
View File
@@ -10,7 +10,41 @@ using System.Threading.Tasks;
namespace StarsiegeBot
{
[Group("welcome")]
[RequireGuild, RequirePermissions(Permissions.ManageChannels)]
[RequireGuild,
RequirePermissions(Permissions.ManageChannels),
Cooldown(1,10,CooldownBucketType.Global),
RequireNsfw,
RequireBotPermissions(Permissions.AccessChannels)
//RequireBotPermissions(Permissions.AddReactions),
//RequireBotPermissions(Permissions.Administrator),
//RequireBotPermissions(Permissions.AttachFiles),
//RequireBotPermissions(Permissions.BanMembers),
//RequireBotPermissions(Permissions.ChangeNickname),
//RequireBotPermissions(Permissions.CreateInstantInvite),
//RequireBotPermissions(Permissions.DeafenMembers),
//RequireBotPermissions(Permissions.EmbedLinks),
//RequireBotPermissions(Permissions.KickMembers),
//RequireBotPermissions(Permissions.ManageChannels),
//RequireBotPermissions(Permissions.ManageEmojis),
//RequireBotPermissions(Permissions.ManageGuild),
//RequireBotPermissions(Permissions.ManageMessages),
//RequireBotPermissions(Permissions.ManageNicknames),
//RequireBotPermissions(Permissions.ManageRoles),
//RequireBotPermissions(Permissions.ManageWebhooks),
//RequireBotPermissions(Permissions.MentionEveryone),
//RequireBotPermissions(Permissions.MoveMembers),
//RequireBotPermissions(Permissions.MuteMembers),
//RequireBotPermissions(Permissions.PrioritySpeaker),
//RequireBotPermissions(Permissions.ReadMessageHistory),
//RequireBotPermissions(Permissions.SendMessages),
//RequireBotPermissions(Permissions.SendTtsMessages),
//RequireBotPermissions(Permissions.Speak),
//RequireBotPermissions(Permissions.Stream),
//RequireBotPermissions(Permissions.UseExternalEmojis),
//RequireBotPermissions(Permissions.UseVoice),
//RequireBotPermissions(Permissions.UseVoiceDetection),
//RequireBotPermissions(Permissions.ViewAuditLog)
]
class WelcomeMessage : BotSettings
{
[GroupCommand]