|
1 | 1 | import asyncio
|
2 | 2 | import random
|
3 | 3 | from datetime import datetime
|
4 |
| -from exchanges import * |
| 4 | + |
5 | 5 | import discord
|
6 | 6 | import requests
|
7 | 7 | from discord import Forbidden, HTTPException, InvalidArgument, NotFound
|
8 | 8 | from discord.ext import commands
|
| 9 | +from exchanges import * |
9 | 10 | from prawcore import exceptions
|
10 | 11 |
|
11 |
| -from utils import getRandomFact, RedditClient |
| 12 | +from utils import getRandomFact, RedditClient, getLogger |
12 | 13 |
|
13 | 14 |
|
14 | 15 | class FunCommandsCog(commands.Cog):
|
| 16 | + """Misc commands for fun with not specific usage""" |
15 | 17 | def __init__(self, bot):
|
16 | 18 | self.bot = bot
|
17 | 19 |
|
@@ -119,7 +121,7 @@ async def rob(self, ctx, member: discord.Member):
|
119 | 121 | embed.set_author(name=self.bot.user.name, icon_url=self.bot.user.avatar_url)
|
120 | 122 | await ctx.send(content=None, embed=embed)
|
121 | 123 |
|
122 |
| - @commands.command(name="dallas", help="Dallas is a fucking furry") |
| 124 | + @commands.command(name="dallas", help="Dallas is a fucking furry", hidden=True) |
123 | 125 | @commands.guild_only()
|
124 | 126 | async def dallas(self, ctx):
|
125 | 127 | embed = discord.Embed(title=None,
|
@@ -290,7 +292,8 @@ async def alex_jones(self, ctx):
|
290 | 292 | embed = discord.Embed(title=None,
|
291 | 293 | description=None,
|
292 | 294 | color=discord.Color.green(), timestamp=datetime.utcnow())
|
293 |
| - embed.set_image(url="https://media.discordapp.net/attachments/644927766197698593/647167462315393053/ezgif.com-video-to-gif.gif") |
| 295 | + embed.set_image( |
| 296 | + url="https://media.discordapp.net/attachments/644927766197698593/647167462315393053/ezgif.com-video-to-gif.gif") |
294 | 297 | embed.set_footer(text=ctx.message.author.name, icon_url=ctx.message.author.avatar_url)
|
295 | 298 | embed.set_author(name=self.bot.user.name, icon_url=self.bot.user.avatar_url)
|
296 | 299 | await ctx.send(content=None, embed=embed)
|
@@ -532,7 +535,8 @@ async def meme(self, ctx, subreddit: str = "funny", listing_type: str = "new"):
|
532 | 535 | print(f"[FunCommands] Cought error in meme command! Error: {e}")
|
533 | 536 | return await ctx.send(f"An error occured!")
|
534 | 537 |
|
535 |
| - @commands.command(name="bitcoin", help="List exchanges, get current price for an exchange", description="Get current bitcoin price for an exchange") |
| 538 | + @commands.command(name="bitcoin", help="List exchanges, get current price for an exchange", |
| 539 | + description="Get current bitcoin price for an exchange") |
536 | 540 | @commands.guild_only()
|
537 | 541 | async def bitcoin(self, ctx, arg=None):
|
538 | 542 | if arg is not None:
|
@@ -634,6 +638,31 @@ async def bitcoin(self, ctx, arg=None):
|
634 | 638 | embed.set_thumbnail(url="https://miro.medium.com/max/3150/2*O3o3Gdam4S5MSXfUg_UxGg.png")
|
635 | 639 | return await ctx.send(content=None, embed=embed)
|
636 | 640 |
|
| 641 | + @commands.command(name="nick", help="Change nickname of a user", usage="<nickname> [user]") |
| 642 | + @commands.guild_only() |
| 643 | + @commands.bot_has_permissions(manage_nicknames=True) |
| 644 | + async def nick(self, ctx, nick: str, member: discord.Member = None): |
| 645 | + user = ctx.author if member is None else member |
| 646 | + try: |
| 647 | + await user.edit(nick=nick) |
| 648 | + embed = discord.Embed(title=f"Nickname updated for {user}!", description=None, |
| 649 | + color=discord.Color.green(), |
| 650 | + timestamp=datetime.utcnow()) |
| 651 | + await ctx.send(content=None, embed=embed, delete_after=10) |
| 652 | + except Forbidden: |
| 653 | + # missing permission |
| 654 | + getLogger().debug(f"[Nick] Missing permissions to change nickname for {user}!") |
| 655 | + embed = discord.Embed(title=f"Missing permissions to change nickname for {user}!", description=None, color=discord.Color.red(), |
| 656 | + timestamp=datetime.utcnow()) |
| 657 | + await ctx.send(content=None, embed=embed, delete_after=10) |
| 658 | + except HTTPException: |
| 659 | + # Failed to edit user |
| 660 | + getLogger().debug(f"[Nick] failed to set nickname!") |
| 661 | + embed = discord.Embed(title=f"failed to set nickname for {user}!", description=None, |
| 662 | + color=discord.Color.red(), |
| 663 | + timestamp=datetime.utcnow()) |
| 664 | + await ctx.send(content=None, embed=embed, delete_after=10) |
| 665 | + |
637 | 666 |
|
638 | 667 | def getPostsByListingType(subreddit: str, type: str):
|
639 | 668 | if type == "top":
|
|
0 commit comments