74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using System.Threading.Tasks;
|
|
using DSharpPlus;
|
|
using DSharpPlus.CommandsNext;
|
|
using DSharpPlus.Entities;
|
|
using DSharpPlus.Interactivity.Extensions;
|
|
using DSharpPlus.Lavalink;
|
|
using DSharpPlus.SlashCommands;
|
|
using DSharpPlus.VoiceNext;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
IConfiguration config = new ConfigurationBuilder()
|
|
.AddJsonFile("appsettings.json", false, true)
|
|
.Build();
|
|
|
|
#if DEBUG
|
|
var discord = new DiscordClient(new DiscordConfiguration
|
|
{
|
|
AlwaysCacheMembers = true,
|
|
AutoReconnect = true,
|
|
GatewayCompressionLevel = GatewayCompressionLevel.Stream,
|
|
HttpTimeout = TimeSpan.FromSeconds(10),
|
|
Intents = DiscordIntents.All,
|
|
LogTimestampFormat = "MMM dd yyyy - hh:mm:ss tt",
|
|
MinimumLogLevel = LogLevel.Debug,
|
|
ReconnectIndefinitely = false,
|
|
Token = config.GetValue<string>("token"),
|
|
TokenType = TokenType.Bot
|
|
});
|
|
#else
|
|
var discord = new DiscordClient(new DiscordConfiguration
|
|
{
|
|
AlwaysCacheMembers = true,
|
|
AutoReconnect = true,
|
|
GatewayCompressionLevel = GatewayCompressionLevel.Stream,
|
|
HttpTimeout = TimeSpan.FromSeconds(10),
|
|
Intents = DiscordIntents.All,
|
|
LogTimestampFormat = "MMM dd yyyy - hh:mm:ss tt",
|
|
MinimumLogLevel = LogLevel.Information,
|
|
ReconnectIndefinitely = false,
|
|
Token = config.GetValue<string>("token"),
|
|
TokenType = TokenType.Bot,
|
|
});
|
|
#endif
|
|
|
|
var services = new ServiceCollection()
|
|
.BuildServiceProvider();
|
|
|
|
/*var slash = discord.UseSlashCommands();
|
|
var lavalink = discord.UseLavalink();
|
|
var interactivity = discord.UseInteractivity();
|
|
var voice = discord.UseVoiceNext();*/
|
|
|
|
// register commands
|
|
var commands = discord.UseCommandsNext(new CommandsNextConfiguration
|
|
{
|
|
CaseSensitive = false,
|
|
DmHelp = false,
|
|
EnableDefaultHelp = true,
|
|
EnableDms = true,
|
|
EnableMentionPrefix = true,
|
|
IgnoreExtraArguments = false,
|
|
Services = services,
|
|
StringPrefixes = new[] { "!" },
|
|
UseDefaultCommandHandler = true
|
|
});
|
|
|
|
commands.RegisterCommands(Assembly.GetExecutingAssembly());
|
|
|
|
await discord.ConnectAsync(new DiscordActivity("With DSharpPlus"));
|
|
await Task.Delay(-1);
|