Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using DSharpPlus;
- using DSharpPlus.Entities;
- namespace DiscordTest
- {
- class Program
- {
- static DiscordClient discord;
- private static List<DiscordChannel> private_channels = new List<DiscordChannel>();
- static void Main(string[] args)
- {
- MainTask(args).ConfigureAwait(false).GetAwaiter().GetResult();
- }
- static async Task MainTask(string[] args)
- {
- discord = new DiscordClient(new DiscordConfiguration
- {
- Token = "",
- TokenType = TokenType.Bot,
- UseInternalLogHandler = true,
- LogLevel = LogLevel.Debug
- }); ;
- discord.MessageCreated += Discord_MessageCreated;
- discord.VoiceStateUpdated += Discord_VoiceStateUpdated;
- await discord.ConnectAsync();
- privateChechek();
- await Task.Delay(-1);
- }
- public static async void privateChechek()
- {
- while (true)
- {
- foreach(DiscordChannel channel in private_channels)
- {
- }
- await Task.Delay(10000);
- }
- }
- private static async Task Discord_VoiceStateUpdated(DSharpPlus.EventArgs.VoiceStateUpdateEventArgs e)
- {
- if (e.Channel != null)
- {
- if (e.Channel.Id == 622753007871852596)
- {
- DiscordChannel parent = e.Guild.GetChannel(622752938867163138);
- Task<DiscordChannel> new_channel = e.Guild.CreateChannelAsync("Private", ChannelType.Voice, parent);
- private_channels.Add(new_channel.Result);
- await new_channel.Result.PlaceMemberAsync((DiscordMember)e.User);
- }
- Console.WriteLine(e.User.Username + " connected to " + e.Channel.Name);
- }
- }
- private static async Task Discord_MessageCreated(DSharpPlus.EventArgs.MessageCreateEventArgs e)
- {
- string message = e.Message.Content;
- if(!e.Author.IsBot)
- {
- if(e.Message.Content.StartsWith('!'))
- {
- string[] command = e.Message.Content.Remove(0, 1).Split(' ');
- //Console.WriteLine("Your command=" + command);
- switch(command[0])
- {
- case "профиль":
- //Console.WriteLine("Count users=" + e.Message.MentionedUsers.Count);
- if (e.Message.MentionedUsers.Count > 0)
- {
- DiscordUser user = e.Message.MentionedUsers.ElementAt(0);
- await e.Message.RespondAsync("Профиль пользователя " + user.Mention);
- }else
- {
- await e.Message.RespondAsync("Ваш профиль 321");
- }
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement