First Commit
This commit is contained in:
1 parent
7fcd4c83df
commit
da91165f5c
10 files changed
+2884
No files matched your search
+365
@@ -0,0 +1,365 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
Properties/
|
||||
launchSettings.json
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.VoiceNext;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.CommandsNext.Exceptions;
|
||||
using DSharpPlus.EventArgs;
|
||||
using DSharpPlus.VoiceNext.Codec;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using DSharpPlus.Interactivity;
|
||||
using DSharpPlus.Interactivity.Extensions;
|
||||
using System.Threading;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
[Group("ex")]
|
||||
class BotSettings : BaseCommandModule
|
||||
{
|
||||
public static Dictionary<string, GuildSettings> GuildSettings;
|
||||
|
||||
public BotSettings()
|
||||
{
|
||||
Console.WriteLine("Bot Setting Commands Loaded");
|
||||
var json = "";
|
||||
using (var fs = File.OpenRead("guildSettings.json"))
|
||||
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||
json = sr.ReadToEnd();
|
||||
GuildSettings = JsonConvert.DeserializeObject<Dictionary<string, GuildSettings>>(json);
|
||||
}
|
||||
|
||||
[Group("Prefix")]
|
||||
class BotPrefix : BotSettings
|
||||
{
|
||||
public BotPrefix()
|
||||
{
|
||||
|
||||
}
|
||||
[GroupCommand]
|
||||
public async Task GetPrefixes(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
var guild = ctx.Guild.Id.ToString();
|
||||
if (! GuildSettings.ContainsKey(guild))
|
||||
{
|
||||
await ctx.RespondAsync("No guild settings found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var server = GuildSettings[guild];
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = $"{ctx.Guild.Name} Settings."
|
||||
};
|
||||
embed.AddField("Prefix(es)", server.Prefixes.ToString());
|
||||
embed.AddField("Use Global Prefix", server.UseGlobalPrefix.ToString(), true);
|
||||
embed.AddField("Self Roles Enabled", server.UseSelfRoles.ToString(), true);
|
||||
embed.AddField("Level Roles Enabled", server.UseLevelRoles.ToString(), true);
|
||||
embed.AddField("Self Role Buy", server.AllowRolesPurchase.ToString(), true);
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
}
|
||||
[Command("Add")]
|
||||
public async Task AddNewPrefix (CommandContext ctx, string prefix)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
GuildSettings[ctx.Guild.Id.ToString()].Prefixes.Add(prefix);
|
||||
await ctx.RespondAsync($"Added `{prefix}` as a command prefix.");
|
||||
}
|
||||
|
||||
[Command("delete"), Aliases("del")]
|
||||
public async Task RemovePrefix (CommandContext ctx, string prefix)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GuildSettings
|
||||
{
|
||||
public bool UseGlobalPrefix { get; set; }
|
||||
public bool UseSelfRoles { get; set; }
|
||||
public bool UseLevelRoles { get; set; }
|
||||
public bool UseLevels { get; set; }
|
||||
public bool AllowRolesPurchase { get; set; }
|
||||
public bool UseAutoRoles { get; set; }
|
||||
public List<String> Prefixes { get; set; }
|
||||
public Dictionary<string,int> SelfRoles { get; set; }
|
||||
public Dictionary<string,int> LevelRoles { get; set; }
|
||||
}
|
||||
}
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.VoiceNext;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
class Commands : BaseCommandModule
|
||||
{
|
||||
private readonly Random rnd = new Random();
|
||||
|
||||
public Commands()
|
||||
{
|
||||
Console.WriteLine("Basic Commands Loaded");
|
||||
}
|
||||
|
||||
[Command("dice"), Aliases("r", "d", "roll")]
|
||||
[Description("A classic dice throwing command. Limited to 1 use per 2 seconds. Format: <NumberOfDice>d<SidesOnDie> ")]
|
||||
[Cooldown(1, 2, CooldownBucketType.User)]
|
||||
public async Task Dice(CommandContext ctx, [RemainingText,Description("XdY")] String throwing = "d")
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
throwing = throwing.ToLower();
|
||||
int totalResult = 0;
|
||||
int totalDie = 0;
|
||||
string overallResults = String.Empty;
|
||||
Regex regex = new Regex("(\\d{0,})(d)(-{0,1}\\d{0,})");
|
||||
MatchCollection matches = regex.Matches(throwing);
|
||||
foreach (Match m in matches)
|
||||
{
|
||||
if (m.Success)
|
||||
{
|
||||
string dieResults = String.Empty;
|
||||
int dieResult = 0;
|
||||
bool volTest = int.TryParse(m.Groups[1].ToString(), out int volume);
|
||||
bool sideTest = int.TryParse(m.Groups[3].ToString(), out int sides);
|
||||
|
||||
if (!volTest)
|
||||
volume = 1;
|
||||
if (!sideTest)
|
||||
sides = 6;
|
||||
|
||||
for (int i = 0; i < volume; i++)
|
||||
{
|
||||
++totalDie;
|
||||
int roll = rnd.Next(Math.Min(1, sides), Math.Max(sides + 1, 0));
|
||||
if (dieResults.Equals(String.Empty))
|
||||
dieResults = roll.ToString();
|
||||
else
|
||||
dieResults += $", {roll}";
|
||||
totalResult += roll;
|
||||
dieResult += roll;
|
||||
}
|
||||
if(volume < 11)
|
||||
dieResults = $"{volume}d{sides}: Total: " + dieResult + " Avg: " + Math.Round(dieResult * 1.0 / volume, 2) + " Results: " + dieResults;
|
||||
else
|
||||
dieResults = $"{volume}d{sides}: Total: " + dieResult + " Avg: " + Math.Round(dieResult * 1.0 / volume, 2);
|
||||
overallResults += "```" + dieResults + "```\r\n";
|
||||
}
|
||||
}
|
||||
if (matches.Count != 1)
|
||||
await ctx.RespondAsync(overallResults + "\r\nTotal: " + totalResult + " Avg: " + Math.Round(totalResult * 1.0 / totalDie * 1.0, 2));
|
||||
else
|
||||
await ctx.RespondAsync(overallResults);
|
||||
}
|
||||
|
||||
[Command("random")]
|
||||
[Description("Random number generator.")]
|
||||
public async Task Random(CommandContext ctx, [Description("Lowest number choice. (Inclusive)")] int min, [Description("Highest Number Choice. (Inclusive)")] int max)
|
||||
{
|
||||
max += 1;
|
||||
var rnd = new Random();
|
||||
int i = Math.Min(min, max);
|
||||
int a = Math.Max(min, max);
|
||||
|
||||
await ctx.RespondAsync($"🎲 Your random number is: {rnd.Next(i, a)}");
|
||||
}
|
||||
[Command("random")]
|
||||
public async Task Random(CommandContext ctx)
|
||||
{
|
||||
await ctx.RespondAsync($"Gives you a random number between <Option 1> and <Option 2> Try someething like `random 3 30`!");
|
||||
}
|
||||
[Command("8ball"), Aliases(new String[] { "ball", "8" })]
|
||||
[Description("The Magic 8-Ball is a fortune-telling or seeking advice")]
|
||||
public async Task Eightball(CommandContext ctx, [RemainingText, Description("Your question to the 8 ball")] String remainingText = "")
|
||||
{
|
||||
string[] results = new string[] { "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Yes.", "Signs point to yes.", "Reply hazy, try again", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don't count on it.", "My reply is no.", "My sources say no", "Outlook not so good.", "Very doubtful." };
|
||||
await ctx.RespondAsync(results[rnd.Next(0, results.Length)]);
|
||||
}
|
||||
|
||||
[Command("slap")]
|
||||
public async Task Slap(CommandContext ctx, DiscordMember user = null)
|
||||
{
|
||||
string[] insults = {
|
||||
"{0} slaps {1} around a bit with a large trout.",
|
||||
"{0} puts a jellyfish on {1}'s head.",
|
||||
"{0} slaps {1} around a bit with the mustache of Caanon.",
|
||||
"{0} slaps {1} around a bit with a questionable rubber object.",
|
||||
"{0} slaps {1} around a bit with a rubber chicken."
|
||||
};
|
||||
string user1;
|
||||
string user2;
|
||||
|
||||
if (user == null || user.Mention == ctx.Message.Author.Mention)
|
||||
{
|
||||
user1 = ctx.Client.CurrentUser.Mention;
|
||||
user2 = ctx.Message.Author.Mention;
|
||||
}
|
||||
else
|
||||
{
|
||||
user1 = ctx.Message.Author.Mention;
|
||||
user2 = user.Mention;
|
||||
}
|
||||
|
||||
await ctx.RespondAsync(string.Format(insults[rnd.Next(insults.Length)], user1, user2));
|
||||
}
|
||||
|
||||
[Command("rpsls")]
|
||||
[Description("Rock Paper Scissors Lizard Spock")]
|
||||
public async Task Rpsls(CommandContext ctx, [RemainingText, Description("Your choice of hand sign to use.")] string text = "")
|
||||
{
|
||||
string[] choices = new string[] { "rock", "paper", "scissors", "lizard", "spock" };
|
||||
text = text.ToLower();
|
||||
string botChoice = choices[rnd.Next(0, choices.Length)];
|
||||
string result;
|
||||
|
||||
if (text.Equals(""))
|
||||
{
|
||||
result = "I'm handing you a";
|
||||
switch (botChoice)
|
||||
{
|
||||
case "rock":
|
||||
result += " shiny rock.";
|
||||
break;
|
||||
case "paper":
|
||||
result += " crumpled paper.";
|
||||
break;
|
||||
case "lizard":
|
||||
result += " deadly lizard.";
|
||||
break;
|
||||
case "scissors":
|
||||
result += " set of child proof scissors.";
|
||||
break;
|
||||
case "spock":
|
||||
result = "I present, Mr. Spock!";
|
||||
break;
|
||||
}
|
||||
await ctx.RespondAsync(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (choices.Contains(text))
|
||||
{
|
||||
if (((botChoice == "scissors") && (text == "paper")) ||
|
||||
((botChoice == "paper") && (text == "rock")) ||
|
||||
((botChoice == "rock") && (text == "lizard")) ||
|
||||
((botChoice == "lizard") && (text == "spock")) ||
|
||||
((botChoice == "spock") && (text == "scissors")) ||
|
||||
((botChoice == "scissors") && (text == "lizard")) ||
|
||||
((botChoice == "lizard") && (text == "paper")) ||
|
||||
((botChoice == "paper") && (text == "spock")) ||
|
||||
((botChoice == "spock") && (text == "rock")) ||
|
||||
((botChoice == "rock") && (text == "scissors")))
|
||||
{
|
||||
result = $"{botChoice} beats {text}. I'm sorry about this.";
|
||||
}
|
||||
else if (text.Equals(botChoice))
|
||||
{
|
||||
result = $"We both picked {text}, looks like we drew, go again?";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = $"{text} beats {botChoice}. **YOU WIN!!**";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "Please pick a valid option! Options: " + String.Join(", ", choices);
|
||||
}
|
||||
await ctx.RespondAsync(result);
|
||||
}
|
||||
}
|
||||
|
||||
[Command("rps")]
|
||||
[Description("Rock Paper Scissors")]
|
||||
public async Task Rps(CommandContext ctx, [RemainingText, Description("Your choice of hand sign to use.")] string text = "")
|
||||
{
|
||||
string[] choices = new string[] { "rock", "paper", "scissors" };
|
||||
text = text.ToLower();
|
||||
string botChoice = choices[rnd.Next(0, choices.Length)];
|
||||
string result;
|
||||
|
||||
if (text.Equals(""))
|
||||
{
|
||||
result = "I'm handing you a";
|
||||
switch (botChoice)
|
||||
{
|
||||
case "rock":
|
||||
result += " shiny rock.";
|
||||
break;
|
||||
case "paper":
|
||||
result += " crumpled paper.";
|
||||
break;
|
||||
case "scissors":
|
||||
result += " set of child proof scissors.";
|
||||
break;
|
||||
}
|
||||
await ctx.RespondAsync(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (choices.Contains(text))
|
||||
{
|
||||
if (((botChoice == "scissors") && (text == "paper")) ||
|
||||
((botChoice == "paper") && (text == "rock")) ||
|
||||
((botChoice == "rock") && (text == "scissors")))
|
||||
{
|
||||
result = $"{botChoice} beats {text}. I'm sorry about this.";
|
||||
}
|
||||
else if (text.Equals(botChoice))
|
||||
{
|
||||
result = $"We both picked {text}, looks like we drew, go again?";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = $"{text} beats {botChoice}. **YOU WIN!!**";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "Please pick a valid option! Options: " + String.Join(", ", choices);
|
||||
}
|
||||
await ctx.RespondAsync(result);
|
||||
}
|
||||
}
|
||||
|
||||
[Command("about")]
|
||||
[Description("Gives some basic info about the bot")]
|
||||
public async Task About(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
DiscordMember member = ctx.User as DiscordMember;
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
|
||||
embed.WithTitle("About " + ctx.Client.CurrentUser.Username + "#" + ctx.Client.CurrentUser.Discriminator);
|
||||
|
||||
embed.WithThumbnail(ctx.Client.CurrentUser.GetAvatarUrl(DSharpPlus.ImageFormat.Png, 32));
|
||||
embed.WithColor(member.Color);
|
||||
embed.AddField("D#+ Ver", ctx.Client.VersionString, true);
|
||||
embed.AddField("Guild Count", ctx.Client.Guilds.Count.ToString(), true);
|
||||
embed.AddField("Ping", ctx.Client.Ping.ToString(), true);
|
||||
embed.AddField("Shard Count", ctx.Client.ShardCount.ToString(), true);
|
||||
embed.AddField("Shard", ctx.Client.ShardId.ToString(), true);
|
||||
|
||||
string owners = "";
|
||||
foreach (DiscordUser owner in ctx.Client.CurrentApplication.Owners)
|
||||
{
|
||||
owners += owner.Username + "#" + owner.Discriminator+"\r\n";
|
||||
}
|
||||
|
||||
//DiscordUser owner = ctx.Client.CurrentApplication.Owners.First();
|
||||
embed.AddField("Owner(s)", owners, false);
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
[Command("credits")]
|
||||
[Description("Shows all those that have helped with my bot(s) over the years!")]
|
||||
public async Task Credits(CommandContext ctx)
|
||||
{
|
||||
string credits = "```asciidoc\r\n= CREDITS (Outdated) =\r\n" +
|
||||
"• UndeadShadow :: Flood Protection. Keepign teh bot from killing itself, and others.\r\n" +
|
||||
"• Da_D_Master :: For giving me my start in my first couple bots, and being a friendly rival.\r\n" +
|
||||
"• ThinkExist & Bored.com :: Quotes for the Quote Database\r\n" +
|
||||
"• Hanibal, TaMeD, Liquid- :: For awlays proving the points of others.\r\n" +
|
||||
"• Neo :: For all their hard work on all the things I've ever asked about.\r\n" +
|
||||
"• Alias :: For helping me learn how to make IRC bots back in the day.\r\n" +
|
||||
"• Drake :: Supporting the development of the bot and supplying code for it.\r\n" +
|
||||
"\r\n```";
|
||||
await ctx.RespondAsync(credits);
|
||||
}
|
||||
|
||||
[Command("coin")]
|
||||
[Description("Flips a coin for ya!")]
|
||||
public async Task Coinflip(CommandContext ctx)
|
||||
{
|
||||
string[] choices = { "heads", "tails" };
|
||||
await ctx.RespondAsync("The coin landed on... " + choices[rnd.Next(0, choices.Length)]);
|
||||
}
|
||||
|
||||
[Command("say")]
|
||||
[Description("Make the bot say something, perhaps silly?!")]
|
||||
public async Task MsgSay(CommandContext ctx, [RemainingText, Description("The stuff you want the bot to say.")] string msg = "")
|
||||
{
|
||||
if (msg != "")
|
||||
await ctx.RespondAsync(msg);
|
||||
else
|
||||
await ctx.RespondAsync("I need something to say...");
|
||||
}
|
||||
}
|
||||
}
|
||||
+551
@@ -0,0 +1,551 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Exceptions;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.EventArgs;
|
||||
using DSharpPlus.Interactivity;
|
||||
using DSharpPlus.Interactivity.Enums;
|
||||
using DSharpPlus.Interactivity.Extensions;
|
||||
using DSharpPlus.VoiceNext;
|
||||
using DSharpPlus.VoiceNext.Codec;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public readonly EventId BotEventId = new EventId(42, "Bot-Ex04");
|
||||
|
||||
public DiscordClient Client { get; set; }
|
||||
public CommandsNextExtension Commands { get; set; }
|
||||
public VoiceNextExtension Voice { get; set; }
|
||||
|
||||
protected string BotName { get; set; }
|
||||
|
||||
public Program()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private async Task StartTimer(CancellationToken cancellationToken)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
string output = JsonConvert.SerializeObject(BotSettings.GuildSettings);
|
||||
await File.WriteAllTextAsync("GuildSettings.json", output);
|
||||
Console.WriteLine("Wrote new info to file.");
|
||||
await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken);
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
Console.WriteLine("Token Cancelled.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// since we cannot make the entry method asynchronous,
|
||||
// let's pass the execution to asynchronous code
|
||||
var prog = new Program(args);
|
||||
prog.
|
||||
RunBotAsync().
|
||||
GetAwaiter().
|
||||
GetResult();
|
||||
}
|
||||
|
||||
public Program(string[] args)
|
||||
{
|
||||
if (args.Length > 0)
|
||||
BotName = args[0].ToLower();
|
||||
else
|
||||
BotName = "cybrid";
|
||||
|
||||
BotEventId = new EventId(276, BotName);
|
||||
}
|
||||
|
||||
public async Task RunBotAsync()
|
||||
{
|
||||
|
||||
// next, let's load the values from that file
|
||||
// to our client's configuration
|
||||
var cfg = new DiscordConfiguration
|
||||
{
|
||||
Token = Environment.GetEnvironmentVariable(BotName + "Token"),
|
||||
TokenType = TokenType.Bot,
|
||||
|
||||
AutoReconnect = true,
|
||||
MinimumLogLevel = LogLevel.Debug,
|
||||
Intents = DiscordIntents.AllUnprivileged,
|
||||
};
|
||||
|
||||
// then we want to instantiate our client
|
||||
this.Client = new DiscordClient(cfg);
|
||||
|
||||
// next, let's hook some events, so we know
|
||||
// what's going on
|
||||
|
||||
this.Client.UseInteractivity(new InteractivityConfiguration()
|
||||
{
|
||||
PollBehaviour = PollBehaviour.KeepEmojis,
|
||||
Timeout = TimeSpan.FromSeconds(15)
|
||||
});
|
||||
|
||||
// up next, let's set up our commands
|
||||
var ccfg = new CommandsNextConfiguration
|
||||
{
|
||||
// let's use the string prefix defined in config.json
|
||||
StringPrefixes = new[] { Environment.GetEnvironmentVariable("CommandPrefix") },
|
||||
|
||||
// enable responding in direct messages
|
||||
EnableDms = true,
|
||||
|
||||
// enable mentioning the bot as a command prefix
|
||||
EnableMentionPrefix = true,
|
||||
|
||||
UseDefaultCommandHandler = false
|
||||
};
|
||||
|
||||
// and hook them up
|
||||
this.Commands = this.Client.UseCommandsNext(ccfg);
|
||||
|
||||
// Hook all possible Event Handlers in the system.
|
||||
this.Client.ChannelCreated += this.Event_ChannelCreated;
|
||||
this.Client.ChannelDeleted += this.Event_ChannelDeleted;
|
||||
this.Client.ChannelPinsUpdated += this.Event_ChannelPinsUpdated;
|
||||
this.Client.ChannelUpdated += this.Event_ChannelUpdated;
|
||||
this.Client.ClientErrored += this.Event_ClientErrored;
|
||||
this.Client.DmChannelDeleted += this.Event_DmChannelDeleted;
|
||||
this.Client.GuildAvailable += this.Event_GuildAvailable;
|
||||
this.Client.GuildBanAdded += this.Event_GuildBanAdded;
|
||||
this.Client.GuildBanRemoved += this.Event_GuildBanRemoved;
|
||||
this.Client.GuildCreated += this.Event_GuildCreated;
|
||||
this.Client.GuildDeleted += this.Event_GuildDeleted;
|
||||
this.Client.GuildDownloadCompleted += this.Event_GuildDownloadCompleted;
|
||||
this.Client.GuildEmojisUpdated += this.Event_GuildEmojisUpdated;
|
||||
this.Client.GuildIntegrationsUpdated += this.Event_GuildIntegrationsUpdated;
|
||||
this.Client.GuildMemberAdded += this.Event_GuildMemberAdded;
|
||||
this.Client.GuildMemberRemoved += this.Event_GuildMemberRemoved;
|
||||
this.Client.GuildMembersChunked += this.Event_GuildMembersChunked;
|
||||
this.Client.GuildMemberUpdated += this.Event_GuildMemberUpdated;
|
||||
this.Client.GuildRoleCreated += this.Event_GuildRoleCreated;
|
||||
this.Client.GuildRoleDeleted += this.Event_GuildRoleDeleted;
|
||||
this.Client.GuildRoleUpdated += this.Event_GuildRoleUpdated;
|
||||
this.Client.GuildUnavailable += this.Event_GuildUnavailable;
|
||||
this.Client.GuildUpdated += this.Event_GuildUpdated;
|
||||
this.Client.Heartbeated += this.Event_Heartbeated;
|
||||
this.Client.InviteCreated += this.Event_InviteCreated;
|
||||
this.Client.InviteDeleted += this.Event_InviteDeleted;
|
||||
this.Client.MessageAcknowledged += this.Event_MessageAcknowledged;
|
||||
this.Client.MessageCreated += this.Event_MessageCreated;
|
||||
this.Client.MessageDeleted += this.Event_MessageDeleted;
|
||||
this.Client.MessageReactionAdded += this.Event_MessageReactionAdded;
|
||||
this.Client.MessageReactionRemoved += this.Event_MessageReactionRemoved;
|
||||
this.Client.MessageReactionRemovedEmoji += this.Event_MessageReactionRemovedEmoji;
|
||||
this.Client.MessageReactionsCleared += this.Event_MessageReactionsCleared;
|
||||
this.Client.MessagesBulkDeleted += this.Event_MessagesBulkDeleted;
|
||||
this.Client.MessageUpdated += this.Event_MessageUpdated;
|
||||
this.Client.PresenceUpdated += this.Event_PresenceUpdated;
|
||||
this.Client.Ready += this.Event_Ready;
|
||||
this.Client.Resumed += this.Event_Resumed;
|
||||
this.Client.SocketClosed += this.Event_SocketClosed;
|
||||
this.Client.SocketErrored += this.Event_SocketErrored;
|
||||
this.Client.SocketOpened += this.Event_SocketOpened;
|
||||
this.Client.TypingStarted += this.Event_TypingStarted;
|
||||
this.Client.UnknownEvent += this.Event_UnknownEvent;
|
||||
this.Client.UserSettingsUpdated += this.Event_UserSettingsUpdated;
|
||||
this.Client.UserUpdated += this.Event_UserUpdated;
|
||||
this.Client.VoiceServerUpdated += this.Event_VoiceServerUpdated;
|
||||
this.Client.VoiceStateUpdated += this.Event_VoiceStateUpdated;
|
||||
this.Client.WebhooksUpdated += this.Event_WebhooksUpdated;
|
||||
|
||||
this.Client.ApplicationCommandCreated += this.Event_ApplicationCommandCreated;
|
||||
this.Client.ApplicationCommandDeleted += this.Event_ApplicationCommandDeleted;
|
||||
this.Client.ApplicationCommandUpdated += this.Event_ApplicationCommandUpdated;
|
||||
|
||||
this.Client.InteractionCreated += this.Event_InteractionCreated;
|
||||
|
||||
this.Commands.CommandExecuted += this.Event_CommandExecuted;
|
||||
this.Commands.CommandErrored += this.Event_CommandErrored;
|
||||
|
||||
// up next, let's register our commands
|
||||
this.Commands.RegisterCommands<Commands>();
|
||||
// this.Commands.RegisterCommands<SnappleFacts>();
|
||||
this.Commands.RegisterCommands<BotSettings>(); // Main Folder. Test Items.
|
||||
|
||||
// All these commands are in the STARSIEGE folder.
|
||||
//if (BotName.Contains("ssp"))
|
||||
//{
|
||||
this.Commands.RegisterCommands<Quickchat>();
|
||||
this.Commands.RegisterCommands<Functions>();
|
||||
this.Commands.RegisterCommands<DeathMessages>();
|
||||
//}
|
||||
Task thisTimer = StartTimer(new CancellationToken());
|
||||
|
||||
// let's enable voice
|
||||
this.Voice = this.Client.UseVoiceNext();
|
||||
|
||||
// finally, let's connect and log in
|
||||
await this.Client.ConnectAsync();
|
||||
|
||||
// and this is to prevent premature quitting
|
||||
await Task.Delay(-1);
|
||||
}
|
||||
private Task Event_MessageCreated(DiscordClient d, MessageCreateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessageCreated.");
|
||||
|
||||
var cnext = d.GetCommandsNext();
|
||||
var msg = e.Message;
|
||||
|
||||
// Check if message has valid prefix.
|
||||
// json file loaded...
|
||||
var cmdStart = msg.GetStringPrefixLength("!");
|
||||
BotSettings.GuildSettings.ContainsKey(e.Guild.Id.ToString());
|
||||
if (cmdStart == -1) return Task.CompletedTask;
|
||||
|
||||
// Retrieve prefix.
|
||||
var prefix = msg.Content.Substring(0, cmdStart);
|
||||
var cmdString = msg.Content.Substring(cmdStart);
|
||||
|
||||
// Retrieve full command string.
|
||||
var command = cnext.FindCommand(cmdString, out var args);
|
||||
if (command == null) return Task.CompletedTask;
|
||||
|
||||
var ctx = cnext.CreateContext(msg, prefix, command, args);
|
||||
Task.Run(async () => await cnext.ExecuteCommandAsync(ctx));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task Event_CommandExecuted(CommandsNextExtension ext, CommandExecutionEventArgs e)
|
||||
{
|
||||
if (e.Context.Client.Guilds.Count > 75)
|
||||
e.Context.Client.Logger.LogCritical(BotEventId, $"Client is in {e.Context.Client.Guilds.Count}");
|
||||
// let's log the name of the command and user
|
||||
e.Context.Client.Logger.LogInformation(BotEventId, $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'");
|
||||
|
||||
// since this method is not async, let's return
|
||||
// a completed task, so that no additional work
|
||||
// is done
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task Event_CommandErrored(CommandsNextExtension ext, CommandErrorEventArgs e)
|
||||
{
|
||||
// let's log the error details
|
||||
e.Context.Client.Logger.LogError(BotEventId, $"{e.Context.User.Username} tried executing '{e.Command?.QualifiedName ?? "<unknown command>"}' but it errored: {e.Exception.GetType()}: {e.Exception.Message ?? "<no message>"}", DateTime.Now);
|
||||
|
||||
// let's check if the error is a result of lack
|
||||
// of required permissions
|
||||
if (e.Exception is ChecksFailedException)
|
||||
{
|
||||
// yes, the user lacks required permissions,
|
||||
// let them know
|
||||
var emoji = DiscordEmoji.FromName(e.Context.Client, ":no_entry:");
|
||||
|
||||
// let's wrap the response into an embed
|
||||
var embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Title = "Access denied",
|
||||
Description = $"{emoji} You do not have the permissions required to execute this command.",
|
||||
Color = new DiscordColor(0xFF0000) // red
|
||||
};
|
||||
await e.Context.RespondAsync("", embed: embed);
|
||||
}
|
||||
}
|
||||
|
||||
private Task Event_InteractionCreated(DiscordClient d, InteractionCreateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, $"{e.Interaction.User.Username} started an interaction. {e.Interaction.Data.Name}");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_ChannelCreated(DiscordClient d, ChannelCreateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, $"{e.Channel.Name} was created on {e.Guild.Name}. Type: {e.Channel.Type}");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_ChannelDeleted(DiscordClient d, ChannelDeleteEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_ChannelDeleted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_ApplicationCommandCreated(DiscordClient d, ApplicationCommandEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_ApplicationCommandCreated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_ApplicationCommandDeleted(DiscordClient d, ApplicationCommandEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_ApplicationCommandDeleted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_ApplicationCommandUpdated(DiscordClient d, ApplicationCommandEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_ApplicationCommandUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_ChannelPinsUpdated(DiscordClient d, ChannelPinsUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_ChannelPinsUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_ChannelUpdated(DiscordClient d, ChannelUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_ChannelUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_ClientErrored(DiscordClient d, ClientErrorEventArgs e)
|
||||
{
|
||||
// let's log the details of the error that just
|
||||
// occured in our client
|
||||
d.Logger.LogError(BotEventId, e.Exception, "Exception occured");
|
||||
|
||||
// since this method is not async, let's return
|
||||
// a completed task, so that no additional work
|
||||
// is done
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_DmChannelDeleted(DiscordClient d, DmChannelDeleteEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_ClientErrored.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildAvailable(DiscordClient d, GuildCreateEventArgs e)
|
||||
{
|
||||
// let's log the name of the guild that was just
|
||||
// sent to our client
|
||||
d.Logger.LogInformation(BotEventId, $"Guild available: {e.Guild.Name}");
|
||||
|
||||
// since this method is not async, let's return
|
||||
// a completed task, so that no additional work
|
||||
// is done
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildBanAdded(DiscordClient d, GuildBanAddEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildBanAdded.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildBanRemoved(DiscordClient d, GuildBanRemoveEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildBanRemoved.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildCreated(DiscordClient d, GuildCreateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildCreated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildDeleted(DiscordClient d, GuildDeleteEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildDeleted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildDownloadCompleted(DiscordClient d, GuildDownloadCompletedEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildDownloadCompleted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildEmojisUpdated(DiscordClient d, GuildEmojisUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildEmojisUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildIntegrationsUpdated(DiscordClient d, GuildIntegrationsUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildIntegrationsUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildMemberAdded(DiscordClient d, GuildMemberAddEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildMemberAdded.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildMemberRemoved(DiscordClient d, GuildMemberRemoveEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildMemberRemoved.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildMembersChunked(DiscordClient d, GuildMembersChunkEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildMembersChunked.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildMemberUpdated(DiscordClient d, GuildMemberUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildMemberUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildRoleCreated(DiscordClient d, GuildRoleCreateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildRoleCreated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildRoleDeleted(DiscordClient d, GuildRoleDeleteEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildRoleDeleted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildRoleUpdated(DiscordClient d, GuildRoleUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildRoleUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildUnavailable(DiscordClient d, GuildDeleteEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildUnavailable.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_GuildUpdated(DiscordClient d, GuildUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_GuildUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_Heartbeated(DiscordClient d, HeartbeatEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_Heartbeated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_InviteCreated(DiscordClient d, InviteCreateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_InviteCreated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_InviteDeleted(DiscordClient d, InviteDeleteEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_InviteDeleted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_MessageAcknowledged(DiscordClient d, MessageAcknowledgeEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessageAcknowledged.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_MessageDeleted(DiscordClient d, MessageDeleteEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessageDeleted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_MessageReactionAdded(DiscordClient d, MessageReactionAddEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessageReactionAdded.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_MessageReactionRemoved(DiscordClient d, MessageReactionRemoveEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessageReactionRemoved.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_MessageReactionRemovedEmoji(DiscordClient d, MessageReactionRemoveEmojiEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessageReactionRemovedEmoji.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_MessageReactionsCleared(DiscordClient d, MessageReactionsClearEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessageReactionsCleared.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_MessagesBulkDeleted(DiscordClient d, MessageBulkDeleteEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessagesBulkDeleted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_MessageUpdated(DiscordClient d, MessageUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_MessageUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_PresenceUpdated(DiscordClient d, PresenceUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_PresenceUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_Ready(DiscordClient d, ReadyEventArgs e)
|
||||
{
|
||||
// let's log the fact that this event occured
|
||||
d.Logger.LogInformation(BotEventId, $"Client is ready to process events. Client is in: {d.Guilds.Count} Guilds.");
|
||||
|
||||
// since this method is not async, let's return
|
||||
// a completed task, so that no additional work
|
||||
// is done
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_Resumed(DiscordClient d, ReadyEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_Resumed.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_SocketClosed(DiscordClient d, SocketCloseEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_SocketClosed.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_SocketErrored(DiscordClient d, SocketErrorEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_SocketErrored.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_SocketOpened(DiscordClient d, SocketEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_SocketOpened.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_TypingStarted(DiscordClient d, TypingStartEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_TypingStarted.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_UnknownEvent(DiscordClient d, UnknownEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_UnknownEvent.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_UserSettingsUpdated(DiscordClient d, UserSettingsUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_UserSettingsUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_UserUpdated(DiscordClient d, UserUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_UserUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_VoiceServerUpdated(DiscordClient d, VoiceServerUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_VoiceServerUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_VoiceStateUpdated(DiscordClient d, VoiceStateUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_VoiceStateUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task Event_WebhooksUpdated(DiscordClient d, WebhooksUpdateEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, "Event_WebhooksUpdated.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
// this structure will hold data from config.json
|
||||
public struct ConfigJson
|
||||
{
|
||||
[JsonProperty("token")]
|
||||
public string Token { get; private set; }
|
||||
|
||||
[JsonProperty("prefix")]
|
||||
public string CommandPrefix { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.VoiceNext;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.CommandsNext.Exceptions;
|
||||
using DSharpPlus.EventArgs;
|
||||
using DSharpPlus.VoiceNext.Codec;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
[Group("deathmessage"), Aliases("dm")]
|
||||
[Description("Gives a random death message. Or interacts with the death messages.")]
|
||||
class DeathMessages : BaseCommandModule
|
||||
{
|
||||
private readonly Random rnd = new Random();
|
||||
private readonly string[] ActiveDeathMessages = new string[] { "{0} ventilated {1}.", "{0} donated {1}'s body to science.", "{0} introduces {1} to the agony of defeat.", "{0} punched {1}'s ticket.", "{0} demonstrates death without dignity to {1}.", "{0} invites {1} to explore the past tense of being.", "{0} offs {1}.", "{0} gives {1} an out of body experience. ", "{0} burns {1} to smelly jelly.", "{0} makes a righteous mess of {1}.", "{0} composts {1}.", "{0} invites {1} to join the scenery.", "{0} gets medieval on {1}.", "{0} wipes the floor with {1}.", "{0} parties down on {1}.", "{0} opens a can of whoopaz on {1}.", "{0} massacred {1}.", "{0} inflicts a coup de grace on {1}.", "{0} showed {1} how its done.", "{0} donated {1}'s body to big dick Leon.", "{0} introduced {1} to God.", "{0} spanked {1} in front of everyone.", "{0} abused {1}.", "{0} invites {1}'s insides to explore the outside.", "{0} farmed {1} for points.", "{0} ruined {1}.", "{0} got a footshot on {1}.", "{0} makes a splattered mess of {1}.", "{0} tapped {1}'s tenderness.", "{0} didnt go easy on {1}.", "{0} raped, pillaged, and savaged {1}.", "{0} wipes their ass with {1}.", "{0} put {1} out of their misery.", "{0} made {1} shutup.", "{0} made {1} look like a noob.", "{0} owns {1}.", "{0} punked out {1}.", "{0} trolled {1} hard.", "{0} flashy-thinged {1} to death.", "{0} neuralyzed {1}.", "{0} gave {1} a close encounter of the MIB kind.", "{0} blew off one of {1}'s heads.", "{0}'s Noisy Cricket misfired in {1}'s direction.", "{0} shoved a Series 4 De-Atomizer in {1}'s mouth & pulled the trigger.", "{0} shot {1} where it don't grow back.", "{0} shot down an Arquillian Battle Cruiser and it crash-landed on {1}. ", "{0} spilled coffee on {1}'s new suit.", "{0} stepped on {1}'s new shades.", "{0} made an 'Edgar-suit' out of {1}.", "{0}'s Noisy Cricket got wicked on {1}.", "{0} gets sawn in half by {0}.", "{0} died. I blame {0}.", "{0} was axe murdered by {0}.", "{0}'s melon was split by {0}.", "{0} was put on the chop block on {0}.", "{0} was sliced and diced by {0}.", "{0} is split from crotch to sternum by {0}.", "{0} is split in two with a powerful axe blow from {0}.", "{0}'s death put another notch on {0}'s axe..", "{0} escapes infection from {0} by dying first.", "{0} dies from {0}'s mysterious tropical disease.", "{0} eats {0}'s pineapple.", "{0} was gibbed by {0}'s grenade.", "{0} receives a gift from {0}.", "{0} plays pass-the-parcel with {0}.", "{0} was knife-murdered by {0}.", "{0} gets knifed from behind by {0}.", "{0} was nailed by {0}.", "{0} caught one too many nails from {0}.", "{0} ran into {0}'s nails.", "{0} was turned into {0}'s pin-cushion.", "{0} gets no say in it, no say in it at all! sings {0}.", "{0} surfs on a grenade from {0}.", "{0} got up-close and personal with {0}'s grenade.", "{0} played catch with {0}'s grenade.", "{0} received a pineapple enema from {0}.", "{0} fetches {0}'s pineapple.", "{0} caught too much shrapnel from {0}'s grenade.", "{0} tried to pick up {0}'s hot potato.", "{0} thought {0} was tossing him a spare grenade.", "{0} stops to ponder the technical details of {0}'s grenade.", "{0} gets a hole in their heart from {0}'s railgun.", "{0} gets derailed by {0}.", "{0} rides {0}'s rocket.", "{0} was gibbed by {0}'s rocket.", "{0} rides {0}'s firecracker.", "{0} chewed on {0}'s boomstick.", "{0} got too close to {0}'s muzzleflash.", "{0} practices being {0}'s clay pigeon.", "{0} was on the receiving end of {0}'s shotgun barrel.", "{0} was fed a lead diet by {0}.", "{0} got blasted by {0}'s last resort.", "{0} got more than a powderburn from {0}'s shotgun blast.", "{0} was punctured by {0}.", "{0} is put to sleep by {0}.", "{0} is all partied out by {0}.", "{0} killed {1}", "{0} knifed {1}", "{0} eviscerated {1}", "{0} melee killed {1}", "{0} whacked {1}", "{0} beat down {1}", "{0} murdered {1}", "{0} battered {1}", "{0} ended {1}", "{0} rifled {1}", "{0} shot down {1}", "{0} floored {1}", "{0} riddled {1}", "{0} drilled {1}", "{0} submachine gunned {1}", "{0} ruined {1}", "{0} bombed {1}", "{0} detonated {1}", "{0} exploded {1}", "{0} obliterated {1}", "{0} destroyed {1}", "{0} erased {1}", "{0} ripped apart {1}", "{0} torn apart {1}", "{0} wiped out {1}", "{0} pulverised {1}", "{0} shotgunned {1}", "{0} sniped {1}", "{0} picked off {1}", "{0} scoped {1}", "{0} pistoled {1}", "{0} blasted {1}", "{0} plugged {1}", "{0} machine gunned {1}", "{0} sprayed {1}", "{0} flattened {1}", "{0} ran over {1}", "{0} ran {1} down", "{0} mowed down {1}", "{0} chopped up {1}", "{0} killed {1}", "{0} tried to catch {1}", "{0} was crushed by {1}", "{0} was jumped by {1}", "{0} stomps {1}", "{0} was literally stomped into particles by {1}", "{0} was ax-murdered by {1}", "{0} was lead poisoned by {1}", "{0} was body pierced by {1}", "{0} was nailed by {1}", "{0} was perforated by {1}", "{0} was punctured by {1}", "{0} was ventilated by {1}", "{0} was straw-cuttered by {1}", "{0} gets a natural disaster from {1}", Line truncated
|
||||
private readonly string[] PassiveDeathMessages = new string[] { "{1} is chewed up and spit out by {0}", "{1} got curb stomped by {0}", "{1} gets the Vulcan Nerve Pinch from {0}", "{1} felt the burn from {0}.", "{1} took it hard and hot from {0}", "{1} is now a crispy lawn ornament in {0}'s yard.", "{1} brought a knife to the gun fight with {0}.", "{1} is snuffed by {0}.", "{1} gets a flying wedgie from {0}.", "{1} gets a nice wet vivisection from {0}.", "{1}'s ticket was punched by {0}.", "{1}'s personal space was violated by {0}.", "{1} is curb stomped by {0}.", "{1} makes an unsuccessful pass at {0}.", "{1} gets a little chin music from {0}.", "{1} receives a Chicago Overcoat from {0}.", "{1} is cut down in the prime of life by {0}.", "{1} gets drilled by {0}.", "{1} got eighty-sixed by {0}.", "{1} plays tackling dummy for {0}.", "{1} got slaughtered by {0}.", "{1} is annihilated by a lucky shot from {0}.", "{1} is chewed up and shit out by {0}.", "{1} is womped on by {0}.", "{1} got on {0}'s last nerve.", "{1} took one to many hits from {0}.", "{1} tried to run away from {0}.", "{1} is another buried body in {0}'s yard.", "{1} got cheap shotted by {0}.", "{1} got knocked the FUCK out by {0}.", "{1} has to respawn after fighting {0}.", "{1}'s online life is ended by {0}.", "{1}'s personal space is violated by {0}.", "{1} is humbled by {0}, haha.", "{1} makes an unsuccessful gay pass at {0}.", "{1} is just another point on the scoreboard for {0}.", "{1} is in put in the hospital after facing {0}.", "{1} got a beat down in the prime of life by {0}.", "{1} never had a chance going up against {0}.", "{1}'s scap popped when fighting {0}.", "{1} lagged out and lost to {0}.", "{1} is annihilated by a very lucky shot from {0}.", "{1} underestimated the power of {0}'s Noisy Cricket.", "{1} didn't get a chance to put their Ray-Ban's on before {0}'s flashy-thing went off.", "{1} got a Carbonizer in the back of the head from {0}.", "{1} was cut to pieces by {0}'s Series 4 De-Atomizer.", "{1} got their atoms rearranged by {0}." };
|
||||
private readonly string[] GenericDeathMessages = new string[] { "{0} died.", "{0} had an accident.", "{0} gave up.", "{0} is fail!", "{0} went to get their gun back.", "{0} had their Series 4 De-Atomizer pointed the wrong way.", "{0} flashy-thinged himself to death.", "{0} just stepped on their last cockroach.", "{0} was swallowed alive by a giant interstellar cockroach.", "{0} died impossibly!", "{0} grenades himself.", "{0} got splatted by their own grenade.", "{0} sat on their own grenade.", "{0} got to know their grenade too well.", "{0} caught the end of their own grenade.", "{0} got too close to their own grenade.", "{0} let their own grenade get the best of him.", "{0} tiptoed over their own grenade.", "{0} stared at their grenade too long.", "{0} becomes bored with life.", "{0} checks if their gun is loaded.", "{0} committed suicide", "{0} took the easy way out", "{0} sleeps with the fishes", "{0} sucks it down", "{0} gulped a load of slime", "{0} can't exist on slime alone", "{0} burst into flames", "{0} turned into hot slag", "{0} visits the Volcano God", "{0} cratered", "{0} fell to their death", "{0} blew up", "{0} was spiked", "{0} was zapped", "{0} ate a lavaball", "{0} died", "{0} tried to leave", "{0} was squished", "{0} was telefragged by their teammate", "{0} squished a teammate", "{0} mows down a teammate", "{0} checks their glasses", "{0} gets a frag for the other team", "{0} loses another friend", "{0} was crushed by their teammate", "{0} was jumped by their teammate", "{0} died impossibly!", "{0} dispenses with himself.", "{0} detonates an ammo box too close to him", "{0} makes a crater", "{0} shoots their teammate one too many times", "{0} obstructs their team's sentry gun", "{0} tried to use the ", "{0} can't swim worth a crap!", "{0} can't breathe water", "{0} visits the Hell fires", "{0} was mauled by a Rottweiler", "{0} blew up", "{0} was crushed", "{0} was shot", "{0} was torn up by an enemy Rottweiler", "{0} was stopped by an enemy autoturret", "{0} didn't survive the operation.", "{0} tripped off the worldmap.", "{0} got knocked the fuck out!" };
|
||||
|
||||
public DeathMessages()
|
||||
{
|
||||
Console.WriteLine("Death Message Commands Loaded.");
|
||||
}
|
||||
|
||||
[GroupCommand]
|
||||
public async Task DeathMessage(CommandContext ctx, [Description("Optional. Person you want to see kill you. If blank, will show generic death message.")]DiscordMember target = null)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string line = "Something went wrong.";
|
||||
if (target == null)
|
||||
{
|
||||
int choice = rnd.Next(0, GenericDeathMessages.Length);
|
||||
line = GenericDeathMessages[choice];
|
||||
await ctx.RespondAsync(string.Format(line, ctx.Message.Author.Mention));
|
||||
}
|
||||
else
|
||||
{
|
||||
int opt = rnd.Next(1, 3);
|
||||
if (opt == 1)
|
||||
{
|
||||
int choice = rnd.Next(0, ActiveDeathMessages.Length);
|
||||
line = ActiveDeathMessages[choice];
|
||||
}
|
||||
else if (opt == 2)
|
||||
{
|
||||
int choice = rnd.Next(0, PassiveDeathMessages.Length);
|
||||
line = PassiveDeathMessages[choice];
|
||||
}
|
||||
await ctx.RespondAsync(string.Format(line, ctx.Message.Author.Mention, target.Mention));
|
||||
}
|
||||
}
|
||||
|
||||
[Command("count")]
|
||||
[Description("Gets the total of each type of death message")]
|
||||
public async Task DeathMessageCount(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
await ctx.RespondAsync($"\r\nActive: {ActiveDeathMessages.Length}\r\nPassive: {PassiveDeathMessages.Length}\r\nGeneric: {GenericDeathMessages.Length}");
|
||||
}
|
||||
|
||||
[Command("script")]
|
||||
[Description("Gets a script file for all the death messages on the bot.")]
|
||||
public async Task DeathMessagesScript(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
|
||||
if (File.Exists("deathmessages.cs"))
|
||||
{
|
||||
File.Delete("deathmessages.cs");
|
||||
}
|
||||
|
||||
using StreamWriter file = new StreamWriter("deathmessages.cs");
|
||||
|
||||
await file.WriteLineAsync($"$deathMessage::genericCount = {GenericDeathMessages.Length};");
|
||||
await file.WriteLineAsync($"$deathMessage::activeCount = {ActiveDeathMessages.Length};");
|
||||
await file.WriteLineAsync($"$deathMessage::passiveCount = {PassiveDeathMessages.Length};\r\n");
|
||||
|
||||
int count = 0;
|
||||
foreach (string death in GenericDeathMessages)
|
||||
{
|
||||
await file.WriteLineAsync(string.Format($"$deathMessage::generic{count} = \"{death}\";", "%s", "%s"));
|
||||
count++;
|
||||
}
|
||||
count = 0;
|
||||
foreach (string death in ActiveDeathMessages)
|
||||
{
|
||||
await file.WriteLineAsync(string.Format($"$deathMessage::active{count} = \"{death}\";", "%s", "%s"));
|
||||
count++;
|
||||
}
|
||||
count = 0;
|
||||
foreach (string death in PassiveDeathMessages)
|
||||
{
|
||||
await file.WriteLineAsync(string.Format($"$deathMessage::passive{count} = \"{death}\";", "%s", "%s"));
|
||||
count++;
|
||||
}
|
||||
|
||||
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
||||
file.Close();
|
||||
|
||||
FileStream sound = new FileStream($"deathmessages.cs", FileMode.Open);
|
||||
msg.WithFile(sound);
|
||||
msg.Content ="Here is your request for a death message script.";
|
||||
await ctx.RespondAsync(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.VoiceNext;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.CommandsNext.Exceptions;
|
||||
using DSharpPlus.EventArgs;
|
||||
using DSharpPlus.VoiceNext.Codec;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
[Group("functions"), Aliases("func")]
|
||||
class Functions : BaseCommandModule
|
||||
{
|
||||
private readonly DiscordColor[] colours = { DiscordColor.Aquamarine, DiscordColor.Azure, DiscordColor.Black, DiscordColor.Blue, DiscordColor.Blurple,
|
||||
DiscordColor.Brown, DiscordColor.Chartreuse, DiscordColor.CornflowerBlue, DiscordColor.Cyan, DiscordColor.DarkBlue, DiscordColor.DarkButNotBlack,
|
||||
DiscordColor.DarkGray, DiscordColor.DarkGreen, DiscordColor.DarkRed, DiscordColor.Gold, DiscordColor.Goldenrod, DiscordColor.Gray, DiscordColor.Grayple,
|
||||
DiscordColor.Green, DiscordColor.HotPink, DiscordColor.IndianRed, DiscordColor.LightGray, DiscordColor.Lilac, DiscordColor.Magenta, DiscordColor.MidnightBlue,
|
||||
DiscordColor.None, DiscordColor.NotQuiteBlack, DiscordColor.Orange, DiscordColor.PhthaloBlue, DiscordColor.PhthaloGreen, DiscordColor.Purple, DiscordColor.Red,
|
||||
DiscordColor.Rose, DiscordColor.SapGreen, DiscordColor.Sienna, DiscordColor.SpringGreen, DiscordColor.Teal, DiscordColor.Turquoise, DiscordColor.VeryDarkGray,
|
||||
DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow };
|
||||
private readonly Random rnd = new Random();
|
||||
private readonly Dictionary<string, SSFunction> ssFunctions;
|
||||
|
||||
public Functions()
|
||||
{
|
||||
Console.WriteLine("Starsiege Function Commands Loaded");
|
||||
// Load the Functions JSON file. Has all information regarding Starsiege in-game Functions.
|
||||
var json = "";
|
||||
using (var fs = File.OpenRead("functions.json"))
|
||||
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||
json = sr.ReadToEnd();
|
||||
ssFunctions = JsonConvert.DeserializeObject<Dictionary<string, SSFunction>>(json);
|
||||
}
|
||||
|
||||
[GroupCommand]
|
||||
[Description("Gives information on desired function.")]
|
||||
public async Task StarsiegeFunctions(CommandContext ctx, [RemainingText, Description("The function to attempt to look up.")] string command = "")
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
if (command.Equals(string.Empty))
|
||||
{
|
||||
List<string> keys = new List<string>(ssFunctions.Keys);
|
||||
string output = string.Empty;
|
||||
foreach (string item in keys)
|
||||
{
|
||||
if (output.Equals(string.Empty))
|
||||
{
|
||||
output = $"`{item}`";
|
||||
}
|
||||
else
|
||||
{
|
||||
output += $", `{item}`";
|
||||
}
|
||||
}
|
||||
await ctx.RespondAsync("List of known Functions in Starsiege: " + output);
|
||||
}
|
||||
|
||||
|
||||
else if (ssFunctions.TryGetValue(command.ToLower(), out SSFunction outItem))
|
||||
{
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
|
||||
embed.WithTitle(outItem.title);
|
||||
embed.WithTimestamp(DateTime.Now);
|
||||
embed.WithColor(colours[rnd.Next(0, colours.Length)]);
|
||||
embed.WithDescription(outItem.description);
|
||||
foreach (Fields item in outItem.fields)
|
||||
{
|
||||
embed.AddField(item.name, item.value, true);
|
||||
}
|
||||
DiscordEmbed em = embed.Build();
|
||||
await ctx.RespondAsync(embed: em);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ctx.RespondAsync("That command wasn't food, pot-head.");
|
||||
}
|
||||
}
|
||||
|
||||
[Command("count")]
|
||||
public async Task FunctionCount(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
await ctx.RespondAsync($"There are {ssFunctions.Count} functions in the known list.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class SSFunction
|
||||
{
|
||||
public string name;
|
||||
public string title;
|
||||
public string description;
|
||||
public Fields[] fields;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string fs = "";
|
||||
foreach (Fields field in fields)
|
||||
{
|
||||
fs += $"[{field}] ";
|
||||
}
|
||||
|
||||
|
||||
return $"Name: {name} || Title: {title} || Desc: {description} || Fields: {fs}";
|
||||
}
|
||||
}
|
||||
public class Fields
|
||||
{
|
||||
public string name;
|
||||
public string value;
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Name: {name} || Value: {value}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.VoiceNext;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.CommandsNext.Exceptions;
|
||||
using DSharpPlus.EventArgs;
|
||||
using DSharpPlus.VoiceNext.Codec;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
[Aliases("qc"), Group("quickchat")]
|
||||
class Quickchat : BaseCommandModule
|
||||
{
|
||||
private readonly List<Quickchats> Quickchats;
|
||||
private readonly Random rnd = new Random();
|
||||
|
||||
public Quickchat()
|
||||
{
|
||||
Console.WriteLine("Quick Chat Commands Loaded");
|
||||
// Load all the Quick Chat texts and sound wav file info.
|
||||
var json = "";
|
||||
using (var fs = File.OpenRead("quickchats.json"))
|
||||
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||
json = sr.ReadToEnd();
|
||||
Dictionary<string, Quickchats> tempQC = JsonConvert.DeserializeObject<Dictionary<string, Quickchats>>(json);
|
||||
Quickchats = Enumerable.ToList(tempQC.Values);
|
||||
|
||||
}
|
||||
|
||||
[Command("script")]
|
||||
[Description("Gives the `say()` for use in the Quickchat.cs file.")]
|
||||
public async Task GetQuickChatScript(CommandContext ctx, [Description("ID of Quick chat to get script for.")] int index)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
if (index < Quickchats.Count || index >= 0)
|
||||
{
|
||||
Quickchats chat = Quickchats[index];
|
||||
await ctx.RespondAsync("```" + chat.ToString() + "```");
|
||||
}
|
||||
else
|
||||
{
|
||||
await ctx.RespondAsync("The ID specified is out of bounds. 0-" + (Quickchats.Count - 1));
|
||||
}
|
||||
}
|
||||
|
||||
[Command("check")]
|
||||
[Description("Runs a check to see how many WAV files are missing from all QC's.")]
|
||||
public async Task QuickChatCheck(CommandContext ctx)
|
||||
{
|
||||
int missingFiles = 0;
|
||||
for (int i = 0; i < Quickchats.Count; i++)
|
||||
{
|
||||
if (!File.Exists($"./qc/{Quickchats[i].soundFile}"))
|
||||
{
|
||||
missingFiles++;
|
||||
Console.Write($"{i}, ");
|
||||
}
|
||||
}
|
||||
await ctx.RespondAsync($"Missing files: {missingFiles}");
|
||||
}
|
||||
|
||||
[GroupCommand]
|
||||
[Description("Gives a specific or random Quickchat. If that QC has a sound file that the bot knows, uploads the sound file too.")]
|
||||
public async Task QuickChat(CommandContext ctx, [Description("The ID of the quick Chat.")] int id = -1)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
||||
|
||||
Quickchats chat;
|
||||
|
||||
if (id != -1)
|
||||
id = Math.Abs(id);
|
||||
if (id == -1 || id > Quickchats.Count)
|
||||
{
|
||||
int idnum = rnd.Next(Quickchats.Count);
|
||||
chat = Quickchats[idnum];
|
||||
msg.Content = idnum + ": " + chat.text;
|
||||
}
|
||||
else
|
||||
{
|
||||
chat = Quickchats[id];
|
||||
msg.Content = id + ": " + chat.text;
|
||||
|
||||
}
|
||||
if (File.Exists($"./qc/{chat.soundFile}"))
|
||||
{
|
||||
FileStream sound = new FileStream($"./qc/{chat.soundFile}", FileMode.Open);
|
||||
msg.WithFile(sound);
|
||||
await ctx.RespondAsync(msg);
|
||||
sound.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
await ctx.RespondAsync(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Quickchats
|
||||
{
|
||||
public string text;
|
||||
public string soundFile;
|
||||
public override string ToString()
|
||||
{
|
||||
return $"say(0,0, \"{text}\", \"{soundFile}\");";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DSharpPlus" Version="4.0.0-rc3" />
|
||||
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-rc3" />
|
||||
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-rc3" />
|
||||
<PackageReference Include="DSharpPlus.Lavalink" Version="4.0.0-rc3" />
|
||||
<PackageReference Include="DSharpPlus.VoiceNext" Version="4.0.0-rc3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Unicorn\" />
|
||||
<Folder Include="Phoenix\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.VoiceNext;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.CommandsNext.Exceptions;
|
||||
using DSharpPlus.EventArgs;
|
||||
using DSharpPlus.VoiceNext.Codec;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using DSharpPlus.Interactivity;
|
||||
using DSharpPlus.Interactivity.Extensions;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
[Group("ex")]
|
||||
[Hidden]
|
||||
|
||||
[Description("Experimental commands. May break the bot.")]
|
||||
class StarsiegeCommands : BaseCommandModule
|
||||
{
|
||||
private readonly List<Questions> QuizQuestions;
|
||||
private readonly Random rnd = new Random();
|
||||
public StarsiegeCommands()
|
||||
{
|
||||
// Load all the Quick Chat texts and sound wav file info.
|
||||
var json = "";
|
||||
using (var fs = File.OpenRead("questions.json"))
|
||||
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||
json = sr.ReadToEnd();
|
||||
Dictionary<string, Questions> tempQC = JsonConvert.DeserializeObject<Dictionary<string, Questions>>(json);
|
||||
QuizQuestions = Enumerable.ToList(tempQC.Values);
|
||||
|
||||
}
|
||||
[Command("quiz")]
|
||||
[Hidden]
|
||||
[Description("")]
|
||||
public async Task Quiz(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
|
||||
|
||||
int[] ids = { rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count)};
|
||||
int selection = rnd.Next(ids.Length);
|
||||
int mainId = ids[selection];
|
||||
string[] options = { "a", "b", "c", "d" };
|
||||
|
||||
var correctAnswer = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{options[selection]}:");
|
||||
|
||||
Questions myQuestion = QuizQuestions[mainId];
|
||||
|
||||
embed.Description = myQuestion.Question;
|
||||
|
||||
embed.AddField($":regional_indicator_{options[0]}:", QuizQuestions[ids[0]].Answers[rnd.Next(QuizQuestions[ids[0]].Answers.Length)], true);
|
||||
embed.AddField($":regional_indicator_{options[1]}:", QuizQuestions[ids[1]].Answers[rnd.Next(QuizQuestions[ids[1]].Answers.Length)], true);
|
||||
embed.AddField("_ _", "_ _", false);
|
||||
embed.AddField($":regional_indicator_{options[2]}:", QuizQuestions[ids[2]].Answers[rnd.Next(QuizQuestions[ids[2]].Answers.Length)], true);
|
||||
embed.AddField($":regional_indicator_{options[3]}:", QuizQuestions[ids[3]].Answers[rnd.Next(QuizQuestions[ids[3]].Answers.Length)], true);
|
||||
|
||||
var message = await ctx.RespondAsync(embed);
|
||||
foreach (var item in options)
|
||||
{
|
||||
var itemEmote = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{item}:");
|
||||
await message.CreateReactionAsync(itemEmote);
|
||||
}
|
||||
var result = message.WaitForReactionAsync(ctx.Message.Author,TimeSpan.FromSeconds(5d));
|
||||
if (!result.Result.TimedOut)
|
||||
{
|
||||
if (result.Result.Result.Emoji == correctAnswer) await ctx.RespondAsync("**CORRECT!!**");
|
||||
else await ctx.RespondAsync($"Sorry, the right answer was {correctAnswer}");
|
||||
}
|
||||
else await ctx.RespondAsync("Sorry, time ran out!");
|
||||
}
|
||||
|
||||
[Command("test")]
|
||||
[Hidden]
|
||||
public async Task CollectionCommand(CommandContext ctx)
|
||||
{
|
||||
var message = await ctx.RespondAsync("React here!");
|
||||
var reactions = await message.CollectReactionsAsync();
|
||||
|
||||
var strBuilder = new StringBuilder();
|
||||
Dictionary<DiscordUser, bool> winners = new Dictionary<DiscordUser, bool>();
|
||||
Dictionary<DiscordUser, bool> losers = new Dictionary<DiscordUser, bool>();
|
||||
var correctEmote = reactions[0].Emoji;
|
||||
foreach (var reaction in reactions)
|
||||
{
|
||||
foreach (var person in reaction.Users)
|
||||
{
|
||||
if ( ! correctEmote.Equals(reaction.Emoji))
|
||||
{
|
||||
losers.Add(person, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
winners.Add(person, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<DiscordUser, bool> pair in winners)
|
||||
{
|
||||
if (losers.ContainsKey(pair.Key))
|
||||
{
|
||||
winners.Remove(pair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
strBuilder.AppendLine("Winners are:");
|
||||
foreach (KeyValuePair<DiscordUser, bool> item in winners)
|
||||
{
|
||||
strBuilder.AppendLine(item.Key.Mention);
|
||||
}
|
||||
|
||||
await ctx.RespondAsync(strBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public class Questions
|
||||
{
|
||||
[JsonProperty("question")]
|
||||
public string Question { get; private set; }
|
||||
[JsonProperty("answer")]
|
||||
public string[] Answers { get; private set; }
|
||||
[JsonProperty("points")]
|
||||
public int Points { get; private set; }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user