Created
July 5, 2024 20:31
-
-
Save karim-eg/e3d6f3e50742e945c1a4afb01aa6928e to your computer and use it in GitHub Desktop.
Discord Bot For Memes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Made By Karim Abdallah, Android Engineer. | |
contact: karim@kotect.com | |
website: https://kotect.com | |
""" | |
import json | |
import discord | |
import requests | |
bot_token = "YOUR_TOKEN_HERE" | |
def get_meme(): | |
response = requests.get('https://meme-api.com/gimme') | |
json_data = json.loads(response.text) | |
return json_data['url'] | |
class BotClient(discord.Client): | |
async def on_ready(self): | |
print('Logged on as {0}!'.format(self.user)) | |
async def on_message(self, message): | |
if message.author == self.user: | |
return | |
if message.content.startswith('/meme'): | |
await message.channel.send(get_meme()) | |
intents = discord.Intents.default() | |
intents.message_content = True | |
client = BotClient(intents=intents) | |
client.run(bot_token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result: