This commit is contained in:
65
SlashRandom/SlashRandom.cs
Normal file
65
SlashRandom/SlashRandom.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
using PluginManager;
|
||||
using PluginManager.Interfaces;
|
||||
|
||||
using SlashCommands.Items;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMD_Utils
|
||||
{
|
||||
public class SlashRandom : DBSlashCommand
|
||||
{
|
||||
public string Command => "random";
|
||||
|
||||
public string Description => "Random number";
|
||||
|
||||
public string Usage => "random [min] [max]";
|
||||
|
||||
public bool requireAdmin => false;
|
||||
|
||||
public bool PrivateResponse => true;
|
||||
|
||||
public async Task InitializeCommand(DiscordSocketClient client)
|
||||
{
|
||||
var guildCommand = new SlashCommandBuilder();
|
||||
guildCommand.WithName(Command);
|
||||
guildCommand.WithDescription(Description);
|
||||
guildCommand.AddOption(new SlashCommandOptionBuilder()
|
||||
.WithName("min")
|
||||
.WithDescription("Minimum number")
|
||||
.WithRequired(true)
|
||||
.WithType(ApplicationCommandOptionType.Integer));
|
||||
guildCommand.AddOption(new SlashCommandOptionBuilder()
|
||||
.WithName("max")
|
||||
.WithDescription("Maximum number")
|
||||
.WithRequired(true)
|
||||
.WithType(ApplicationCommandOptionType.Integer));
|
||||
await client.GetGuild(ulong.Parse(Config.GetValue<string>("ServerID"))).CreateApplicationCommandAsync(guildCommand.Build());
|
||||
}
|
||||
|
||||
public async Task ExecuteServer(SocketSlashCommand command)
|
||||
{
|
||||
var commandArguments = command.Data.Options.ToArray();
|
||||
|
||||
if (commandArguments.Count() == 0)
|
||||
{
|
||||
await command.RespondAsync("Please provide a min and max value", ephemeral: true);
|
||||
return;
|
||||
}
|
||||
|
||||
var min = (int)commandArguments[0].Value;
|
||||
var max = (int)commandArguments[1].Value;
|
||||
|
||||
|
||||
await command.RespondAsync("User generated number: " + new System.Random().Next(min, max + 1), ephemeral: PrivateResponse);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
13
SlashRandom/SlashRandom.csproj
Normal file
13
SlashRandom/SlashRandom.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SlashCommands\SlashCommands.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user