Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Commit

Permalink
Improved help embeds and added custom prefixes
Browse files Browse the repository at this point in the history
Made help commands much better now!
  • Loading branch information
djthegr8 committed Jul 21, 2020
1 parent 6d3131a commit ac46455
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 58 deletions.
33 changes: 19 additions & 14 deletions TradeMemer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using Discord.WebSocket;
using System.Text.RegularExpressions;
using System.Threading;
using System.Reflection;
using System.IO;
using TradeMemer.modules;
using System.Collections.Generic;
using Microsoft.VisualBasic;

namespace TradeMemer
{
Expand Down Expand Up @@ -92,9 +94,8 @@ internal async Task HandleJoinAsync(SocketGuild guild) {
}
}).Start();
}
internal async Task HandleCommandResult(CommandStatus result, SocketUserMessage msg)
{
/*
internal async Task HandleCommandResult(CustomCommandService.ICommandResult result, SocketUserMessage msg, string prefi)
{
await Task.Delay(10);
string completed = Resultformat(result.IsSuccess);
if (result.IsSuccess)
Expand All @@ -105,14 +106,14 @@ internal async Task HandleCommandResult(CommandStatus result, SocketUserMessage
{
Color = Color.Green,
Title = "**Command Log**",
Description = $"The Command {msg.Content.Split(' ').First()} was used in {msg.Channel.Name} of {(msg.Channel as SocketTextChannel).Guild.Name} by {msg.Author.Username + "#" + msg.Author.Discriminator} \n\n **Full Message** \n `{msg.Content}`\n\n **Result** \n {completed}",
Description = $"The Command {msg.Content.Substring(prefi.Length)} was used in {msg.Channel.Name} of {(msg.Channel as SocketTextChannel).Guild.Name} by {msg.Author.Username + "#" + msg.Author.Discriminator} \n\n **Full Message** \n `{msg.Content}`\n\n **Result** \n {completed}",
Footer = new EmbedFooterBuilder()
};
eb.Footer.Text = "Command Autogen";
eb.Footer.IconUrl = _client.CurrentUser.GetAvatarUrl();
await _client.GetGuild(732300342888497263).GetTextChannel(732300343655923807).SendMessageAsync("", false, eb.Build());
}).Start();
}*/
}
}
internal async Task StatusUpdateAsync(int arg1, int arg2)
{
Expand Down Expand Up @@ -161,14 +162,13 @@ public async Task HandleCommandAsync(SocketMessage s)
var ca = msg.Content.ToCharArray();
if (ca.Length == 0) return;
var context = new SocketCommandContext(_client, msg);
var prefu = await Class3.PrefixGetter(context.Guild.Id);
Console.WriteLine($"reached bp, prefix is {prefu}");
var prefu = await SqliteClass.PrefixGetter(context.Guild.Id);
if (msg.MentionedUsers.Any(x => x.Id == _client.CurrentUser.Id))
{
await context.Message.Channel.SendMessageAsync($"Hey trader!\nMy prefix in dis server is {prefu}");
return;
}
Console.WriteLine($"Reached the other saideee {msg.Content.Substring(0,prefu.Length)} == {prefu}");
if (msg.Content.Length <= prefu.Length) return;
if (msg.Content.Substring(0, prefu.Length) == prefu)
{
Console.WriteLine("Copy that prefix");
Expand All @@ -182,7 +182,7 @@ public async Task HandleCommandAsync(SocketMessage s)
}

//if (!MyCommandClass.Commands.Any(x => x.CommandName == msg.Content.Skip(1).ToString()) && !MySecondCommandClass.Commands.Any(x => x.CommandName == msg.Content.Skip(1).ToString())) return;
var tup = await Class3.SpeedCheck(context.User.Id);
var tup = await SqliteClass.SpeedCheck(context.User.Id);
if (tup.Item1 >= 3)
{
return;
Expand All @@ -191,11 +191,11 @@ public async Task HandleCommandAsync(SocketMessage s)
{
try
{
Console.WriteLine(await Class3.PrefixGetter(context.Guild.Id));
await _service.ExecuteAsync(context,await Class3.PrefixGetter(context.Guild.Id));
Console.WriteLine(context.User.Username + ": " + msg + " in channel " + context.Channel.Name + " of guild " + context.Guild.Name);
var x = await _service.ExecuteAsync(context,prefu);
await HandleCommandResult(x, msg, prefu);
Console.WriteLine(context.User.Username + ": " + x.Result + " in channel " + context.Channel.Name + " of guild " + context.Guild.Name);
}
catch (Exception)
catch (Discord.Net.HttpException)
{
await context.Guild.Owner.SendMessageAsync("I do not have perms!!! Please give them to me!");
}
Expand Down Expand Up @@ -238,6 +238,11 @@ public async Task HandleReactionAsync(Cacheable<IUserMessage, ulong> arg1, ISock
var userIDReacter = arg3.UserId;
var userReacter = await arg2.GetUserAsync(userIDReacter);
if (userReacter.IsBot) return;
var tup = await SqliteClass.SpeedCheck(userIDReacter);
if (tup.Item1 >= 3)
{
return;
}
if ((userSeller.Id == userReacter.Id || userReacter.Id == 541998151716962305 || userReacter.Id == 701029647760097361) && arg3.Emote.Name == Dealdone.Name)
{
try
Expand All @@ -249,7 +254,7 @@ public async Task HandleReactionAsync(Cacheable<IUserMessage, ulong> arg1, ISock
return;
}
}
if (userSeller.Id == userReacter.Id) {
if (userSeller.Id == userReacter.Id || (await SqliteClass.SpeedCheck(userIDReacter)).Item1 >= 3) {
await msg.RemoveReactionAsync(arg3.Emote, userReacter);
return;
}
Expand Down
106 changes: 80 additions & 26 deletions TradeMemer/modules/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public class MyCommandClass : CommandModuleBase
{
Title = "**Trade Memer help**"
}
.AddField("Trading Commands", "``!trade`` is the command for putting a sale \n`!trade [quantity] [itemname] [price]`\nExample - !trade 12 banknotes 20k\nWhile ``!buying`` is the command for requesting a trade\nExample - !buying 2 pepe 60000\nReact with :white_check_mark: to accept a deal and DM the seller.\nAfter a deal is finished, seller should react with :x: to declare the deal as closed.\n\n")
.AddField("Secure-trade Commands", "`!profile` - This command allows you to check the past warns of the trader.\n`!profile [mention/id]`\nExample - !profile @DJ001\n`!my-reports` - Get details of your past warns.\n`trade-report`(Admins only) - Report scammers.You can report a scammer only once in 1 server.\n`!trade-report [@scammmer or ID] [optional reason]`\nExample - !trade-report @DJ001\n`!appeal` - If you feel you are warned or banned falsely then you can appeal here with proof.\n\n")
.AddField("Non trading commands", "`idea` - Help us in making trade better by sharing your unique suggestions with us.\nExample - !idea my suggestion is make bot better\n`!vote` - Motivate us for making trade better by voting the bot.\n`!ping` - Allows you to check the speed of bot.\n\n")
.AddField("Trading Mechanism", "React with :white_check_mark: to accept a deal and DM the seller.\nAfter a deal is finished, seller should react with :x: to declare the deal as closed.\n\n")
.AddField("Trading Commands", "1.``!trade``\n2.``!buying``\n\n")
.AddField("Non trading commands", "1.`!prefix`\n2.`!idea`\n3.`!vote`\n4.`!ping`\n\n")
.AddField("Secure-trade Commands", "1.`!profile`\n2.`!my-reports`\n3.`!trade-report`(Admins only)\n4.`!appeal`\n\n")
.AddField("Links", "[Support Server](https://discord.gg/PbunDXN) | [Invite link](https://tiny.cc/TMAdmin)")
.Build();
readonly Embed buyError = new EmbedBuilder
{
Expand Down Expand Up @@ -52,7 +54,13 @@ public class MyCommandClass : CommandModuleBase
}
};

[DiscordCommand("buying")]
[DiscordCommand("buying",
description ="This command is for requesting people to sell the item you are wishing to buy.",
commandHelp ="buying [quantity] [itemname] [price-each/barter]",
example ="buying 10 pepe 2m"
)]
[Alt("b")]
[Alt("buy")]
public async Task BuyCommand(uint quantity, string item, string price)
{
if (quantity == 0 || item == "")
Expand All @@ -67,12 +75,16 @@ public async Task BuyCommand(uint quantity, string item, string price)
//}
bool isTrader;
(price, isTrader) = await Preprocess(price);
SocketCommandContext truContext = Context as SocketCommandContext;
SocketCommandContext truContext = Context;
ulong chnlId = await SearchChannel(truContext);
if (chnlId == 1)
{
return;
}
var chnl = truContext.Guild.GetTextChannel(chnlId);
if (isTrader) await ReplyAsync($"Your buyer's request of {quantity} {item} for {price} currency has been mentioned in {chnl.Mention}!\n{await Class4.GetApi(Context as SocketCommandContext)}");
else await ReplyAsync($"Your barter request of {quantity} {item} for {price} has been mentioned in {chnl.Mention}!\n{await Class4.GetApi(Context as SocketCommandContext)}");
await Bleh(Context);
EmbedBuilder eb = new EmbedBuilder
{
Title = $"**{item.ToUpper()}** in demand!",
Expand All @@ -82,15 +94,18 @@ public async Task BuyCommand(uint quantity, string item, string price)
if (isTrader) eb.Description = $"{Context.User.Mention} wants to buy **{quantity} {item} ** and is willing to pay {price} each";
else eb.Description = $"{Context.User.Mention} wants to buy **{quantity} {item} ** and is willing to barter {price}";
eb.Footer.Text = "Made with ❤️ by TradeMemer";
var chnl = truContext.Guild.GetTextChannel(chnlId);
var res = await chnl.SendMessageAsync(chn, false, eb.Build());
await res.AddReactionAsync(new Emoji(""));
await res.AddReactionAsync(new Emoji(""));
if (isTrader) await ReplyAsync($"Your buyer's request of {quantity} {item} for {price} currency has been mentioned in {chnl.Mention}!\n{await Class4.GetApi(Context as SocketCommandContext)}");
else await ReplyAsync($"Your barter request of {quantity} {item} for {price} has been mentioned in {chnl.Mention}!\n{await Class4.GetApi(Context as SocketCommandContext)}");
await Bleh(Context);
}
[DiscordCommand("trade")]
[DiscordCommand("trade",
description ="This is the command for placing an item for sale.",
commandHelp ="trade [quantity] [itemname] [price-each/barter]",
example ="trade 5 fish 5.1k"
)]
[Alt("s")]
[Alt("sell")]
[Alt("selling")]
public async Task TradeCommand(uint quantity, string item, string price)
{
if (quantity == 0 || item == "")
Expand Down Expand Up @@ -129,7 +144,7 @@ public async Task SingleArgTrade(string help)
await NoArgTrade();
}

[DiscordCommand("ping")]
[DiscordCommand("ping",description ="See how fast the bot's responses are!!")]
public async Task Ping()
{
await ReplyAsync($"TradePong: ``{ (Context as SocketCommandContext).Client.Latency} ms``");
Expand All @@ -149,53 +164,92 @@ public async Task OneArgBuyTSrade(string arg)
{
await NoArgTrade();
}
[DiscordCommand("vote")]
public async Task Vote()
[DiscordCommand("vote",
description ="Like our bot? Vote for it on Discord Bot List!"
)]
[Alt("voting")]
public async Task Vote(params string[] args)
{
await Context.Channel.SendMessageAsync("", false, vote);
}
[DiscordCommand("idea")]
[DiscordCommand("idea",description ="Have a suggestion to make? Use !idea to do it!")]
[Alt("suggest")]
[Alt("suggestion")]
public async Task Idea(params string[] args)
{
await ReplyAsync("Your suggestion has been sent to the Devs and i've put in a good word ;)\nAnd while you wait, join our support server!\nhttps://discord.gg/PbunDXN");
var sug = Context.Message.Content.Remove(0, 5);
await ReplyAsync("Your suggestion has been sent to the Devs and i've put in a good word ;)");
await Bleh(Context);
var sug = Context.Message.Content;
var mBed = new EmbedBuilder
{
Description = sug + "\n" + $"*Given by {Context.User.Username}#{Context.User.Discriminator}*",
Title = $"**New bot suggestion from **{Context.Guild.Name}"
};
var tM = await (Context.Client as IDiscordClient).GetGuildAsync(730634262788833281);
var sugChan = await tM.GetChannelAsync(730700586135322636) as SocketTextChannel;
var tM = await (Context.Client as IDiscordClient).GetGuildAsync(732300342888497263);
var sugChan = await tM.GetChannelAsync(734634237772431490) as SocketTextChannel;
await sugChan.SendMessageAsync("", false, mBed.Build());
await Task.Delay(2000);
}
[DiscordCommand("invite")]
[DiscordCommand("invite",description ="Invite the bot to your server!")]
public async Task Me(params string[] args)
{
invite.ImageUrl = Context.Client.CurrentUser.GetAvatarUrl();
await ReplyAsync("", false, invite.Build());
}
[DiscordCommand("prefix")]
public async Task PrefixUpd(char x)
[DiscordCommand("prefix",description ="Change the bot's prefix here!",commandHelp ="prefix &")]
public async Task PrefixUpd(string x)
{
await Class3.PrefixAdder(Context.Guild.Id, x);
await SqliteClass.PrefixAdder(Context.Guild.Id, x);
EmbedBuilder f = new EmbedBuilder
{
Title = "Prefix Changed Successfully!",
Description = $"The bot prefix has successfully been changed to {x}"
Description = $"The bot prefix has successfully been changed to {x}",
ThumbnailUrl = Context.Client.CurrentUser.GetAvatarUrl()
};
await ReplyAsync("", false, f.Build());
}
[DiscordCommand("help")]
public async Task Helper(string cmd)
{
if (!Commands.Any(x => (x.CommandName.ToLower() == cmd.ToLower() || x.Alts.Any(x => x.ToLower() == cmd.ToLower())) && x.CommandDescription != ""))
{
var d = new EmbedBuilder
{
Title = "Command not found",
Description = $"The command {cmd} was not found!",
Footer = new EmbedFooterBuilder()
};
d.Footer.Text = "Help Command by Trade Memer";
d.Footer.Build();
await ReplyAsync("", embed: d.Build());
} else
{
var prefixure = await SqliteClass.PrefixGetter(Context.Guild.Id);
var commandSelected = Commands.First(x => (x.CommandName.ToLower() == cmd.ToLower() || x.Alts.Any(x => x.ToLower() == cmd.ToLower())) && x.CommandDescription != "");
var aliasStr = prefixure + string.Join($", {prefixure}", commandSelected.Alts);
var embeds = new EmbedBuilder();
embeds.AddField("Command", prefixure + commandSelected.CommandName + '\t');
embeds.AddField("Description", commandSelected.CommandDescription, true);
if (!string.IsNullOrEmpty(commandSelected.CommandHelpMessage)) embeds.AddField("Usage", $"`{prefixure}{commandSelected.CommandHelpMessage}`");
if (!string.IsNullOrEmpty(commandSelected.example)) embeds.AddField("Example", $"`{prefixure}{commandSelected.example}`");
if (commandSelected.Alts.Count > 0) embeds.AddField("Aliases", aliasStr);
embeds.AddField("Links", "[Support Server](https://discord.gg/PbunDXN) | [Invite link](https://tiny.cc/TMAdmin)");
embeds.Footer = new EmbedFooterBuilder { Text = "Help Command by Trade Memer" };
await ReplyAsync("", false, embeds.Build());
}
}
//Below are supporter functions, not really commands.

public async Task Bleh(ICommandContext context)
{

if (regret.Next(0, 6) <= 3)
var xyz = await context.Client.GetGuildAsync(732300342888497263);
await xyz.DownloadUsersAsync();
var abc = await xyz.GetUsersAsync();
if (regret.Next(0, 6) <= 4)
{
if (regret.Next(0, 10) > 5)
{
if ((context.User as SocketGuildUser).MutualGuilds.Any(x => x.Id == 732300342888497263)) return;
if (abc.Any(x => x.Id == context.User.Id)) return;
await ReplyAsync("While you wait for a someone to see your deal, why not join our supercool support server!\nhttps://discord.gg/PbunDXN");
}
else
Expand Down
Loading

0 comments on commit ac46455

Please sign in to comment.