Skip to content

Commit

Permalink
Merge pull request #472 from fit-ctu-discord/v2022.4.4
Browse files Browse the repository at this point in the history
Release version 2022.4.4
  • Loading branch information
ostorc authored Dec 20, 2022
2 parents 23f1247 + bc7f333 commit bd9f962
Show file tree
Hide file tree
Showing 24 changed files with 392 additions and 233 deletions.
14 changes: 0 additions & 14 deletions .github/dependabot.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
"gitmoji",
"schedule:earlyMondays",
":disableRateLimiting"
],
"labels": ["dependencies"],
"packageRules": [
{
"matchUpdateTypes": ["patch", "minor"],
"groupName": "minor + patch dependencies"
},
{
"groupName": "Github Actions",
"matchManagers": [
"github-actions"
]
}
]
}
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -37,7 +37,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -51,4 +51,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
6 changes: 3 additions & 3 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
8 changes: 2 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<Project>
<PropertyGroup>
<Version>2022.4.3</Version>
<TargetFramework>net6.0</TargetFramework>
<Version>2022.4.4</Version>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<WarningsAsErrors>true</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<CentralPackagesFile>$(MSBuildThisFileDirectory)Packages.props</CentralPackagesFile>
</PropertyGroup>
</Project>
31 changes: 31 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Chronic.Core" Version="0.4.0" />
<PackageVersion Include="Cronos" Version="0.7.1" />
<PackageVersion Include="DSharpPlus" Version="4.3.0-nightly-01223" />
<PackageVersion Include="DSharpPlus.Interactivity" Version="4.3.0-nightly-01223" />
<PackageVersion Include="DSharpPlus.SlashCommands" Version="4.3.0-nightly-01223" />
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="7.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageVersion Include="System.Collections.Immutable" Version="7.0.0" />
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="Shouldly" Version="4.1.0" />
<PackageVersion Include="Html2Markdown" Version="5.1.0.703" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion HonzaBotner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
CONTRIBUTING.md = CONTRIBUTING.md
Packages.props = Packages.props
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HonzaBotner", "src\HonzaBotner\HonzaBotner.csproj", "{04BEA8DF-6FDB-465A-BF6C-D28BADBD572F}"
Expand Down
28 changes: 0 additions & 28 deletions Packages.props

This file was deleted.

2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "7.0.101",
"rollForward": "latestMinor"
}
}
69 changes: 68 additions & 1 deletion src/HonzaBotner.Discord.Services/Commands/BotCommands.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System.Reflection;
using System;
using System.Reflection;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
using DSharpPlus.SlashCommands;
using HonzaBotner.Discord.Managers;
using HonzaBotner.Discord.Services.Options;
using Microsoft.Extensions.Options;

Expand Down Expand Up @@ -75,4 +79,67 @@ public async Task PingCommandAsync(InteractionContext ctx)
{
await ctx.CreateResponseAsync($"Pong! Latency: {ctx.Client.Ping} ms");
}

[SlashCommandGroup("buttons", "Module used to edit button interactions on messages")]
[SlashCommandPermissions(Permissions.ManageMessages)]
public class ButtonCommands : ApplicationCommandModule
{
private readonly IButtonManager _buttonManager;

public ButtonCommands(IButtonManager manager)
{
_buttonManager = manager;
}

[SlashCommand("remove","Deletes all button interactions on the message")]
public async Task RemoveButtons(
InteractionContext ctx,
[Option("message-link", "URL of the message")] string url)
{
DiscordGuild guild = ctx.Guild;
DiscordMessage? message = await DiscordHelper.FindMessageFromLink(guild, url);
if (message is null)
{
throw new ArgumentOutOfRangeException($"Couldn't find message with link: {url}");
}

try
{
await _buttonManager.RemoveButtonsFromMessage(message);
}
catch (UnauthorizedException)
{
await ctx.CreateResponseAsync("Error: You can only edit messages by this bot.");
return;
}

await ctx.CreateResponseAsync("Removed buttons");
}

[SlashCommand("setup","Marks message as verification message")]
public async Task SetupButtons(
InteractionContext ctx,
[Option("message-link", "URL of the message")] string url
)
{
DiscordGuild guild = ctx.Guild;
DiscordMessage? message = await DiscordHelper.FindMessageFromLink(guild, url);
if (message == null)
{
throw new ArgumentOutOfRangeException($"Couldn't find message with link: {url}");
}

try
{
await _buttonManager.SetupVerificationButtons(message);
}
catch (UnauthorizedException)
{
await ctx.CreateResponseAsync("Error: You can only edit messages by this bot.");
return;
}

await ctx.CreateResponseAsync("Added verification buttons to the message.");
}
}
}
Loading

0 comments on commit bd9f962

Please sign in to comment.