Beispiel #1
0
 private async Task _client_UserLeft(SocketGuildUser user)
 {
     if (user.Guild.Name == "Discord-BOT-Tutorial")
     {
         if (_client.GetChannel(GuildsData.FindGuildConfig(user.Guild.Id).LogChannelID) is SocketTextChannel discordBotTutorialGeneral)
         {
             await discordBotTutorialGeneral.SendMessageAsync(
                 $"{user.Username} ({user.Id}) left **{user.Guild.Name}**!");
         }
     }
 }
Beispiel #2
0
        public async Task HandleCommandAsync(SocketMessage s)
        {
            if (!(s is SocketUserMessage msg))
            {
                return;
            }
            var context = new SocketCommandContext(_client, msg);
            int argPos  = 0;

            if (msg.HasStringPrefix(GuildsData.FindOrCreateGuildConfig(context.Guild).Prefix, ref argPos) ||
                msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                await Utilities.Log(MethodBase.GetCurrentMethod(), "Command detected.", Discord.LogSeverity.Verbose);

                /*
                 * await Utilities.Log(MethodBase.GetCurrentMethod(), UserAccounts.GetAccount(_client.CurrentUser.Id, true).ToString());
                 * if (UserAccounts.GetAccount(_client.CurrentUser.Id, true).Equals(null))
                 * {
                 *  await Utilities.Log("HandleCommandAsync",
                 *      $"Welcome the new user by the name of {_client.CurrentUser.Username}!");
                 *  var embed = new EmbedBuilder();
                 *  embed.WithTitle($"This is your first time using our bot {_client.CurrentUser.Username}!")
                 *      .WithDescription("Welcome!!")
                 *      .WithColor(new Color(Config.BotConfig.BotThemeColorR, Config.BotConfig.BotThemeColorG, Config.BotConfig.BotThemeColorB)); // Should reduce it to a color class.
                 *  await context.Channel.SendMessageAsync("", false, embed);
                 * }DF
                 */
                var result = await _service.ExecuteAsync(context, argPos, null);

                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    await context.Channel.SendMessageAsync(result.ErrorReason);
                }
                else
                {
                    // ------------------ create statistics machine. Class DatabaseHandler
                    // ------------------ create
                    context.Guild.GetTextChannel(GuildsData.FindGuildConfig(context.Guild.Id).LogChannelID);
                }
            }
        }