Compare commits
21 Commits
dev
...
debug_bran
Author | SHA1 | Date | |
---|---|---|---|
|
ed86405263 | ||
|
203811366b | ||
|
e9f59780ed | ||
|
18657d7fab | ||
|
b5702faa31 | ||
|
9ac6343406 | ||
|
c28ffe2ade | ||
|
92459fb4de | ||
|
32246855fa | ||
|
941716b19d | ||
|
9ede67c61b | ||
|
021c497288 | ||
|
5d32d3b611 | ||
|
17e08c6f01 | ||
|
6ce26b1d39 | ||
|
05143db059 | ||
|
0522482685 | ||
|
e1f376f92c | ||
|
f73d84803e | ||
|
2a80032cae | ||
|
cea06e205c |
16
EventBot/Attributes/ExampleAttribute.cs
Normal file
16
EventBot/Attributes/ExampleAttribute.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace EventBot.Attributes
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
||||||
|
class ExampleAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Use { get; set; }
|
||||||
|
public ExampleAttribute(string use)
|
||||||
|
{
|
||||||
|
Use = use;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -7,10 +7,10 @@ COPY ["EventBot/EventBot.csproj", "EventBot/"]
|
|||||||
RUN dotnet restore "EventBot/EventBot.csproj"
|
RUN dotnet restore "EventBot/EventBot.csproj"
|
||||||
COPY . .
|
COPY . .
|
||||||
WORKDIR "/src/EventBot"
|
WORKDIR "/src/EventBot"
|
||||||
RUN dotnet build "EventBot.csproj" -c Release -o /app
|
RUN dotnet build "EventBot.csproj" -c Debug -o /app
|
||||||
|
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
RUN dotnet publish "EventBot.csproj" -c Release -o /app
|
RUN dotnet publish "EventBot.csproj" -c Debug -o /app
|
||||||
|
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
@@ -9,15 +9,15 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Discord.Addons.Interactive" Version="1.0.1" />
|
<PackageReference Include="Discord.Addons.Interactive" Version="1.0.1" />
|
||||||
<PackageReference Include="Discord.Net" Version="2.1.1" />
|
<PackageReference Include="Discord.Net" Version="2.1.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.design" Version="2.2.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.design" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.6">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.9" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.5" />
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@@ -88,7 +88,7 @@ namespace EventBot.Modules
|
|||||||
.Aggregate(true, (a, r) => a && r))
|
.Aggregate(true, (a, r) => a && r))
|
||||||
.SelectMany(c => c.Aliases.Select(a => new { CI = c, MA = (c.Aliases[0] == a), A = a }).Reverse())
|
.SelectMany(c => c.Aliases.Select(a => new { CI = c, MA = (c.Aliases[0] == a), A = a }).Reverse())
|
||||||
.Select((e, i) => new { Command = e, Index = i })
|
.Select((e, i) => new { Command = e, Index = i })
|
||||||
.GroupBy(o => o.Index / 30)
|
.GroupBy(o => o.Index / 15)
|
||||||
.Select(g => g.Select(o => o.Command));
|
.Select(g => g.Select(o => o.Command));
|
||||||
|
|
||||||
var pager = new PaginatedMessage()
|
var pager = new PaginatedMessage()
|
||||||
@@ -130,6 +130,9 @@ namespace EventBot.Modules
|
|||||||
embed.AddField("Parameters",
|
embed.AddField("Parameters",
|
||||||
string.Join("\r\n", command.Parameters.Select(p => $"`{p.FormatParameter()}` *(Type: {p.FormatParameterType()})* - **{p.Summary}** {(p.IsRemainder ? "_No quotes are needed, when providing this parameter._" : "")}" ))
|
string.Join("\r\n", command.Parameters.Select(p => $"`{p.FormatParameter()}` *(Type: {p.FormatParameterType()})* - **{p.Summary}** {(p.IsRemainder ? "_No quotes are needed, when providing this parameter._" : "")}" ))
|
||||||
);
|
);
|
||||||
|
var examples = command.Attributes.Where(a => a is ExampleAttribute).Select(a => ((ExampleAttribute)a).Use).ToArray();
|
||||||
|
if (examples.Length != 0)
|
||||||
|
embed.AddField("Examples", $"```{string.Join("\r\n", examples)}```");
|
||||||
|
|
||||||
await ReplyAsync($"I got this information about command `{commandAlias}`:", embed: embed.Build());
|
await ReplyAsync($"I got this information about command `{commandAlias}`:", embed: embed.Build());
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ using System.Linq;
|
|||||||
using EventBot.Entities;
|
using EventBot.Entities;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using Discord.Addons.Interactive;
|
using Discord.Addons.Interactive;
|
||||||
|
using EventBot.Attributes;
|
||||||
|
|
||||||
namespace EventBot.Modules
|
namespace EventBot.Modules
|
||||||
{
|
{
|
||||||
@@ -28,6 +29,9 @@ namespace EventBot.Modules
|
|||||||
[Alias("j")]
|
[Alias("j")]
|
||||||
[Name("Join event")]
|
[Name("Join event")]
|
||||||
[Summary("Joins latest or specified event with specified event role.")]
|
[Summary("Joins latest or specified event with specified event role.")]
|
||||||
|
[Example("join :slight_smile:")]
|
||||||
|
[Example("join 5 \"John Smith\"")]
|
||||||
|
[Example("join :gun: \"Tpr. James\" 2")]
|
||||||
public async Task JoinEvent(
|
public async Task JoinEvent(
|
||||||
[Summary("Role emote or role ID to join the most recent event.")] string emoteOrId,
|
[Summary("Role emote or role ID to join the most recent event.")] string emoteOrId,
|
||||||
[Summary("Extra information that might be needed by organizers.")] string extraInformation = null,
|
[Summary("Extra information that might be needed by organizers.")] string extraInformation = null,
|
||||||
@@ -129,6 +133,8 @@ namespace EventBot.Modules
|
|||||||
[Alias("add", "create")]
|
[Alias("add", "create")]
|
||||||
[Name("Create event")]
|
[Name("Create event")]
|
||||||
[Summary("Creates a new event.")]
|
[Summary("Creates a new event.")]
|
||||||
|
[Example("event new \"The event\" \"This is going to be a very hard event to organize.\"")]
|
||||||
|
[Example("event new \"Departmental chaos\" \"This event is about departmental workers rising against heads. Please provide your character name during registration.\" Detailed")]
|
||||||
public async Task CreateEvent(
|
public async Task CreateEvent(
|
||||||
[Summary("Title for the event.")] string title,
|
[Summary("Title for the event.")] string title,
|
||||||
[Summary("Description for the event.")] string description,
|
[Summary("Description for the event.")] string description,
|
||||||
@@ -194,6 +200,8 @@ namespace EventBot.Modules
|
|||||||
[Command("update type")]
|
[Command("update type")]
|
||||||
[Name("Update event's type")]
|
[Name("Update event's type")]
|
||||||
[Summary("Updates the event type.")]
|
[Summary("Updates the event type.")]
|
||||||
|
[Example("event update type Quick")]
|
||||||
|
[Example("event update type Detailed 3")]
|
||||||
public async Task UpdateEventType(
|
public async Task UpdateEventType(
|
||||||
[Summary("Type of event registration.")] Event.EventParticipactionType type,
|
[Summary("Type of event registration.")] Event.EventParticipactionType type,
|
||||||
[Summary("Event to update, if not specified, updates latest event.")] Event @event = null)
|
[Summary("Event to update, if not specified, updates latest event.")] Event @event = null)
|
||||||
@@ -220,6 +228,9 @@ namespace EventBot.Modules
|
|||||||
[Alias("role add", "role create")]
|
[Alias("role add", "role create")]
|
||||||
[Name("Add role")]
|
[Name("Add role")]
|
||||||
[Summary("Adds a new role to the event.")]
|
[Summary("Adds a new role to the event.")]
|
||||||
|
[Example("event role new \"ERT\" \"Emergency response team that recovers the artifact.\" :gun:")]
|
||||||
|
[Example("event role new \"Ninja\" \"To sneak around various corners of the station.\" :fire: 1")]
|
||||||
|
[Example("event role new \"Mercenaries\" \"To go on the station and do stuff.\" :fingers_crossed: 6 2")]
|
||||||
public async Task NewEventRole(
|
public async Task NewEventRole(
|
||||||
[Summary("Title of the role.")] string title,
|
[Summary("Title of the role.")] string title,
|
||||||
[Summary("Description of the role.")] string description,
|
[Summary("Description of the role.")] string description,
|
||||||
@@ -277,6 +288,10 @@ namespace EventBot.Modules
|
|||||||
throw new Exception("This event is finalized. Please make a new event.");
|
throw new Exception("This event is finalized. Please make a new event.");
|
||||||
eventRole.Title = title;
|
eventRole.Title = title;
|
||||||
var s = _database.SaveChangesAsync();
|
var s = _database.SaveChangesAsync();
|
||||||
|
if (eventRole.ChannelId != 0)
|
||||||
|
await Context.Guild.GetTextChannel(eventRole.ChannelId).ModifyAsync(p => p.Name = eventRole.ChannelName);
|
||||||
|
if (eventRole.RoleId != 0)
|
||||||
|
await Context.Guild.GetRole(eventRole.RoleId).ModifyAsync(p => p.Name = eventRole.Title);
|
||||||
await ReplyAsync($"Updated event role `{eventRole.Id}`'s title to `{eventRole.Title}`");
|
await ReplyAsync($"Updated event role `{eventRole.Id}`'s title to `{eventRole.Title}`");
|
||||||
await s;
|
await s;
|
||||||
await _events.UpdateEventMessage(eventRole.Event);
|
await _events.UpdateEventMessage(eventRole.Event);
|
||||||
@@ -566,7 +581,10 @@ namespace EventBot.Modules
|
|||||||
[Priority(2)]
|
[Priority(2)]
|
||||||
[Command("participant add")]
|
[Command("participant add")]
|
||||||
[Name("Add participant")]
|
[Name("Add participant")]
|
||||||
[Summary("Add user to event role. Acts like join command.")]
|
[Summary("Add user to event role. Acts like join command. Works even if registration is closed.")]
|
||||||
|
[Example("participant add \"Mini Moose#6944\" :slight_smile:")]
|
||||||
|
[Example("participant add Arrow768#3092 5 \"John Smith\"")]
|
||||||
|
[Example("participant add 183658981019877376 :gun: \"Tpr. James\" 2")]
|
||||||
public async Task EventParticipantAdd(
|
public async Task EventParticipantAdd(
|
||||||
[Summary("User ID or discord mention.")] IUser user,
|
[Summary("User ID or discord mention.")] IUser user,
|
||||||
[Summary("Role emote or role ID to join.")] string emoteOrId,
|
[Summary("Role emote or role ID to join.")] string emoteOrId,
|
||||||
|
@@ -49,12 +49,7 @@ namespace EventBot
|
|||||||
private ServiceProvider ConfigureServices()
|
private ServiceProvider ConfigureServices()
|
||||||
{
|
{
|
||||||
return new ServiceCollection()
|
return new ServiceCollection()
|
||||||
.AddSingleton(s => new DiscordSocketClient(new DiscordSocketConfig() {
|
.AddSingleton(s => new DiscordSocketClient(getDiscordSocketConfig()))
|
||||||
#if DEBUG
|
|
||||||
LogLevel = LogSeverity.Debug,
|
|
||||||
#endif
|
|
||||||
MessageCacheSize = 1500
|
|
||||||
}))
|
|
||||||
.AddSingleton<CommandService>()
|
.AddSingleton<CommandService>()
|
||||||
.AddSingleton<CommandHandlingService>()
|
.AddSingleton<CommandHandlingService>()
|
||||||
.AddSingleton<EventManagementService>()
|
.AddSingleton<EventManagementService>()
|
||||||
@@ -69,5 +64,19 @@ namespace EventBot
|
|||||||
//.AddSingleton<PictureService>()
|
//.AddSingleton<PictureService>()
|
||||||
.BuildServiceProvider();
|
.BuildServiceProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DiscordSocketConfig getDiscordSocketConfig()
|
||||||
|
{
|
||||||
|
var config = new DiscordSocketConfig()
|
||||||
|
{
|
||||||
|
MessageCacheSize = 1500
|
||||||
|
};
|
||||||
|
#if DEBUG
|
||||||
|
config.LogLevel = LogSeverity.Debug;
|
||||||
|
#endif
|
||||||
|
if(Environment.GetEnvironmentVariable("DEBUG") != null)
|
||||||
|
config.LogLevel = LogSeverity.Debug;
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
"EventBot": {
|
"EventBot": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"dbconnection": "Server=localhost;Database=eventbot;User=root;Password=tux;",
|
"dbconnection": "Server=server;Database=eventbot;User=eventbot;Password=password;",
|
||||||
"token": "<insert Token here>"
|
"token": "token here"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Docker": {
|
"Docker": {
|
||||||
|
Reference in New Issue
Block a user