Skip to content

Commit be346ca

Browse files
committed
Add fakediscordmessage command
1 parent df06810 commit be346ca

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

commands/img.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,45 @@ async def challenge(self, ctx, given_icon: str = None, *, text: str = None):
155155
"description": "Failed to generate challenge. API must be down...",
156156
"colour": "ff0000"
157157
})
158+
159+
@commands.command(name="discordmessage", description="Create a fake Discord message.", aliases=["fakediscordmessage", "fakediscordmsg", "fakediscord"], usage="[user] [message]")
160+
async def discordmessage(self, ctx, user: discord.Member = None, *, message: str = None):
161+
if not user:
162+
return await cmdhelper.send_message(ctx, {
163+
"title": "Error",
164+
"description": "Please specify a user to make the message from.",
165+
"colour": "#ff0000"
166+
})
167+
168+
if not message:
169+
return await cmdhelper.send_message(ctx, {
170+
"title": "Error",
171+
"description": "Please specify a message to send.",
172+
"colour": "#ff0000"
173+
})
174+
175+
args = {
176+
"avatar_url": user.avatar.url,
177+
"username": user.name,
178+
"text": message
179+
}
180+
181+
api = "https://benny.fun/api/discordmessage"
182+
183+
response = requests.get(f"https://benny.fun/api/discordmessage?avatar_url={args['avatar_url']}&username={args['username']}&text={args['text']}")
184+
185+
if response.status_code == 200:
186+
with open("data/cache/discordmessage.png", "wb") as file:
187+
file.write(response.content)
188+
189+
await ctx.send(file=discord.File("data/cache/discordmessage.png"))
190+
os.remove("data/cache/discordmessage.png")
191+
else:
192+
await cmdhelper.send_message(ctx, {
193+
"title": "Error",
194+
"description": "Failed to generate discord message.",
195+
"colour": "#ff0000"
196+
})
158197

159198
@commands.command(name="searchimage", description="Search for an image on google", usage="[query]", aliases=["searchimg", "imgsearch", "imagesearch"])
160199
async def searchimage(self, ctx, *, query):

0 commit comments

Comments
 (0)