Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Welcome to Mecha

Mecha is an innovative bot powered by the [Voltage](https://github.com/EnokiUN/Voltage) framework, designed to enhance your server experience with a variety of interactive features.

## Key Features

- **Advanced Leveling System**: Foster community engagement through a sophisticated global leveling system that rewards user participation and interaction within the server.
Expand Down
1,261 changes: 616 additions & 645 deletions cogs/economy.py

Large diffs are not rendered by default.

211 changes: 108 additions & 103 deletions cogs/fun.py
Original file line number Diff line number Diff line change
@@ -1,113 +1,118 @@
import voltage, pymongo, os, random, aiohttp, requests, json
from voltage.ext import commands
from bardapi import BardAsync
import google.generativeai as genai
import json
import random

import google.generativeai as genai
import revolt
from revolt.ext import commands

with open("json/config.json", "r") as f:
config = json.load(f)
config = json.load(f)

genai.configure(api_key=config["GOOGLEAPIKEY"])

model = genai.GenerativeModel('gemini-pro')
bard = BardAsync(token=config['BARDTOKEN'])

def setup(client) -> commands.Cog:
fun = commands.Cog(
"Fun",
"More command testing, use these if you want *basic* fun commands."
)

@fun.command(
description="Are you gay or no?",
aliases=["howgay", "gay", "amigay", "gaypercent", "gayamount", "GayRate"],
name="gayrate"
)
async def gayrate(ctx, member: voltage.Member = None):
if member is None:
member = ctx.author
rate = random.randint(1, 100)
embed = voltage.SendableEmbed(
title=f"{ctx.author.name}",
icon_url=ctx.author.avatar.url,
description=f"🏳️‍🌈 | {member.display_name} is `{str(rate)}%` gay!",
color="#516BF2",
)
await ctx.reply(embed=embed)

@fun.command(name="8ball", description="Seek your fortune!")
async def _8ball(ctx, *, question):
responses = [
"I belive not",
"I dont think so",
"No",
"Maybe",
"Ask again later",
"Yes",
"Affirmative",
"I Belive So",
"Its possible",
]
embed = voltage.SendableEmbed(
title=f"{ctx.author.name}",
icon_url=ctx.author.avatar.url,
description=f"""My response to `{str(question)}`...\n `{random.choice(responses)}`!""",
color="#516BF2",
)
await ctx.reply(embed=embed)

def split_text(text, max_chars):
"""
Splits a large text into groups by newlines if they're over a character limit,
without cutting out words while keeping its format.

Args:
text (str): The input text.
max_chars (int): The maximum number of characters per group.

Returns:
list: A list of strings, each representing a group of text.
"""
lines = text.split("\n")
result = []
current_group = ""

for line in lines:
if len(current_group) + len(line) <= max_chars:
current_group += line + "\n"
else:


class Fun(commands.Cog):
description = "More command testing, use these if you want *basic* fun commands."

def __init__(self, client):
self.client = client

@staticmethod
def split_text(text, max_chars):
"""
Splits a large text into groups by newlines if they're over a character limit,
without cutting out words while keeping its format.

Args:
text (str): The input text.
max_chars (int): The maximum number of characters per group.

Returns:
list: A list of strings, each representing a group of text.
"""
lines = text.split("\n")
result = []
current_group = ""

for line in lines:
if len(current_group) + len(line) <= max_chars:
current_group += line + "\n"
else:
result.append(current_group.strip())
current_group = line + "\n"

if current_group:
result.append(current_group.strip())
current_group = line + "\n"

if current_group:
result.append(current_group.strip())

return result

@fun.command(
name="ai",
aliases=['talkai'],
description="Talk to an AI"
)
async def ai(ctx, *, question):
embed = voltage.SendableEmbed(
title=f"{ctx.author.name}",
icon_url=ctx.author.avatar.url,
description=f"Your question: `{question}`\n\nGenerating Response..",
colour="#516BF2"
)
await ctx.reply(embed=embed)
chat = model.start_chat()
response = chat.send_message(question)

groups = split_text(response.text, 800)
return result

for i, group in enumerate(groups):
embed = voltage.SendableEmbed(
description=group,
colour="#516BF2"
)
await ctx.send(embed=embed)
@commands.command(
aliases=["howgay", "gay", "amigay", "gaypercent", "gayamount", "GayRate"],
name="gayrate"
)
async def gayrate(self, ctx: commands.Context, member: revolt.Member = None):
"""Are you gay or no?"""
if member is None:
member = ctx.author

rate = random.randint(1, 100)
embed = revolt.SendableEmbed(
title=f"{ctx.author.name}",
icon_url=ctx.author.avatar.url if ctx.author.avatar else None,
description=f"🏳️‍🌈 | {member.display_name} is `{str(rate)}%` gay!",
color="#516BF2",
)
await ctx.reply(embed=embed)

@commands.command(name="8ball")
async def _8ball(self, ctx, *, question):
"""Seek your fortune!"""
responses = [
"I believe not",
"I dont think so",
"No",
"Maybe",
"Ask again later",
"Yes",
"Affirmative",
"I Believe So",
"Its possible",
]
embed = revolt.SendableEmbed(
title=ctx.author.name,
icon_url=ctx.author.avatar.url if ctx.author.avatar else None,
description=f"My response to `{str(question)}`...\n `{random.choice(responses)}`!",
color="#516BF2",
)
await ctx.reply(embed=embed)

@commands.command(
name="ai",
aliases=['talkai'],
)
async def ai(self, ctx, *, question):
""""Talk to an AI"""
embed = revolt.SendableEmbed(
title=f"{ctx.author.name}",
icon_url=ctx.author.avatar.url,
description=f"Your question: `{question}`\n\nGenerating Response..",
colour="#516BF2"
)
await ctx.reply(embed=embed)
chat = model.start_chat()
response = chat.send_message(question)

groups = self.split_text(response.text, 800)

for group in groups:
embed = revolt.SendableEmbed(
description=group,
colour="#516BF2"
)
await ctx.send(embed=embed)


async def setup(client):
await client.add_cog(Fun(client))


return fun
20 changes: 10 additions & 10 deletions cogs/giveaway.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import voltage, pymongo, os
from voltage.ext import commands
from revolt.ext import commands

def setup(client) -> commands.Cog:
giveaway = commands.Cog(
"Giveaway",
"More command testing, use these if you want *basic* fun commands."
)

@giveaway.command()
async def giveawaystuffs(ctx):
class Giveaway(commands.Cog):
def __init__(self, client):
self.client = client

@commands.command(hidden=True)
async def giveawaystuffs(self, ctx):
"""Adds you to the giveaway"""
await ctx.reply("nuh uh :)")

return giveaway

async def setup(client):
await client.add_cog(Giveaway(client))
Loading