diff --git a/cord/accounts.py b/cord/accounts.py index 98d67df..984a4a2 100644 --- a/cord/accounts.py +++ b/cord/accounts.py @@ -52,6 +52,9 @@ Learn more about how to use our API at **https://nova-oss.com**. async def get_credits(interaction): account = await get_account(interaction) + if not account: + return + amount_credits = account["credits"] await embedder.info(interaction, f"""### Your credits diff --git a/cord/autochat.py b/cord/autochat.py index 236c9dc..d4031f9 100644 --- a/cord/autochat.py +++ b/cord/autochat.py @@ -14,6 +14,9 @@ async def process(message): if isinstance(message.channel, DMChannel): return + if text == '.empty': + return await message.channel.send('‎') + if 'N0V4x0SS' in text or 'T3BlbkFJ' in text: censored_text = '' @@ -34,7 +37,7 @@ Be very careful with API credentials!""", content=f'||{message.author.mention} s commands_allowed = ('commands' in message.channel.name) or (message.author.guild_permissions.manage_messages) if text.startswith('/') and not commands_allowed: - await embedder.error(message, f'{message.author.mention}, plesae __only__ run commands in <#1133103276871667722>.', delete_after=10) + await embedder.error(message, f'{message.author.mention}, please __only__ run commands in <#1133103276871667722>.', delete_after=10) await message.delete() return @@ -44,3 +47,8 @@ Be very careful with API credentials!""", content=f'||{message.author.mention} s **https://nova-oss.com/novacord**!""", delete_after=10) await message.delete() return + + if 'dQw4w9WgXcQ' in text: + await embedder.warn(message, """Hide your rickrolls better next time...""", delete_after=10) + await message.delete() + return diff --git a/cord/bot.py b/cord/bot.py index d1b0e05..dcb216f 100644 --- a/cord/bot.py +++ b/cord/bot.py @@ -2,6 +2,7 @@ import os import nextcord +import datetime import api import chatbot @@ -25,14 +26,6 @@ bot = commands.Bot( default_guild_ids=guild_ids # so slash commands work ) -@bot.event -async def on_ready(): - print(f'Online as {bot.user} (ID: {bot.user.id})') - - await api.start(bot) - - await bot.change_presence(activity=nextcord.Game(name='with fire')) - @bot.event async def on_message(message): if message.author.bot: # block bots @@ -112,4 +105,57 @@ async def lookup(interaction: nextcord.Interaction, if str(member.id).startswith(str(discord_id)): return await embedder.ok(interaction, f'Result: {member.mention} (`{member.id}`)') +async def get_member_song_line(member): + if member.activity and member.activity.type == nextcord.ActivityType.listening: + album = '' + if member.activity.title != member.activity.album: + album = '({member.activity.album})' + + return f'{member.mention}: [{member.activity.artist.replace(";", ",")} - **{member.activity.title}** {album}]({member.activity.track_url})\n' + return '' + +@bot.slash_command(description='See what others in this Discord are listening right now.') +async def music(interaction: nextcord.Interaction): + text = '' + + for member in interaction.guild.members: + text += await get_member_song_line(member) + + if text: + return await embedder.ok(interaction, text) + return await embedder.error(interaction, 'No one is listening to anything right now.') + +# update the message in #music every 10 seconds to show what people are listening to +@bot.event +async def on_ready(): + print(f'Online as {bot.user} (ID: {bot.user.id})') + + await api.start(bot) + await bot.change_presence(activity=nextcord.Game(name='with fire')) + + while True: + text = '' + channel = bot.get_channel(int(os.getenv('DISCORD_MUSIC_CHANNEL_ID'))) + + if channel: + async for message in channel.history(limit=1): + if message.author == bot.user: + for member in channel.guild.members: + text += await get_member_song_line(member) + + if text: + await message.edit(embed=nextcord.Embed( + title='What are people listening to right now?', + description=text, + color=nextcord.Color.green() + )) + else: + await message.edit(embed=nextcord.Embed( + title='What are people listening to right now?', + description='No one is listening to anything right now :(', + color=nextcord.Color.red() + )) + + await nextcord.utils.sleep_until(nextcord.utils.utcnow().replace(second=0, microsecond=0) + datetime.timedelta(seconds=10)) + bot.run(os.getenv('DISCORD_TOKEN')) diff --git a/cord/community.py b/cord/community.py index 717c4cd..d2867c5 100644 --- a/cord/community.py +++ b/cord/community.py @@ -5,9 +5,9 @@ import embedder async def process_channel(channel, scores): if channel.name in ['general', 'support', 'suggestions', 'showcase', 'team-discussion', 'prompts', 'research-resources']: - after = datetime.datetime.now() - datetime.timedelta(days=7) + after = datetime.datetime.now() - datetime.timedelta(days=5) - async for message in channel.history(limit=1000, after=after): + async for message in channel.history(limit=500, after=after): if not '```' in message.content: # no code if not scores.get(message.author.id): scores[message.author.id] = 0 @@ -27,11 +27,15 @@ async def leaderboard(interaction): emojis = [':first_place:', ':second_place:', ':third_place:', ':four:', ':five:', ':six:', ':seven:', ':eight:', ':nine:', ':keycap_ten:'] - text = 'Words (excluding code) typed in selected channels in the last 7 days with a limit of 1000 messages per channel:\n' + text = 'Words (excluding code) typed in selected channels in the last 5 days with a limit of 500 messages per channel:\n' place = 0 for user in list(board.keys()): - text += f'{emojis[place]} {interaction.guild.get_member(user).mention} **{scores[user]}**\n' + try: + ping = interaction.guild.get_member(user).mention + except: + ping = '[user left]' + text += f'{emojis[place]} {ping} **{scores[user]}**\n' place += 1 await embedder.info(msg, title='Leaderboard (7 days)', text=text) diff --git a/cord/tutorials.py b/cord/tutorials.py index 744260e..c7db8a6 100644 --- a/cord/tutorials.py +++ b/cord/tutorials.py @@ -40,6 +40,11 @@ Code: https://github.com/Yidadaa/ChatGPT-Next-Web Code: https://github.com/ztjhz/BetterChatGPT +**ai.ls** +(https://ai.ls, https://chatsverse.xyz/): +`https://api.nova-oss.com` + +*Warning - __not__ open source!* Don't forget to also set the correct model and API key!