2023.06.01 03:37 AI0 AutoModerator performed action `sticky`
2023.06.01 03:37 DanielCoben1993 Need some help with a discord bot and asyncpraw
import asyncpraw, json, discord, asyncio from discord.ext import commands from asyncprawcore.exceptions import RequestException, Timeout class RedditDiscordBot_Build2: def discord_reddit_settings(self, client_id: str, client_secret: str, user_agent: str, username: str, subreddit: str, subreddit_icon_url: str, token_string: str): self.__client_id = client_id self.__client_secret = client_secret self.__user_agent = user_agent self.__username = username self.__subreddit = subreddit self.__subreddit_icon_url = subreddit_icon_url self.__TOKEN = token_string self.__intents = discord.Intents.default() self.__intents.message_content = True self.__client = discord.Client(intents = self.__intents) self.__reddit_api = asyncpraw.Reddit( client_id = self.__client_id, client_secret = self.__client_secret, user_agent = self.__user_agent, username = self.__username ) def discord_bot_settings(self): @self.__client.event async def on_ready(): print(f"{self.__client.user} is now running") @self.__client.event async def on_message(message): if (message.author == self.__client.user): return username = str(message.author) user_msg = str(message.content) channel = str(message.channel) print(f"{username} said: {user_msg} ({channel})") if (user_msg == "?begin"): await message.channel.send("Beginning monitoring") await self.send_embed(message) self.__client.run(self.__TOKEN) async def send_embed(self, message): async def build_embed(instance): title_string = f"{instance.title[0:200]}......" if (len(instance.title) >= 250) else instance.title spoiler_string = f"**{title_string} (spoiler)**" if (instance.spoiler) else f"**{title_string}**" preview_text = f"{instance.selftext[0:300]}......" if (len(instance.selftext) > 300) else instance.selftext preview_url = f"https://www.reddit.com{instance.permalink}" embed_object = discord.Embed(url = preview_url) embed_object.set_footer(text = f"Post by: {instance.author.name}") setattr(embed_object, "title", spoiler_string) if (hasattr(instance, "selftext")): setattr(embed_object, "description", preview_text) if (hasattr(instance, "preview")): temp_url = instance.preview["images"][0]["resolutions"][len(instance.preview["images"][0]["resolutions"]) - 1]["url"] embed_object.set_image(url = temp_url) embed_object.add_field(name = '', value = f"[Thread Link](https://www.reddit.com{instance.permalink})") embed_object.set_author( name = f"{self.__subreddit} - New", url = f"https://www.reddit.com/{self.__subreddit}/new/", icon_url = self.__subreddit_icon_url ) return embed_object self.__subreddit_object = await self.__reddit_api.subreddit(self.__subreddit) async for instance in self.__subreddit_object.stream.submissions(): embed_object = await build_embed(instance) try: await message.channel.send(embed = embed_object) except (RequestException, Timeout, Exception) as e: await message.channel.send(f"Error: {e}") await message.channel.send(f"https://www.reddit.com{instance.permalink}")I'm not very familiar with asyncpraw or asynchronous programming in general, so I can't quite figure out what I'm doing wrong here as I'm getting these errors when I run this program:
RuntimeError: Timeout context manager should be used inside a task During handling of the above exception, another exception occurred: asyncprawcore.exceptions.RequestException: error with request Timeout context manager should be used inside a task
2023.06.01 03:36 ArronEisenman [Hire Me] Hire the Best of the Best in Writing Services√
2023.06.01 03:35 Real-Knowledge-8592 How do I dynamically change the map dimensions in javascript? I'd prefer not use plug ins if possible.
2023.06.01 03:34 Aggravating_Lunch599 Anyone with experience with nest learning thermostat?
2023.06.01 03:34 Arker456 A new RPG maker mz tutorial is about to drop!
2023.06.01 03:32 Real-Knowledge-8592 How do I dynamically change the map dimensions in javascript? I'd prefer not use plug ins if possible.
2023.06.01 03:31 AI0 tresser performed action `approvecomment`
2023.06.01 03:30 AI0 AutoModerator performed action `removecomment`
2023.06.01 03:29 Arker456 A new RPG maker mz tutorial is about to drop!
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [][][][][] [][][][][] [] [] [] [] [][][][][] [] [] [] [] [] [] [][][][][] [] [] [] [] [] [][][][] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [][][][] [] [] [] [] [] [] [] [] [] [] [] [][][] [] [] [] [][] [][][] [] [] [] [] [] [][][][] [] [] [] [] [] []
2023.06.01 03:26 Yes-No-Maybes Find - MW batch - J4 snakeskin - ¥390 - TMF
![]() | Not my style but looks great in terms of shape and material. If you wanted this pair def pick up. submitted by Yes-No-Maybes to repbudgetsneakers [link] [comments] https://shop1628395132.v.weidian.com/item.html?itemID=6360336219&a=b&wfr=BuyercopyURL&distributorId=1558985871&share_relation=17d287f3ad285bff_1558985871_1 |
2023.06.01 03:24 Yes-No-Maybes Find - MW batch - J4 snakeskin - ¥390 - TMF
![]() | Not my style but they do look great in terms of shape and material. submitted by Yes-No-Maybes to repweidiansneakers [link] [comments] https://shop1628395132.v.weidian.com/item.html?itemID=6360336219&a=b&wfr=BuyercopyURL&distributorId=1558985871&share_relation=17d287f3ad285bff_1558985871_1 |
2023.06.01 03:23 I_Will_Procrastinate Are Virtual Bones + Controls meant to be combined in a Control Rig?
2023.06.01 03:23 GingerSnap_K [A3] [Event] [US] Varangian Guard, Monthly Public Event.
2023.06.01 03:23 D_2d Remove string characters from labels
2023.06.01 03:19 mdnlss Questions with Emacs Overlay Flake
Warning (initialization): An error occurred while loading ‘~/.emacs’:Here is my flake.nix,
Symbol's value as variable is void: rustic
To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the ‘--debug-init’ option to view a complete error backtrace. Disable showing Disable logging ‘--debug-init’ option to view a complete error backtrace. Disable showing Disable
{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; emacs-overlay.url = "github:nix-community/emacs-overlay"; }; outputs = { self, nixpkgs, flake-utils, emacs-overlay }: flake-utils.lib.eachDefaultSystem (system: let overlays = [ (import emacs-overlay) ]; pkgs = import nixpkgs { inherit system overlays; }; in with pkgs; { devShells.default = mkShell { buildInputs = [ (pkgs.emacsWithPackagesFromUsePackage { config = ./emacs/init.el; defaultInitFile = true; alwaysEnsure = true; package = pkgs.emacs; extraEmacsPackages = epkgs: [ epkgs.python ]; }) pkgs.nodePackages.typescript pkgs.nodePackages.typescript-language-server pkgs.nodePackages.npm ] ++ (with pkgs; [ ripgrep fd exa ]); #these packages are optional and were added for personal tooling shellHook = '' alias ls="exa -la"; ''; }; } ); }Here is the el file,
;; basic settings (menu-bar-mode -1) (tool-bar-mode -1) (global-display-line-numbers-mode 1) (setq display-line-numbers-type 'relative) ;; ;; ;; install melpa (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) ;; ;; install use-package (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package)) (eval-and-compile (setq use-package-always-ensure t use-package-expand-minimally t)) ;; (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(package-selected-packages '(rustic python-mode editorconfig treemacs-evil spacemacs-theme flycheck lsp-ui evil company))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ;; evil mode (require 'evil) (evil-mode 1) ;; ;; add company text completion (add-hook 'after-init-hook 'global-company-mode) ;; ;; rust configuration (use-package rustic) (add-to-list 'package-selected-packages 'rustic) (setq rustic-format-trigger 'on-save) (use-package lsp-ui :ensure :commands lsp-ui-mode :custom (lsp-ui-peek-always-show t) (lsp-ui-sideline-show-hover t) (lsp-ui-doc-enable t)) (use-package flycheck :ensure) (setq lsp-rust-analyzer-server-display-inlay-hints t) ;; ;; treemacs config (use-package treemacs-evil) ;; ;; yaml mode ;;(require 'yaml-mode) ;; (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)) ;;I tried running the same config on a system configured without Nix and the same init.el works. Does anyone have any idea as to what could be causing this issue?
2023.06.01 03:16 thememeconnoisseurig Warranties and X Pipes
2023.06.01 03:16 AI0 tresser performed action `approvecomment`
2023.06.01 03:15 AI0 AutoModerator performed action `removecomment`
2023.06.01 03:14 Far-King2927 [psa] NEW, BETTER AND EASIER CSGO INVESTMENT SHEET
2023.06.01 03:14 Far-King2927 Free easy and new csgo investment spreadsheet
2023.06.01 03:13 Ok_Cartographer4016 Root Directory vs Subdirectory