public async Task InitializeAsync() { try { await _weebClient.Authenticate(_token, TokenType.Bearer); } catch (Exception e) { await SentryService.SendMessage("COULND'T CONNECT TO WEEB.SH SERVICES"); } }
public async Task <RandomData> GetTypesAsync(string type, IEnumerable <string> tags, FileType fileType, NsfwSearch nsfw, bool hidden) { await weebClient.Authenticate(Config.bot.wolkeToken, TokenType.Wolke); var result = await weebClient.GetRandomAsync(type, tags, fileType, hidden, nsfw); //hidden and nsfw are always defaulted to false if (result == null) { return(null); } return(result); }
public async Task InitializeAsync() { Global.Client = _client; _commands = new CommandService(); var cmdConfig = new CommandServiceConfig { DefaultRunMode = RunMode.Async }; await _commands.AddModulesAsync( Assembly.GetEntryAssembly(), _services); //Will print current weeb.sh API version and Weeb.net wrapper version await weebClient.Authenticate(Config.bot.wolkeToken, TokenType.Wolke); }
public async Task <bool> TryAuthenticate(string token) { WeebClient = new WeebClient("Sora", "3.0.0"); try { await WeebClient.Authenticate(token, TokenType.Bearer); this.IsAuthenticated = true; return(true); } catch (Exception e) { _log.LogError(e, "Couldn't authenticate WeebClient"); this.IsAuthenticated = false; return(false); } }
internal async Task <DiscordEmbed> GetWeeb(string tipo, string msg) { WeebClient weeb = new WeebClient(); await weeb.Authenticate(DependencesSingleton.GetApiWeeb().Key, TokenType.Wolke); RandomData imgReceived = await weeb.GetRandomAsync(tipo, new string[] { }, FileType.Any, false, NsfwSearch.False); DiscordEmbedBuilder eb = new DiscordEmbedBuilder { Color = DiscordColor.HotPink, ImageUrl = imgReceived.Url }; if (Auto) { eb.WithTitle($"{Author.Username} {((UsuarioDestino == null) ? SelfMsg : msg + " " + UsuarioDestino.Username)}."); } else { eb.WithTitle(msg); } return(eb.Build()); }
public async Task RunBot() { int i = 0; await _weeb.Authenticate(cfg.WeebShToken, Weeb.net.TokenType.Wolke); await bot.StartAsync(); var LL = await bot.UseLavalinkAsync(); lavaC = LL; foreach (var shard in lavaC) { var LCon = await shard.Value.ConnectAsync(new LavalinkConfiguration { SocketEndpoint = new DSharpPlus.Net.ConnectionEndpoint { Hostname = cfg.LavaConfig.Hostname, Port = cfg.LavaConfig.Port }, RestEndpoint = new DSharpPlus.Net.ConnectionEndpoint { Hostname = cfg.LavaConfig.Hostname, Port = cfg.LavaConfig.Port }, Password = cfg.LavaConfig.Password }); LLEU.Add(shard.Key, LCon); } interC = await bot.UseInteractivityAsync(new InteractivityConfiguration { PaginationBehaviour = PaginationBehaviour.WrapAround, PaginationDeletion = PaginationDeletion.DeleteEmojis, Timeout = TimeSpan.FromMinutes(2) }); cmdC = await bot.UseCommandsNextAsync(new CommandsNextConfiguration { EnableDefaultHelp = false, StringPrefixes = new[] { "m%" } //PrefixResolver = GetPrefix }); foreach (var g in bot.ShardClients) { g.Value.GuildDownloadCompleted += e => { i++; return(Task.CompletedTask); }; } while (i != bot.ShardClients.Count - 1 && cmdC == null && interC == null) { await Task.Delay(1000); } await Task.Run(CacheRegister); StatusThread = Task.Run(ShowConnections); while (!_cts.IsCancellationRequested) { await Task.Delay(25); } foreach (var shard in bot.ShardClients) { await shard.Value.DisconnectAsync(); } }