Skip to content

Commit 2b8df8b

Browse files
committed
[FIXED]: guild join embed bug
1 parent c528c67 commit 2b8df8b

File tree

5 files changed

+123
-33
lines changed

5 files changed

+123
-33
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<br>
88

9-
<a href="https://discord.com/api/oauth2/authorize?client_id=946829157445296188&permissions=283974528116&scope=bot"><i>dex</i></a> <small>discord bot</small>
9+
<a href="https://discord.com/api/oauth2/authorize?client_id=946829157445296188&permissions=335514139760&scope=bot"><i>dex</i></a> <small>discord bot</small>
1010

1111
<br>
1212

13-
[![Invite: Dex](https://img.shields.io/static/v1?label=%20Invite&message=dex&color=5865F2&style=for-the-badge&logo=discord)](https://discord.com/api/oauth2/authorize?client_id=946829157445296188&permissions=283974528116&scope=bot) 🌟 [![Join: Server](https://img.shields.io/static/v1?label=%20Join&message=here&color=5865F2&style=for-the-badge&logo=discord)](https://discord.gg/FUqqEyBBA3)
13+
[![Invite: Dex](https://img.shields.io/static/v1?label=%20Invite&message=dex&color=5865F2&style=for-the-badge&logo=discord)](https://discord.com/api/oauth2/authorize?client_id=946829157445296188&permissions=335514139760&scope=bot) 🌟 [![Join: Server](https://img.shields.io/static/v1?label=%20Join&message=here&color=5865F2&style=for-the-badge&logo=discord)](https://discord.gg/FUqqEyBBA3)
1414

1515
[![License: MIT](https://img.shields.io/static/v1?label=License&message=MIT&color=red&style=for-the-badge&logo=giphy)](https://github.com/code-chaser/dex/blob/main/LICENSE) [![Made in: Python](https://img.shields.io/static/v1?label=Made%20in&message=Python&color=yellow&style=for-the-badge&logo=python&logoColor=yellow)](https://github.com/code-chaser/dex/) [![Fork: Count](https://img.shields.io/github/forks/code-chaser/dex?color=blue&label=Forks&style=for-the-badge&logo=gitextensions)](https://github.com/code-chaser/dex/network/members) [![Star: Count](https://img.shields.io/github/stars/code-chaser/dex?color=brightgreen&label=Stars&style=for-the-badge&logo=icinga)](https://github.com/code-chaser/dex/stargazers) [![Follower: Count](https://img.shields.io/github/followers/code-chaser?color=cb5786&label=Followers&style=for-the-badge&logo=github)](https://github.com/code-chaser/)
1616

@@ -25,7 +25,7 @@ ___
2525
Default set prefix is `$dex ` &nbsp; (yes, mind that trailing space)
2626

2727
- Try it in our public Bot server: [Join Here](https://discord.gg/FUqqEyBBA3)
28-
- Try it on your own server: [Invite Bot](https://discord.com/api/oauth2/authorize?client_id=946829157445296188&permissions=283974528116&scope=bot)
28+
- Try it on your own server: [Invite Bot](https://discord.com/api/oauth2/authorize?client_id=946829157445296188&permissions=335514139760&scope=bot)
2929

3030
Once the bot joins your server, you can get started with `$dex help` to get the complete list of available commands.
3131
You can also check out commands & features [here](https://github.com/code-chaser/dex/tree/main/docs/commandsAndFeatures.md).

src/bot.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, *args, **kwargs):
2323
intents=discord.Intents.all(),
2424
activity=discord.Activity(
2525
type=discord.ActivityType.listening,
26-
name="Stop WW3!",
26+
name="$dex help",
2727
large_image_url=self.EXHAUSTED_FACE,
2828
small_image_url=self.EXHAUSTED_FACE,
2929
start=datetime.datetime(2022, 2, 24),
@@ -130,12 +130,11 @@ async def on_command_error(self, ctx, error) -> None:
130130
await ctx.send(embed=embed)
131131

132132
def intro_msg_embed(self, guild):
133-
description = ''
134-
description = description.join(
135-
'\nThanks for adding me to ' + guild.name + '!')
136-
description = description.join('\nUse `$dex help` to get started!')
137-
description = description.join(
138-
'\nVisit: '.join(self.REPOSITORY_URL))
133+
description = ('\nThanks for adding me to ' + guild.name + '!')
134+
description += ('\nUse `$dex help` to get started!')
135+
description += ('\nSource Code: [Link](')
136+
description += (self.REPOSITORY_URL)
137+
description += (')')
139138
embed = discord.Embed(
140139
title='**GREETINGS!**',
141140
description=description,

src/cogs/modset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ async def leave_this_server(self, ctx):
105105
embed = discord.Embed(title="**GOOD BYE!**", description=f"""
106106
Had a great time in {ctx.guild.name}!
107107
Now it's time, I guess!
108-
To report any issues: https://github.com/code-chaser/dex/issues/new
108+
Report any issues: [Here](https://github.com/code-chaser/dex/issues/new)
109109
""", color=0x8e38ce, timestamp=datetime.utcnow())
110110
embed.set_image(
111111
url="https://user-images.githubusercontent.com/63065397/156924332-3638cd0d-9cf9-4e08-b4de-6f20cedd921a.png")

src/cogs/music.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -583,28 +583,6 @@ async def skip_command(self, ctx):
583583
await ctx.send(embed=embed)
584584
ctx.voice_client.stop()
585585

586-
@commands.command(name="ping", aliases=["latency"], help="shows the latency of the bot")
587-
async def ping_command(self, ctx):
588-
async with ctx.typing():
589-
ping = round(self.bot.latency * 1000, 1)
590-
high = 400
591-
low = 30
592-
red = min((ping)/high, 1)
593-
green = 1-red
594-
if ping >= high:
595-
red = 1
596-
green = 0
597-
if ping <= low:
598-
red = 0
599-
green = 1
600-
embed = discord.Embed(
601-
title="Ping",
602-
description="**"+str(ping)+"ms**",
603-
colour=discord.Color.from_rgb(int(red*255), int(green*255), 0),
604-
timestamp=datetime.datetime.utcnow()
605-
)
606-
await ctx.send(embed=embed)
607-
608586
async def get_lyrics(self, song_title):
609587
API_URL = "https://some-random-api.ml/lyrics?title=" + song_title
610588
async with aiohttp.ClientSession() as session:

src/cogs/other.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import discord
2+
import aiohttp
3+
import json
4+
import os
5+
import datetime
6+
import typing
7+
from discord.ext import commands
8+
9+
10+
class Other(commands.Cog):
11+
def __init__(self, bot):
12+
self.bot = bot
13+
# ----------------------------------------------------------------------------------------------------------------------
14+
15+
async def get_covid19_details(self):
16+
API_URL = "https://api.covid19api.com/summary"
17+
async with aiohttp.ClientSession() as session:
18+
async with session.get(API_URL) as resp:
19+
data_json = await resp.json()
20+
return (data_json)
21+
22+
@commands.command(name="covid19", help="sends COVID-19 stats of the given country (global stats if country == null)")
23+
async def covid19_data(self, ctx, *args):
24+
countr = ""
25+
for arg in args:
26+
countr += arg + " "
27+
size = len(countr)
28+
country = countr[:size - 1]
29+
original = country
30+
found = False
31+
stats = await self.get_covid19_details()
32+
if country:
33+
for k in stats["Countries"]:
34+
if ((k["CountryCode"]).lower() == country.lower()) or ((k["Country"]).lower() == country.lower()):
35+
embed = discord.Embed(
36+
title=(k["Country"]).title(),
37+
description="COVID-19 Statistics",
38+
colour=0xff0000,
39+
timestamp=datetime.datetime.utcnow()
40+
)
41+
flag_url = "https://flagcdn.com/w640/" + \
42+
str(k["CountryCode"]).lower() + ".jpg"
43+
embed.set_thumbnail(url=flag_url)
44+
fields = [
45+
("New Confirmed Cases", k["NewConfirmed"], True),
46+
("Total Confirmed Cases", k["TotalConfirmed"], True),
47+
("Country Code", k["CountryCode"], True),
48+
("New Deaths", k["NewDeaths"], True),
49+
("Total Deaths", k["TotalDeaths"], True),
50+
("Report Time (UTC)", "Date: " +
51+
k["Date"][0:10] + " & Time: " + k["Date"][11:19], True),
52+
]
53+
for n, v, i in fields:
54+
embed.add_field(name=n, value=v, inline=i)
55+
await ctx.send(embed=embed)
56+
found = True
57+
else:
58+
k = stats["Global"]
59+
embed = discord.Embed(
60+
title="Global",
61+
description="COVID-19 Statistics",
62+
colour=0xff0000,
63+
timestamp=datetime.datetime.utcnow()
64+
)
65+
embed.set_thumbnail(
66+
url="https://user-images.githubusercontent.com/63065397/156144079-6f90504d-ad48-4f2e-bec5-bae31cebd858.png"
67+
)
68+
fields = [
69+
("New Confirmed Cases", k["NewConfirmed"], True),
70+
("Total Confirmed Cases", k["TotalConfirmed"], True),
71+
("New Deaths", k["NewDeaths"], True),
72+
("Total Deaths", k["TotalDeaths"], True),
73+
]
74+
for n, v, i in fields:
75+
embed.add_field(name=n, value=v, inline=i)
76+
await ctx.send(embed=embed)
77+
found = True
78+
if not found:
79+
embed = discord.Embed(
80+
title="Error",
81+
description="Country Not Found",
82+
colour=0xff0000
83+
)
84+
embed.add_field(name="Given Country Name",
85+
value=original, inline=True)
86+
await ctx.send(embed=embed)
87+
# ----------------------------------------------------------------------------------------------------------------------
88+
89+
@commands.command(name="ping", aliases=["latency"], help="shows the latency of the bot")
90+
async def ping_command(self, ctx):
91+
async with ctx.typing():
92+
ping = round(self.bot.latency * 1000, 1)
93+
high = 400
94+
low = 30
95+
red = min((ping)/high, 1)
96+
green = 1-red
97+
if ping >= high:
98+
red = 1
99+
green = 0
100+
if ping <= low:
101+
red = 0
102+
green = 1
103+
embed = discord.Embed(
104+
title="Ping",
105+
description="**"+str(ping)+"ms**",
106+
colour=discord.Color.from_rgb(int(red*255), int(green*255), 0),
107+
timestamp=datetime.datetime.utcnow()
108+
)
109+
await ctx.send(embed=embed)
110+
# ----------------------------------------------------------------------------------------------------------------------
111+
112+
def setup(bot):
113+
bot.add_cog(Other(bot))

0 commit comments

Comments
 (0)