瀏覽代碼

fixed multiple bugs with the scrapper and improved speeds for the reddit cog.

tags/v2.0.0
Roxie Gibson 5 年之前
父節點
當前提交
3b040ad7a7
共有 1 個檔案被更改,包括 2 行新增5 行删除
  1. +2
    -5
      roxbot/cogs/reddit.py

+ 2
- 5
roxbot/cogs/reddit.py 查看文件

@@ -23,7 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
import time

import random
import fnmatch
@@ -178,7 +178,6 @@ class Reddit:
Example:
{command_prefix}subreddit pics
"""
start = time.time()
subreddit = subreddit.lower()
if isinstance(ctx.channel, discord.DMChannel):
cache_id = ctx.author.id
@@ -187,6 +186,7 @@ class Reddit:

self.scrapper.cache_refresh(cache_id)
posts = await self.scrapper.sub_request(subreddit)

if not posts:
return await ctx.send("Error ;-; That subreddit probably doesn't exist. Please check your spelling")

@@ -197,9 +197,6 @@ class Reddit:

choice = await self.scrapper.random(posts["children"], cache_id, nsfw_allowed)

end = time.time()
print("Time Taken: {}s".format(end-start))

if not choice:
return await ctx.send("I couldn't find any images from that subreddit.")
elif choice.get("success", True) is False:

Loading…
取消
儲存