Archived
0
0
Fork 0
This repository has been archived on 2024-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
Sharpy/CSharpBot/Program.cs

75 lines
2.1 KiB
C#
Raw Normal View History

2021-09-02 16:14:13 +00:00
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
2021-09-03 00:29:50 +00:00
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,
});
2021-09-02 16:14:13 +00:00
#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);