|
| 1 | +// This file is part of the DSharpPlus project. |
| 2 | +// |
| 3 | +// Copyright (c) 2015 Mike Santiago |
| 4 | +// Copyright (c) 2016-2022 DSharpPlus Contributors |
| 5 | +// |
| 6 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | +// of this software and associated documentation files (the "Software"), to deal |
| 8 | +// in the Software without restriction, including without limitation the rights |
| 9 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | +// copies of the Software, and to permit persons to whom the Software is |
| 11 | +// furnished to do so, subject to the following conditions: |
| 12 | +// |
| 13 | +// The above copyright notice and this permission notice shall be included in all |
| 14 | +// copies or substantial portions of the Software. |
| 15 | +// |
| 16 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | +// SOFTWARE. |
| 23 | + |
| 24 | +using System; |
| 25 | +using System.Threading.Tasks; |
| 26 | +using DSharpPlus; |
| 27 | +using DSharpPlusDocs.Controllers; |
| 28 | +using Microsoft.Extensions.Logging; |
| 29 | + |
| 30 | +namespace DSharpPlusDocs |
| 31 | +{ |
| 32 | + public class DSharpPlusDocs : IDisposable |
| 33 | + { |
| 34 | + private DiscordClient _client; |
| 35 | + private MainHandler _mainHandler; |
| 36 | + |
| 37 | + public async Task RunAsync() |
| 38 | + { |
| 39 | + _client = new DiscordClient(new DiscordConfiguration |
| 40 | + { |
| 41 | + MinimumLogLevel = LogLevel.Debug, |
| 42 | + MessageCacheSize = 1024, |
| 43 | + TokenType = TokenType.Bot, |
| 44 | + Token = Environment.GetEnvironmentVariable("DISCORD_TOKEN") |
| 45 | + }); |
| 46 | + |
| 47 | + _client.Ready += (client, eventArgs) => |
| 48 | + { |
| 49 | + Console.WriteLine("Connected!"); |
| 50 | + return Task.CompletedTask; |
| 51 | + }; |
| 52 | + |
| 53 | + _mainHandler = new MainHandler(_client); |
| 54 | + await _mainHandler.InitializeEarlyAsync(); |
| 55 | + |
| 56 | + await _client.ConnectAsync(); |
| 57 | + await Task.Delay(-1); |
| 58 | + } |
| 59 | + |
| 60 | + public void Dispose() |
| 61 | + { |
| 62 | + _client.Dispose(); |
| 63 | + GC.SuppressFinalize(this); |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments